Class BackupBase

    • Constructor Detail

      • BackupBase

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

      • backupFilesToSetName

        public void backupFilesToSetName​(java.lang.String setName)
                                  throws java.io.IOException,
                                         java.lang.IllegalArgumentException
        Backs up Operations files to the named backup set under the backup root directory.
        Parameters:
        setName - The name of the new backup set
        Throws:
        java.io.IOException - Due to trouble writing files
        java.lang.IllegalArgumentException - if string null or empty
      • backupFilesToDirectory

        public void backupFilesToDirectory​(java.io.File backupDirectory)
                                    throws java.io.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:
        java.io.IOException - Due to trouble writing files
      • getBackupSetList

        public java.lang.String[] getBackupSetList()
        Returns a sorted list of the Backup Sets under the backup root.
        Returns:
        A sorted backup list.
      • checkIfBackupSetExists

        public boolean checkIfBackupSetExists​(java.lang.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​(java.lang.String setName)
                                     throws java.io.IOException
        Restores a Backup Set with the given name from the backup store.
        Parameters:
        setName - The directory name.
        Throws:
        java.io.IOException - Due to trouble loading files
      • restoreFilesFromDirectory

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

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

        public int getSourceFileCount​(java.io.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 java.io.IOException
        Reloads the demo Operations files that are distributed with JMRI.
        Throws:
        java.io.IOException - Due to trouble loading files
      • suggestBackupSetName

        public java.lang.String 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.