1 23 24 package com.sun.enterprise.config.backup; 25 26 import com.sun.enterprise.config.backup.util.*; 27 import java.io.*; 28 import java.util.*; 29 30 31 35 36 37 public class BackupManager extends BackupRestoreManager 38 { 39 public BackupManager(BackupRequest req) throws BackupException 40 { 41 super(req); 42 } 43 44 46 public final String backup() throws BackupException 47 { 48 String mesg = StringHelper.get("backup-res.SuccessfulBackup"); 49 String statusString = writeStatus(); 50 51 if(request.terse == false) 52 { 53 mesg += "\n\n" + statusString; 54 } 55 56 try 57 { 58 ZipStorage zs = new ZipStorage(request); 59 zs.store(); 60 return mesg; 61 } 62 finally 63 { 64 status.delete(); 65 FileUtils.protect(request.backupFile); 66 } 67 } 68 69 71 void init() throws BackupException 72 { 73 super.init(); 74 75 if(request.backupFile != null) 76 throw new BackupException("backup-res.InternalError", "No backupFilename may be specified for a backup -- it is reserved for restore operations only."); 77 78 if(!FileUtils.safeIsDirectory(request.domainDir)) 79 throw new BackupException("backup-res.NoDomainDir", request.domainDir); 80 81 File backupDir = new File(request.domainDir, Constants.BACKUP_DIR); 82 83 backupDir.mkdirs(); 85 86 if(!FileUtils.safeIsDirectory(backupDir)) 88 throw new BackupException("backup-res.NoBackupDirCantCreate", backupDir); 89 90 String ts = "" + request.timestamp + ".zip"; 91 BackupFilenameManager bfmgr = new BackupFilenameManager(backupDir); 92 request.backupFile = bfmgr.next(); 93 } 95 96 98 private String writeStatus() 99 { 100 status = new Status(); 101 return status.write(request); 102 } 103 104 106 Status status; 107 } 108 | Popular Tags |