1 16 package org.outerj.daisy.backupTool; 17 18 import java.io.File ; 19 20 public abstract class AbstractBackupEntry implements BackupEntry { 21 protected File backupFile; 22 protected BackupInstance buInstance; 23 24 public AbstractBackupEntry (File backupFile, BackupInstance buInstance) { 25 this.backupFile = backupFile; 26 this.buInstance = buInstance; 27 } 28 29 public String generateDigest() throws Exception { 30 return BackupHelper.generateMD5Hash(backupFile); 31 } 32 33 public void backupCleanup() throws Exception { 34 if (!isNothing()) { 35 try { 36 BackupHelper.fileToZip(getTempPath(), backupFile); 37 } catch (Throwable e) { 38 throw new Exception ("Error zipping backup files into " + backupFile.getAbsolutePath(), e); 39 } 40 } else { 41 System.out.println("Excluding " + backupFile.getName() + " from the backup because it is empty."); 42 } 43 44 try { 45 BackupHelper.deleteFile(getTempPath()); 46 } catch (Throwable e) { 47 throw new Exception ("Error deleting temporary backup file or directory: " + getTempPath().getAbsolutePath(), e); 48 } 49 } 50 51 protected abstract File getTempPath(); 52 53 57 protected abstract boolean isNothing(); 58 } 59 | Popular Tags |