FileDocCategorySizeDatePackage
BackupManager.javaAPI DocGlassfish v2 API4004Fri May 04 22:23:14 BST 2007com.sun.enterprise.config.backup

BackupManager

public class BackupManager extends BackupRestoreManager
author
Byron Nevins

Fields Summary
Status
status
Constructors Summary
public BackupManager(BackupRequest req)

		super(req);
	
Methods Summary
public final java.lang.Stringbackup()

		String mesg = StringHelper.get("backup-res.SuccessfulBackup");
		String statusString = writeStatus();
		
		if(request.terse == false)
		{
			mesg += "\n\n" + statusString;
		}
		
		try
		{
			ZipStorage zs = new ZipStorage(request);
			zs.store();
			return mesg;
		}
		finally
		{
			status.delete();
			FileUtils.protect(request.backupFile);
		}
	
voidinit()

		super.init();
		
		if(request.backupFile != null)
			throw new BackupException("backup-res.InternalError", "No backupFilename may be specified for a backup -- it is reserved for restore operations only.");
		
		if(!FileUtils.safeIsDirectory(request.domainDir))
			throw new BackupException("backup-res.NoDomainDir", request.domainDir);

		File backupDir = new File(request.domainDir, Constants.BACKUP_DIR);

		// not an error for this directory to not exist yet
		backupDir.mkdirs();

		// NOW it's an error to not exist...
		if(!FileUtils.safeIsDirectory(backupDir))
			throw new BackupException("backup-res.NoBackupDirCantCreate", backupDir);

		String ts = "" + request.timestamp + ".zip";
		BackupFilenameManager bfmgr = new BackupFilenameManager(backupDir);
		request.backupFile = bfmgr.next();
		//request.backupFile = new File(backupDir, ts);
	
private java.lang.StringwriteStatus()

		status = new Status();
		return status.write(request);