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

ZipStorage

public class ZipStorage extends Object
This class implements storing backups as zip files.
author
Byron Nevins

Fields Summary
private BackupRequest
request
Constructors Summary
ZipStorage(BackupRequest req)

param
req
throws
BackupException

		if(req == null)
			throw new BackupException("backup-res.NoBackupRequest", getClass().getName() + ".ctor");
		
		request = req;
	
Methods Summary
voidstore()
Backups the files to a zip file.

throws
BackupException if there were any errors writing the file.

		String zipName			= FileUtils.safeGetCanonicalPath(request.backupFile);
		String domainDirName	= FileUtils.safeGetCanonicalPath(request.domainDir);
		
		FileListerRelative lister = new FileListerRelative(request.domainDir);
		lister.keepEmptyDirectories();	// we want to restore any empty directories too!
		String[] files = lister.getFiles();
		
		LoggerHelper.fine("Writing " + zipName);
		
		try
		{
			ZipWriter writer = new ZipWriter(zipName, domainDirName, files);

			if(request.excludeDirs != null && request.excludeDirs.length > 0)
				writer.excludeDirs(request.excludeDirs);
			
			writer.safeWrite();
		}
		catch(ZipFileException zfe)
		{
			throw new BackupException("backup-res.ZipBackupError", zfe, zipName);
		}
	
voidwrite()