1 6 7 package com.sun.enterprise.config.backup.phase; 8 9 import com.sun.enterprise.config.backup.status.RestoreStatus; 10 import com.sun.enterprise.config.backup.status.SnapShotStatus; 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.pluggable.BackupStorage; 16 import com.sun.enterprise.config.backup.BackupAbortException; 17 import com.sun.enterprise.config.backup.BackupException; 18 import com.sun.enterprise.config.backup.utils.BackupHelper; 19 import com.sun.enterprise.config.backup.utils.FactoryHelper; 20 import com.sun.enterprise.config.backup.utils.LocalStringsHelper; 21 import java.io.File ; 22 import java.io.IOException ; 23 24 28 public class RestorePhases extends PhasesBase { 29 30 31 public RestorePhases() { 32 } 33 34 39 40 public void assertStatusNotNull(RestoreStatus rs) { 41 if(rs == null) { 42 LoggerHelper.info("null_status_in_restore"); 43 RestoreStatus rs1 = new RestoreStatus(); 45 setStatusInRegistry(rs1); 46 47 throw new BackupAbortException( 48 "error_invoking_restore", 49 LocalStringsHelper.getString("error_invoking_restore")); 50 } 51 } 52 53 public RestoreStatus getStatus() { 54 return (RestoreStatus)getStatusFromRegistry(); 55 } 56 57 public void monitorBackupDir() { 58 try { 59 FactoryHelper.getBackupStorageMonitor().run(); 60 } catch(Exception e) { 61 LoggerHelper.warning("error_monitoring_backup_dir"); 63 LoggerHelper.fine("error_monitoring_backup_dir", e); 64 } 65 } 66 67 74 76 80 public void takeSnapShot() { 81 try { 82 SnapShotStatus ss = new SnapShotStatus(true); 84 long size = backup(ss.getAbsoluteSnapShotFileName(), ss); 85 ss.setStatusCode(StatusConstants.STATUS_SUCCESS); 86 LoggerHelper.fine("snapshot info= " + ss); 87 FactoryHelper.getSnapShotStorageMonitor().run(); 88 } catch(Exception e1) { 89 LoggerHelper.info("ignore_error_taking_snapshot ", e1); 90 } 91 } 92 93 private long backup(String absSnapShotFileName, SnapShotStatus ss) throws Exception { 94 String [] srcDirs = ss.getDirectoriesToBackup(); 95 LoggerHelper.fine("Source Directory for snapshot is " 96 + BackupHelper.ArrayToString(srcDirs)); 97 98 BackupStorage backupStorage = FactoryHelper.getStorage(); 100 return backupStorage.backup(srcDirs, absSnapShotFileName); 101 } 102 103 public void performRestore(File f) throws Exception { 104 FactoryHelper.getStorage().restore(f); 105 } 106 107 111 public void deleteTarget() { 112 FactoryHelper.getStorage().deleteTarget(); 114 } 115 } 116 | Popular Tags |