1 6 7 package com.sun.enterprise.config.backup.phase; 8 9 import com.sun.enterprise.config.backup.utils.FactoryHelper; 10 import com.sun.enterprise.config.backup.utils.BackupHelper; 11 import com.sun.enterprise.config.backup.utils.LoggerHelper; 12 import com.sun.enterprise.config.backup.utils.LocalStringsHelper; 13 import com.sun.enterprise.config.backup.status.Status; 14 import com.sun.enterprise.config.backup.status.RemoveStatus; 15 import com.sun.enterprise.config.backup.status.StatusConstants; 16 import com.sun.enterprise.config.backup.BackupException; 17 import com.sun.enterprise.util.io.FileUtils; 18 import java.io.File ; 19 20 24 public class RemovePhases extends PhasesBase { 25 26 27 public RemovePhases() { 28 } 29 30 public RemoveStatus deleteBackup(File f, boolean system) { 31 LoggerHelper.fine("deleting_backup_file " + f.getName()); 32 RemoveStatus rs = null; 33 try { 34 rs = new RemoveStatus(f.getName(), system); 35 if(!f.exists()) { 36 throw new BackupException( 37 "error_delete_invalid_file", 38 LocalStringsHelper.getString("error_delete_invalid_file",f)); 39 } 40 FileUtils.liquidate(f); 41 setSuccess(rs); 42 } catch(Exception e) { 44 RemoveStatus rs1 = null; 45 try { 46 rs1 = new RemoveStatus(); 47 setFailure(rs1, e); 48 }catch (Exception ex){} 49 return rs1; 50 } 51 return rs; 52 } 53 54 private void setSuccess(Status rs) { 55 try { 56 rs.setStatusCode(StatusConstants.STATUS_SUCCESS); 57 } catch (Exception e) { 58 } 60 } 61 62 63 private void setFailure(Status rs, Exception e) { 64 try { 65 rs.setStatusCode(StatusConstants.STATUS_FAILURE); 66 rs.setException(e); 67 } catch (Exception e1) { 68 } 70 } 71 72 public RemoveStatus deleteBackup(String name, boolean system) { 73 File f; 74 try { 75 f = new File (BackupHelper.getAbsoluteBackupFileName(name)); 76 } catch(Exception e) { 77 RemoveStatus rs = null; 78 try { 79 rs = new RemoveStatus(); 80 setFailure(rs, e); 81 } catch(Exception ex){} 82 return rs; 83 } 84 return deleteBackup(f, system); 85 } 86 87 private void updateHistory(Status rs) { 88 try { 89 FactoryHelper.getHistoryManager().addHistoryEntry(rs); 90 } catch(Exception e) { 91 LoggerHelper.warning("error_adding_history_entry", e); 92 } 94 } 95 } 96 | Popular Tags |