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

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

public class Utils
extends Object


Field Summary
static SimpleDateFormat DIRECTORY_NAME_DATE_FORMAT
           
static SimpleDateFormat DISPLAY_DATE_FORMAT
           
static int FORCE_QUIETMODE_TIMEOUT_MINUTES
           
static String THINBACKUP_TMP_DIR
           
 
Constructor Summary
Utils()
           
 
Method Summary
static String convertToDirectoryNameDateFormat(String displayFormattedDate)
           
static String expandEnvironmentVariables(String path)
           
static List<String> getBackupsAsDates(File directory)
           
static List<File> getBackupSetZipFiles(File parentDir)
           
static List<File> getBackupTypeDirectories(File parentDir, ThinBackupPeriodicWork.BackupType backupType)
           
static Date getDateFromBackupDirectory(File directory)
           
static Date getDateFromBackupDirectoryName(String directoryName)
           
static File getFormattedDirectory(File parent, ThinBackupPeriodicWork.BackupType backupType, Date date)
           
static File getReferencedFullBackup(File diffBackup)
           
static List<File> getReferencingDiffBackups(File fullBackup)
           
static List<BackupSet> getValidBackupSets(File directory)
           
static List<BackupSet> getValidBackupSetsFromDirectories(File directory)
           
static List<BackupSet> getValidBackupSetsFromZips(File directory)
           
protected static String internalExpandEnvironmentVariables(String path, Map<String,String> environmentVariables)
          For unit testing purposes only.
static void moveOldBackupsToZipFile(File backupRoot, 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.
static void waitUntilIdleAndSwitchToQuietMode(int timeout, TimeUnit unit)
          Waits until all executors are idle and switch jenkins to quiet mode.
 
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 final SimpleDateFormat DISPLAY_DATE_FORMAT

DIRECTORY_NAME_DATE_FORMAT

public static final SimpleDateFormat DIRECTORY_NAME_DATE_FORMAT

THINBACKUP_TMP_DIR

public static final String THINBACKUP_TMP_DIR

FORCE_QUIETMODE_TIMEOUT_MINUTES

public static final int FORCE_QUIETMODE_TIMEOUT_MINUTES
See Also:
Constant Field Values
Constructor Detail

Utils

public Utils()
Method Detail

waitUntilIdle

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


waitUntilIdleAndSwitchToQuietMode

public static void waitUntilIdleAndSwitchToQuietMode(int timeout,
                                                     TimeUnit unit)
                                              throws IOException
Waits until all executors are idle and switch jenkins to quiet mode. If it takes to long that all executors are idle because in the mean time other jobs are executed the timeout ensure that the quiet mode is forced.

Parameters:
timeout - specifies when a quiet mode is forced. 0 = no timeout.
unit - specifies the time unit for the value of timeout.
Throws:
IOException

getDateFromBackupDirectory

public static Date getDateFromBackupDirectory(File directory)
Parameters:
directory -
Returns:
the date component of a directory name formatted in the thinBackup standard

getDateFromBackupDirectoryName

public static Date getDateFromBackupDirectoryName(String directoryName)
Parameters:
directoryName -
Returns:
the date component of a directory name formatted in the thinBackup standard

convertToDirectoryNameDateFormat

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

getFormattedDirectory

public static File getFormattedDirectory(File parent,
                                         ThinBackupPeriodicWork.BackupType backupType,
                                         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 List<File> getBackupTypeDirectories(File parentDir,
                                                  ThinBackupPeriodicWork.BackupType backupType)
Parameters:
parentDir -
backupType -
Returns:
an unordered list of backup directories of the given backup type.

getBackupSetZipFiles

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

getReferencedFullBackup

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

getReferencingDiffBackups

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

getBackupsAsDates

public static List<String> getBackupsAsDates(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 List<BackupSet> getValidBackupSetsFromDirectories(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 List<BackupSet> getValidBackupSetsFromZips(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 List<BackupSet> getValidBackupSets(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(File backupRoot,
                                           File currentBackup)
                                    throws 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:
IOException

expandEnvironmentVariables

public static String expandEnvironmentVariables(String path)
                                         throws EnvironmentVariableNotDefinedException
Throws:
EnvironmentVariableNotDefinedException

internalExpandEnvironmentVariables

protected static String internalExpandEnvironmentVariables(String path,
                                                           Map<String,String> environmentVariables)
                                                    throws EnvironmentVariableNotDefinedException
For unit testing purposes only. Use @link {expandEnvironmentVariables}.

Throws:
EnvironmentVariableNotDefinedException


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