org.jvnet.hudson.plugins.thinbackup.backup
Class BackupSet

java.lang.Object
  extended by org.jvnet.hudson.plugins.thinbackup.backup.BackupSet
All Implemented Interfaces:
java.lang.Comparable<BackupSet>

public class BackupSet
extends java.lang.Object
implements java.lang.Comparable<BackupSet>

A BackupSet contains references to a full and zero or more diff backups. It can be created from either a reference to a full or diff backup directory or from a reference to a ZIP file. If it is created from a ZIP file, the BackupSet must be unzipped before the data contained can be actually accessed (it is never unzipped automatically).


Field Summary
static java.lang.String BACKUPSET_ZIPFILE_PREFIX
           
 
Constructor Summary
BackupSet(java.io.File initial)
           
 
Method Summary
 int compareTo(BackupSet other)
          Compares the backup sets by using the sets' associated full backups' backup date.
 boolean containsBackupForDate(java.util.Date date)
           
 boolean containsDirectory(java.io.File directory)
           
 void delete()
           
 void deleteUnzipDir()
          Deletes the directory used for unzipping this BackupSet.
 java.util.List<java.io.File> getDiffBackups()
           
 java.util.List<java.lang.String> getDiffBackupsNames()
           
 java.io.File getFullBackup()
           
 java.lang.String getFullBackupName()
           
 java.io.File getUnzipDir()
           
 boolean isInZipFile()
           
 boolean isValid()
           
 java.lang.String toString()
           
 BackupSet unzip()
          Unzips this backup set if it was initialized from a ZIP file.
 BackupSet unzipTo(java.io.File directory)
          Unzips this backup set into a directory within the specified directory if it was initialized from a ZIP file.
 java.io.File zipTo(java.io.File directory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

BACKUPSET_ZIPFILE_PREFIX

public static final java.lang.String BACKUPSET_ZIPFILE_PREFIX
See Also:
Constant Field Values
Constructor Detail

BackupSet

public BackupSet(java.io.File initial)
Parameters:
initial - either a FULL or DIFF backup directory, or a BackupSet ZIP file.
Method Detail

isValid

public boolean isValid()
Returns:
true if this backup set has a referenced full backup.

delete

public void delete()
            throws java.io.IOException
Throws:
java.io.IOException

deleteUnzipDir

public void deleteUnzipDir()
Deletes the directory used for unzipping this BackupSet. Note that this will make BackupSets created from that directory no longer usable.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

unzip

public BackupSet unzip()
                throws java.io.IOException
Unzips this backup set if it was initialized from a ZIP file. Does does NOT change this. Unzip location is Utils.THINBACKUP_TMP_DIR. deleteUnzipDir() may be called if the unzipped BackupSet is no longer needed. Before using the returned BackupSet, it should be checked if it is valid.

Returns:
a new BackupSet referencing the unzipped directories, or the current BackupSet if it was either not created from a ZIP file or is invalid. In case of an error an invalid BackupSet is returned.
Throws:
java.io.IOException

unzipTo

public BackupSet unzipTo(java.io.File directory)
                  throws java.io.IOException
Unzips this backup set into a directory within the specified directory if it was initialized from a ZIP file. Does NOT change this. deleteUnzipDir() may be called if the unzipped BackupSet is no longer needed. The directory the BackupSet was unzipped to can be retrieved with getUnzipDir(). Before using the returned BackupSet, it should be checked if it is valid.

Parameters:
directory -
Returns:
a new BackupSet referencing the unzipped directories, or the current BackupSet if it was either not created from a ZIP file or is invalid. In case of an error an invalid BackupSet is returned.
Throws:
java.io.IOException

zipTo

public java.io.File zipTo(java.io.File directory)
Parameters:
directory -
Returns:
a reference to the created ZIP file, the current ZIP file if the BackupSet was created from one (because no zipping is performed in this case), or null if this BackupSet is invalid.

compareTo

public int compareTo(BackupSet other)
Compares the backup sets by using the sets' associated full backups' backup date.

Specified by:
compareTo in interface java.lang.Comparable<BackupSet>
Returns:
-1 if this BackupSet's full backup date is before the other's, 0 if they are equal, 1 if is after the other's.

containsDirectory

public boolean containsDirectory(java.io.File directory)
Parameters:
directory -
Returns:
true if this BackupSet contains a backup directory with the same name or if directory is null. Note that only the top level backup directories are checked, not any other contents of the BackupSet.

containsBackupForDate

public boolean containsBackupForDate(java.util.Date date)
Parameters:
date -
Returns:
true if a backup for the given date exists in this BackupSet.

isInZipFile

public boolean isInZipFile()
Returns:
true if this BackupSet was constructed from a ZIP file.

getFullBackup

public java.io.File getFullBackup()
Returns:
the full backup directory reference, or null if this BackupSet is in a ZIP file.

getFullBackupName

public java.lang.String getFullBackupName()
Returns:
the name of full backup directory.

getDiffBackups

public java.util.List<java.io.File> getDiffBackups()
Returns:
a List of diff backup directory references, or null if this BackupSet is in a ZIP file.

getDiffBackupsNames

public java.util.List<java.lang.String> getDiffBackupsNames()
Returns:
a List of diff backup directory names.

getUnzipDir

public java.io.File getUnzipDir()
Returns:
a reference to the directory where this BackupSet was unzipped, or null if it either was not yet unzipped or if this BackupSet is not in a ZIP file.


Copyright © 2004-2013. All Rights Reserved.