1 6 7 package com.sun.enterprise.config.backup.phase; 8 9 import com.sun.enterprise.config.backup.status.BackupStatus; 10 import com.sun.enterprise.config.backup.BackupException; 11 import com.sun.enterprise.config.backup.status.Status; 12 import com.sun.enterprise.config.backup.status.StatusConstants; 13 import com.sun.enterprise.config.backup.StatusRegistry; 14 import com.sun.enterprise.config.backup.utils.LoggerHelper; 15 import com.sun.enterprise.config.backup.utils.LocalStringsHelper; 16 import com.sun.enterprise.config.backup.pluggable.BackupStorage; 17 import com.sun.enterprise.config.backup.BackupAbortException; 18 import com.sun.enterprise.config.backup.utils.BackupHelper; 19 import com.sun.enterprise.config.backup.utils.FactoryHelper; 20 21 25 public class BackupPhases extends PhasesBase { 26 27 28 public BackupPhases() { 29 } 30 31 36 37 public void assertStatusNotNull(BackupStatus bs) { 38 if(bs == null) { 39 LoggerHelper.info("null_status_in_backup"); 40 BackupStatus bs1 = new BackupStatus(); 42 setStatusInRegistry(bs1); 43 throw new BackupAbortException( 44 "error_invoking_backup_null_status", 45 LocalStringsHelper.getString( 46 "error_invoking_backup_null_status")); 47 } 48 } 49 50 51 public void setAbsoluteBackupFileName(String absoluteTargetFile) { 52 getStatus().setAbsoluteBackupFileName(absoluteTargetFile); 53 LoggerHelper.fine("Target File for backup is " + absoluteTargetFile); 54 55 } 56 57 public BackupStatus getStatus() { 58 return (BackupStatus)getStatusFromRegistry(); 59 } 60 61 public void monitorBackupDir() { 62 try { 63 FactoryHelper.getBackupStorageMonitor().run(); 64 } catch(Exception e) { 65 LoggerHelper.warning("error_monitoring_backup_dir"); 67 LoggerHelper.fine("error_monitoring_backup_dir", e); 68 } 69 } 70 71 public void setBackupFileSize(long size) { 72 getStatus().setBackupFileSize(size); 73 } 74 75 public long backup() throws Exception { 76 String [] srcDirs = getStatus().getDirectoriesToBackup(); 77 LoggerHelper.fine("Source Directory for backup is " 78 + BackupHelper.ArrayToString(srcDirs)); 79 80 String absTargetFile = getStatus().getAbsoluteBackupFileName(); 81 BackupStorage backupStorage = FactoryHelper.getStorage(); 83 return backupStorage.backup(srcDirs, absTargetFile); 84 } 85 86 public void addStatusFile() { 87 String absTargetFile = getStatus().getAbsoluteBackupFileName(); 88 BackupStorage backupStorage = FactoryHelper.getStorage(); 90 backupStorage.createStatusFile(absTargetFile, getStatus()); 91 } 92 93 } 94 | Popular Tags |