org.jvnet.hudson.plugins.thinbackup.utils
Class Utils

java.lang.Object
  extended by org.jvnet.hudson.plugins.thinbackup.utils.Utils

public class Utils
extends java.lang.Object


Field Summary
static java.text.SimpleDateFormat DIRECTORY_NAME_DATE_FORMAT
           
static java.text.SimpleDateFormat DISPLAY_DATE_FORMAT
           
static java.lang.String THINBACKUP_TMP_DIR
           
 
Constructor Summary
Utils()
           
 
Method Summary
static java.lang.String convertToDirectoryNameDateFormat(java.lang.String displayFormattedDate)
           
static java.util.List<java.lang.String> getBackupsAsDates(java.io.File directory)
           
static java.util.List<java.io.File> getBackupSetZipFiles(java.io.File parentDir)
           
static java.util.List<java.io.File> getBackupTypeDirectories(java.io.File parentDir, ThinBackupPeriodicWork.BackupType backupType)
           
static java.util.Date getDateFromBackupDirectory(java.io.File directory)
           
static java.util.Date getDateFromBackupDirectoryName(java.lang.String directoryName)
           
static java.io.File getFormattedDirectory(java.io.File parent, ThinBackupPeriodicWork.BackupType backupType, java.util.Date date)
           
static java.io.File getReferencedFullBackup(java.io.File diffBackup)
           
static java.util.List<java.io.File> getReferencingDiffBackups(java.io.File fullBackup)
           
static java.util.List<BackupSet> getValidBackupSets(java.io.File directory)
           
static java.util.List<BackupSet> getValidBackupSetsFromDirectories(java.io.File directory)
           
static java.util.List<BackupSet> getValidBackupSetsFromZips(java.io.File directory)
           
static void moveOldBackupsToZipFile(java.io.File backupRoot, java.io.File currentBackup)
          Moves all backup sets (that are not already zipped) other than the one containing currentBackup to ZIP files located in backupRoot.
static void waitUntilIdle()
          Waits until all Hudson slaves are idle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_DATE_FORMAT

public static java.text.SimpleDateFormat DISPLAY_DATE_FORMAT

DIRECTORY_NAME_DATE_FORMAT

public static java.text.SimpleDateFormat DIRECTORY_NAME_DATE_FORMAT

THINBACKUP_TMP_DIR

public static final java.lang.String THINBACKUP_TMP_DIR
Constructor Detail

Utils

public Utils()
Method Detail

waitUntilIdle

public static void waitUntilIdle()
Waits until all Hudson slaves are idle.


getDateFromBackupDirectory

public static java.util.Date getDateFromBackupDirectory(java.io.File directory)
                                                 throws java.text.ParseException
Parameters:
directory -
Returns:
the date component of a directory name formatted in the thinBackup standard
Throws:
java.text.ParseException - if the name could not be parsed

getDateFromBackupDirectoryName

public static java.util.Date getDateFromBackupDirectoryName(java.lang.String directoryName)
                                                     throws java.text.ParseException
Parameters:
directoryName -
Returns:
the date component of a directory name formatted in the thinBackup standard
Throws:
java.text.ParseException - if the name could not be parsed

convertToDirectoryNameDateFormat

public static java.lang.String convertToDirectoryNameDateFormat(java.lang.String displayFormattedDate)
                                                         throws java.text.ParseException
Parameters:
displayFormattedDate - a String in the display format date
Returns:
the string formatted in the directory names' date format
Throws:
java.text.ParseException

getFormattedDirectory

public static java.io.File getFormattedDirectory(java.io.File parent,
                                                 ThinBackupPeriodicWork.BackupType backupType,
                                                 java.util.Date date)
Parameters:
parent -
backupType -
date -
Returns:
a reference to a file in the given parent directory with a name formatted like "-yyyy-MM-dd_HH-mm".

getBackupTypeDirectories

public static java.util.List<java.io.File> getBackupTypeDirectories(java.io.File parentDir,
                                                                    ThinBackupPeriodicWork.BackupType backupType)
Parameters:
parentDir -
backupType -
Returns:
an unordered list of backup directories of the given backup type.

getBackupSetZipFiles

public static java.util.List<java.io.File> getBackupSetZipFiles(java.io.File parentDir)
Parameters:
parentDir -
Returns:
an unordered list of zipped backupsets in the given directory.

getReferencedFullBackup

public static java.io.File getReferencedFullBackup(java.io.File diffBackup)
Parameters:
diffBackup -
Returns:
the full backup referenced by the given diff backup, or null if none can be found.

getReferencingDiffBackups

public static java.util.List<java.io.File> getReferencingDiffBackups(java.io.File fullBackup)
Parameters:
fullBackup -
Returns:
a list of all diff backups which reference the given full backup.

getBackupsAsDates

public static java.util.List<java.lang.String> getBackupsAsDates(java.io.File directory)
Parameters:
directory -
Returns:
a list of backups in the given directory (both FULL and DIFF), displayed as the respective backup date, from both directories and ZIP files, ordered descending by the date encoded in the backups' name.

getValidBackupSetsFromDirectories

public static java.util.List<BackupSet> getValidBackupSetsFromDirectories(java.io.File directory)
Parameters:
directory -
Returns:
a list of valid (@see BackupSet#isValid) backup sets that exists as directories (not as ZIP files) in the given directory, ordered ascending by the backup date of the BackupSets' full backup.

getValidBackupSetsFromZips

public static java.util.List<BackupSet> getValidBackupSetsFromZips(java.io.File directory)
Parameters:
directory -
Returns:
a list of valid (@see BackupSet#isValid) backup sets that exists as ZIP files (not as directories) in the given directory, ordered ascending by the backup date of the BackupSets' full backup.

getValidBackupSets

public static java.util.List<BackupSet> getValidBackupSets(java.io.File directory)
Parameters:
directory -
Returns:
a list of valid (@see BackupSet#isValid) backup sets in the given directory, ordered ascending by the backup date of the BackupSets' full backup.

moveOldBackupsToZipFile

public static void moveOldBackupsToZipFile(java.io.File backupRoot,
                                           java.io.File currentBackup)
                                    throws java.io.IOException
Moves all backup sets (that are not already zipped) other than the one containing currentBackup to ZIP files located in backupRoot.

Parameters:
backupRoot -
currentBackup - specified which backup should be omitted from being moved. If null, all backups are moved to ZIP files.
Throws:
java.io.IOException


Copyright © 2004-2011 Borland (a Microfocus Company). All Rights Reserved.