Class BackupBase
java.lang.Object
jmri.beans.PropertyChangeSupport
jmri.jmrit.operations.setup.backup.BackupBase
- All Implemented Interfaces:
PropertyChangeFirer,PropertyChangeProvider,InstanceManagerAutoDefault
- Direct Known Subclasses:
AutoBackup,DefaultBackup
public abstract class BackupBase
extends PropertyChangeSupport
implements InstanceManagerAutoDefault
Base class for backing up and restoring Operations working files. Derived
classes implement specifics for working with different backup set stores,
such as Automatic and Default backups.
-
Field Summary
FieldsFields inherited from class jmri.beans.PropertyChangeSupport
propertyChangeSupport -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBackupBase(String rootName) Creates a BackupBase instance and initializes the Operations root directory to its normal value. -
Method Summary
Modifier and TypeMethodDescriptionvoidbackupFilesToDirectory(File backupDirectory) Creates backup files for the directory specified.voidbackupFilesToSetName(String setName) Backs up Operations files to the named backup set under the backup root directory.booleancheckIfBackupSetExists(String setName) Check to see if the given backup set already exists in the backup store.voidcopyBackupSet(File sourceDir, File destDir) Copies a complete set of Operations files from one directory to another directory.voidReset Operations by deleting XML files, leaves directories and backup files in place.File[]String[]String[]Returns a sorted list of the Backup Sets under the backup root.intgetSourceFileCount(File sourceDir) Checks to see how many of the Operations files are present in the source directory.voidReloads the demo Operations files that are distributed with JMRI.voidrestoreFilesFromDirectory(File directory) Restores a Backup Set from the given directory.voidrestoreFilesFromSetName(String setName) Restores a Backup Set with the given name from the backup store.Searches for an unused directory name, based on the default base name, under the given directory.Methods inherited from class jmri.beans.PropertyChangeSupport
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Field Details
-
COPY_FILES_CHANGED_PROPERTY
- See Also:
-
testException
-
_operationsRoot
-
_backupRoot
-
-
Constructor Details
-
BackupBase
Creates a BackupBase instance and initializes the Operations root directory to its normal value.- Parameters:
rootName- Directory name to use.
-
-
Method Details
-
getOperationsRoot
-
getBackupRoot
-
getBackupSetFileNames
-
backupFilesToSetName
Backs up Operations files to the named backup set under the backup root directory.- Parameters:
setName- The name of the new backup set- Throws:
IOException- Due to trouble writing filesIllegalArgumentException- if string null or empty
-
backupFilesToDirectory
Creates backup files for the directory specified. Assumes that backupDirectory is a fully qualified path where the individual files will be created. This will backup files to any directory which does not have to be part of the JMRI hierarchy.- Parameters:
backupDirectory- The directory to use for the backup.- Throws:
IOException- Due to trouble writing files
-
getBackupSetList
Returns a sorted list of the Backup Sets under the backup root.- Returns:
- A sorted backup list.
-
getBackupSetDirs
-
getBackupSets
-
checkIfBackupSetExists
Check to see if the given backup set already exists in the backup store.- Parameters:
setName- The directory name to check.- Returns:
- true if it exists
-
restoreFilesFromSetName
Restores a Backup Set with the given name from the backup store.- Parameters:
setName- The directory name.- Throws:
IOException- Due to trouble loading files
-
restoreFilesFromDirectory
Restores a Backup Set from the given directory.- Parameters:
directory- The File directory.- Throws:
IOException- Due to trouble loading files
-
copyBackupSet
Copies a complete set of Operations files from one directory to another directory. Usually used to copy to or from a backup location. Creates the destination directory if it does not exist. Only copies files that are included in the list of Operations files.- Parameters:
sourceDir- From DirectorydestDir- To Directory- Throws:
IOException- Due to trouble reading or writing
-
getSourceFileCount
Checks to see how many of the Operations files are present in the source directory.- Parameters:
sourceDir- The Directory to check.- Returns:
- number of files
-
loadDemoFiles
Reloads the demo Operations files that are distributed with JMRI.- Throws:
IOException- Due to trouble loading files
-
suggestBackupSetName
Searches for an unused directory name, based on the default base name, under the given directory. A name suffix as appended to the base name and can range from 00 to 99.- Returns:
- A backup set name that is not already in use.
-
deleteOperationsFiles
Reset Operations by deleting XML files, leaves directories and backup files in place.
-