Class BackupPropertiesDelegate

java.lang.Object
edu.ucsb.nceas.metacat.properties.BackupPropertiesDelegate

public class BackupPropertiesDelegate extends Object
BackupPropertiesDelegate handles functionality related to backing up the main properties for metacat configuration. Since it is a singleton class that has a private constructor, a shared instance of BackupPropertiesDelegate can be obtained by a call to the static method BackupPropertiesDelegate.getInstance(). However, PropertyService should be the only class instantiating BackupPropertiesDelegate and calling its methods. When PropertyService receives Authentication-related method calls, they are simply "passed through" and delegated directly to the corresponding methods in BackupPropertiesDelegate. This pattern was used to improve encapsulation, separation of concerns, readability, and reasoning about how the codebase works.
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    (for dev use only) Bypasses the properties configuration utility by using the backup properties to overwrite the main properties.
    protected boolean
    Determine if the system is able to bypass configuration.
    protected Path
    Get the path to the directory where the backup properties are stored, and as a side effect, update the properties file to save this path as "application.backupDir"
    protected static BackupPropertiesDelegate
    Get a shared singleton BackupPropertiesDelegate instance by calling BackupPropertiesDelegate.getInstance().
    protected edu.ucsb.nceas.utilities.SortedProperties
    Get the main backup properties file.
    protected void
    Writes out configurable properties to a backup file outside the metacat install directory, so they are not lost if metacat installation is overwritten during an upgrade.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getInstance

      protected static BackupPropertiesDelegate getInstance() throws edu.ucsb.nceas.utilities.GeneralPropertyException
      Get a shared singleton BackupPropertiesDelegate instance by calling BackupPropertiesDelegate.getInstance(). If the instance does not already exist, it will be created on the first call. Subsequent calls will return this same instance.
      Returns:
      a shared singleton BackupPropertiesDelegate instance
      Throws:
      edu.ucsb.nceas.utilities.GeneralPropertyException - if there are problems discovering or saving the backup properties file path, or if there is an IOException loading the backup properties from the file.
    • getMainBackupProperties

      protected edu.ucsb.nceas.utilities.SortedProperties getMainBackupProperties()
      Get the main backup properties file. These are configurable properties that are stored outside the metacat install directories so the user does not need to re-enter all the configuration information every time they do an upgrade.
      Returns:
      a SortedProperties object with the backup properties
    • persistMainBackupProperties

      protected void persistMainBackupProperties() throws edu.ucsb.nceas.utilities.GeneralPropertyException
      Writes out configurable properties to a backup file outside the metacat install directory, so they are not lost if metacat installation is overwritten during an upgrade. These backup properties are used by the admin page to populate defaults when the configuration is edited. (They are also used to overwrite the main properties if bypassConfiguration() is called)
      Throws:
      edu.ucsb.nceas.utilities.GeneralPropertyException
    • canBypass

      protected boolean canBypass() throws edu.ucsb.nceas.utilities.PropertyNotFoundException
      Determine if the system is able to bypass configuration. If so, the system will look for backup configuration files at startup time and use those to configure metacat. The bypass options should only be set by developers. Production code should never bypass configuration.
      Returns:
      true if dev.runConfiguration is set to true in metacat.properties, and we have not already checked for bypass; false otherwise.
      Throws:
      edu.ucsb.nceas.utilities.PropertyNotFoundException - if the "dev.runConfiguration" property cannot be found
    • bypassConfiguration

      protected void bypassConfiguration()
      (for dev use only) Bypasses the properties configuration utility by using the backup properties to overwrite the main properties.
    • getBackupDirPath

      protected Path getBackupDirPath() throws edu.ucsb.nceas.utilities.GeneralPropertyException
      Get the path to the directory where the backup properties are stored, and as a side effect, update the properties file to save this path as "application.backupDir"
      Returns:
      java.nio.Path representation of the directory path
      Throws:
      edu.ucsb.nceas.utilities.GeneralPropertyException - if there are issues retrieving or persisting the value