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 Details

  • Constructor Details

    • BackupBase

      protected BackupBase(String rootName)
      Creates a BackupBase instance and initializes the Operations root directory to its normal value.
      Parameters:
      rootName - Directory name to use.
  • Method Details

    • getOperationsRoot

    • getBackupRoot

      public File 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 files
      IllegalArgumentException - if string null or empty
    • backupFilesToDirectory

      public void backupFilesToDirectory(File backupDirectory) throws IOException
      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

      public File[] getBackupSetDirs()
    • getBackupSets

    • checkIfBackupSetExists

      public boolean checkIfBackupSetExists(String setName)
      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

      public void restoreFilesFromSetName(String setName) throws IOException
      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

      public void restoreFilesFromDirectory(File directory) throws IOException
      Restores a Backup Set from the given directory.
      Parameters:
      directory - The File directory.
      Throws:
      IOException - Due to trouble loading files
    • copyBackupSet

      public void copyBackupSet(File sourceDir, File destDir) throws IOException
      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 Directory
      destDir - To Directory
      Throws:
      IOException - Due to trouble reading or writing
    • getSourceFileCount

      public int getSourceFileCount(File sourceDir)
      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

      public void loadDemoFiles() throws IOException
      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

      public void deleteOperationsFiles()
      Reset Operations by deleting XML files, leaves directories and backup files in place.