edu.ucsb.nceas.metacat.properties

## Class ConfigurableProperties

- java.lang.Object
- - edu.ucsb.nceas.metacat.shared.BaseService
  - - edu.ucsb.nceas.metacat.properties.ConfigurableProperties

- All Implemented Interfaces:
    PropertiesInterface

      public class ConfigurableProperties
      extends BaseService
      implements PropertiesInterface

  A suite of utility classes for the metadata configuration utility

- - ### Field Summary

    - ### Fields inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `_serviceName`

    - ### Fields inherited from interface edu.ucsb.nceas.metacat.properties.PropertiesInterface

      `BYPASSED, CONFIGURED, UNCONFIGURED`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ConfigurableProperties()` private constructor since this is a singleton

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addProperty(java.lang.String propertyName, java.lang.String value)` Utility method to add a property value both in memory and to the properties file
    `boolean` | `arePropertiesConfigured()` Reports whether properties are fully configured.
    `void` | `bypassConfiguration()` Reports whether the metacat configuration utility should be run.
    `boolean` | `checkAndSetProperty(javax.servlet.http.HttpServletRequest request, java.lang.String propertyName)` Take input from the user in an HTTP request about an property to be changed and update the metacat property file with that new value if it has changed from the value that was originally set.
    `boolean` | `doBypass()` Determine if the system is configured to bypass configuration.
    `void` | `doRefresh()`
    `edu.ucsb.nceas.utilities.SortedProperties` | `getAuthBackupProperties()` Get the auth backup properties file.
    `edu.ucsb.nceas.utilities.PropertiesMetaData` | `getAuthMetaData()` Get the auth properties metadata.
    `edu.ucsb.nceas.utilities.SortedProperties` | `getMainBackupProperties()` Get the main backup properties file.
    `edu.ucsb.nceas.utilities.PropertiesMetaData` | `getMainMetaData()` Get the main properties metadata.
    `java.util.Map<java.lang.String,java.lang.String>` | `getPropertiesByGroup(java.lang.String groupName)` Get a Map of all properties that start with the groupName prefix.
    `java.lang.String` | `getProperty(java.lang.String propertyName)` Utility method to get a property value from the properties file
    `java.util.Vector<java.lang.String>` | `getPropertyNames()` Get a set of all property names.
    `java.util.Vector<java.lang.String>` | `getPropertyNamesByGroup(java.lang.String groupName)` Get a Set of all property names that start with the groupName prefix.
    `void` | `persistAuthBackupProperties(javax.servlet.ServletContext servletContext)` Writes out backup configurable properties to a file.
    `void` | `persistMainBackupProperties()` Writes out backup configurable properties to a file.
    `void` | `persistProperties()` Save the properties to a properties file.
    `boolean` | `refreshable()`
    `void` | `setProperty(java.lang.String propertyName, java.lang.String newValue)` Utility method to set a property value both in memory and to the properties file
    `void` | `setPropertyNoPersist(java.lang.String propertyName, java.lang.String newValue)` Utility method to set a property value in memory.
    `void` | `stop()`

    - ### Methods inherited from class edu.ucsb.nceas.metacat.shared.BaseService

      `refresh`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ConfigurableProperties

          protected ConfigurableProperties()
                                    throws ServiceException

      private constructor since this is a singleton
      Parameters:
        `servletContext` - the context we will use to get relative paths
      Throws:
        `ServiceException`

  - ### Method Detail

    - #### refreshable

          public boolean refreshable()

      Specified by:
        `refreshable` in class `BaseService`

    - #### doRefresh

          public void doRefresh()
                         throws ServiceException

      Specified by:
        `doRefresh` in class `BaseService`
      Throws:
        `ServiceException`

    - #### stop

          public void stop()
                    throws ServiceException

      Specified by:
        `stop` in class `BaseService`
      Throws:
        `ServiceException`

    - #### getProperty

          public java.lang.String getProperty(java.lang.String propertyName)
                                       throws edu.ucsb.nceas.utilities.PropertyNotFoundException

      Utility method to get a property value from the properties file
      Specified by:
        `getProperty` in interface `PropertiesInterface`
      Parameters:
        `propertyName` - the name of the property requested
      Returns:
        the String value for the property
      Throws:
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

    - #### getPropertyNames

          public java.util.Vector<java.lang.String> getPropertyNames()

      Get a set of all property names.
      Specified by:
        `getPropertyNames` in interface `PropertiesInterface`
      Returns:
        Set of property names

    - #### getPropertyNamesByGroup

          public java.util.Vector<java.lang.String> getPropertyNamesByGroup(java.lang.String groupName)

      Get a Set of all property names that start with the groupName prefix.
      Specified by:
        `getPropertyNamesByGroup` in interface `PropertiesInterface`
      Parameters:
        `groupName` - the prefix of the keys to search for.
      Returns:
        enumeration of property names

    - #### getPropertiesByGroup

          public java.util.Map<java.lang.String,java.lang.String> getPropertiesByGroup(java.lang.String groupName)
                                                                                throws edu.ucsb.nceas.utilities.PropertyNotFoundException

      Get a Map of all properties that start with the groupName prefix.
      Specified by:
        `getPropertiesByGroup` in interface `PropertiesInterface`
      Parameters:
        `groupName` - the prefix of the keys to search for.
      Returns:
        Map of property names
      Throws:
        `edu.ucsb.nceas.utilities.PropertyNotFoundException`

    - #### addProperty

          public void addProperty(java.lang.String propertyName,
                                  java.lang.String value)
                           throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Utility method to add a property value both in memory and to the properties file
      Specified by:
        `addProperty` in interface `PropertiesInterface`
      Parameters:
        `propertyName` - the name of the property to add
        `newValue` - the value for the property
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### setProperty

          public void setProperty(java.lang.String propertyName,
                                  java.lang.String newValue)
                           throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Utility method to set a property value both in memory and to the properties file
      Specified by:
        `setProperty` in interface `PropertiesInterface`
      Parameters:
        `propertyName` - the name of the property requested
        `newValue` - the new value for the property
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### setPropertyNoPersist

          public void setPropertyNoPersist(java.lang.String propertyName,
                                           java.lang.String newValue)
                                    throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Utility method to set a property value in memory. This will NOT cause the property to be written to disk. Use this method to set multiple properties in a row without causing excessive I/O. You must call persistProperties() once you're done setting properties to have them written to disk.
      Specified by:
        `setPropertyNoPersist` in interface `PropertiesInterface`
      Parameters:
        `propertyName` - the name of the property requested
        `newValue` - the new value for the property
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### persistProperties

          public void persistProperties()
                                 throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Save the properties to a properties file. Note, the order and comments will be preserved.
      Specified by:
        `persistProperties` in interface `PropertiesInterface`
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### getMainBackupProperties

          public 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.
      Specified by:
        `getMainBackupProperties` in interface `PropertiesInterface`
      Returns:
        a SortedProperties object with the backup properties

    - #### getAuthBackupProperties

          public edu.ucsb.nceas.utilities.SortedProperties getAuthBackupProperties()

      Get the auth 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.
      Specified by:
        `getAuthBackupProperties` in interface `PropertiesInterface`
      Returns:
        a SortedProperties object with the backup properties

    - #### getMainMetaData

          public edu.ucsb.nceas.utilities.PropertiesMetaData getMainMetaData()

      Get the main properties metadata. This is retrieved from an xml file that describes the attributes of configurable properties.
      Specified by:
        `getMainMetaData` in interface `PropertiesInterface`
      Returns:
        a PropertiesMetaData object with the main properties metadata

    - #### getAuthMetaData

          public edu.ucsb.nceas.utilities.PropertiesMetaData getAuthMetaData()

      Get the auth properties metadata. This is retrieved from an xml file that describes the attributes of configurable properties.
      Specified by:
        `getAuthMetaData` in interface `PropertiesInterface`
      Returns:
        a PropertiesMetaData object with the organization properties metadata

    - #### persistMainBackupProperties

          public void persistMainBackupProperties()
                                           throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Writes out backup configurable properties to a file.
      Specified by:
        `persistMainBackupProperties` in interface `PropertiesInterface`
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### persistAuthBackupProperties

          public void persistAuthBackupProperties(javax.servlet.ServletContext servletContext)
                                           throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Writes out backup configurable properties to a file.
      Specified by:
        `persistAuthBackupProperties` in interface `PropertiesInterface`
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### arePropertiesConfigured

          public boolean arePropertiesConfigured()
                                          throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Reports whether properties are fully configured.
      Specified by:
        `arePropertiesConfigured` in interface `PropertiesInterface`
      Returns:
        a boolean that is true if properties are not unconfigured and false otherwise
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### doBypass

          public boolean doBypass()
                           throws edu.ucsb.nceas.utilities.PropertyNotFoundException

      Determine if the system is configured 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 confguration.
      Specified by:
        `doBypass` in interface `PropertiesInterface`
      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`

    - #### bypassConfiguration

          public void bypassConfiguration()
                                   throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Reports whether the metacat configuration utility should be run. Returns false if -- dev.runConfiguration=false and -- backup properties file exists Note that dev.runConfiguration should only be set to false when reinstalling the same version of the application in developement.
      Specified by:
        `bypassConfiguration` in interface `PropertiesInterface`
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

    - #### checkAndSetProperty

          public boolean checkAndSetProperty(javax.servlet.http.HttpServletRequest request,
                                             java.lang.String propertyName)
                                      throws edu.ucsb.nceas.utilities.GeneralPropertyException

      Take input from the user in an HTTP request about an property to be changed and update the metacat property file with that new value if it has changed from the value that was originally set.
      Specified by:
        `checkAndSetProperty` in interface `PropertiesInterface`
      Parameters:
        `request` - that was generated by the user
        `response` - to send output back to the user
        `propertyName` - the name of the property to be checked and set
      Throws:
        `edu.ucsb.nceas.utilities.GeneralPropertyException`

Copyright © 2020 Regents of the University of California. All Rights Reserved.