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

ListManager

public class ListManager extends BackupRestoreManager
This class is responsible for returning information about backups. It opens each backup zip file and examines the properties file for the information that was stored when the backup was performed. It returns all this information to CLI as a String.
author
bnevins

Fields Summary
File[]
zips
Constructors Summary
public ListManager(BackupRequest req)
Creates an instance of ListManager. The superclass will call init() so it is possible for Exceptions to be thrown.

param
req The BackupRequest instance with required information.
throws
BackupException if there is a fatal error with the BackupRequest object.
throws
BackupWarningException if there is a non-fatal error with the BackupRequest object.

		super(req);
	
Methods Summary
voidfindZips()
Looks through the backups directory and assembles a list of all backup files found.

throws
BackupWarningException if there are no backup zip files

		zips = request.backupDir.listFiles(new ZipFilenameFilter());

		if(zips == null || zips.length <= 0)
			throw new BackupWarningException("backup-res.NoBackupFiles", request.backupDir);
	
voidinit()
Finish initializing the BackupRequest object. note: this method is called by the super class...

throws
BackupException for fatal errors
throws
BackupWarningException for non-fatal errors - these are errors where we can not continue execution.

		super.init();
		
		if(!FileUtils.safeIsDirectory(request.domainDir))
			throw new BackupException("backup-res.NoDomainDir", request.domainDir);

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

		// It's a warning to not exist...
		if(!FileUtils.safeIsDirectory(request.backupDir))
			throw new BackupWarningException("backup-res.NoBackupDir", request.backupDir);
	
public java.lang.Stringlist()
Find all backup zip files in a domain and return a String summarizing information about the backup. The summary is shorter if the "terse" option is true.

return
a String summary
throws
BackupException if there is a fatal error

		StringBuffer sb = new StringBuffer();
		
		findZips();
		
		// it is GUARANTEED that the length > 0
		for(int i = 0; i < zips.length; i++)
		{
			Status status = new Status();
			sb.append(status.read(zips[i], request.terse));
			sb.append("\n");
			
			if(request.terse == false)
				sb.append("\n");
		}
		
		return sb.toString();