Class AbstractConfiguration

java.lang.Object
io.goobi.viewer.controller.AbstractConfiguration
Direct Known Subclasses:
Configuration

public abstract class AbstractConfiguration extends Object
Abstract configuration with base getters.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.commons.configuration2.builder.ReloadingFileBasedConfigurationBuilder<org.apache.commons.configuration2.XMLConfiguration>
     
    protected org.apache.commons.configuration2.builder.ReloadingFileBasedConfigurationBuilder<org.apache.commons.configuration2.XMLConfiguration>
     
    protected boolean
     
    protected long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>>
    Gathers all configuration nodes from both the local and global config, local first.
    protected org.apache.commons.configuration2.XMLConfiguration
     
    protected org.apache.commons.configuration2.XMLConfiguration
     
     
    protected boolean
    getLocalBoolean(String inPath, boolean inDefault)
    getLocalBoolean.
    protected org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>
    getLocalConfigurationAt.
    protected List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>>
    getLocalConfigurationsAt.
    protected static List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>>
    getLocalConfigurationsAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> altConfig, String inPath)
     
    protected float
    getLocalFloat.
    protected float
    getLocalFloat(String inPath, float inDefault)
    getLocalFloat.
    protected int
    getLocalInt(String inPath, int inDefault)
    getLocalInt.
    protected List<String>
    getLocalList.
    protected List<String>
    getLocalList(String inPath, List<String> defaultList)
    getLocalList.
    protected static List<String>
    getLocalList(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> altConfig, String inPath, List<String> defaultList)
    getLocalList.
    protected List<Object>
    getLocalNodeList.
    protected String
    getLocalString.
    protected String
    getLocalString(String inPath, String inDefault)
    getLocalString.
    void
    overrideValue(String property, Object value)
    Overrides values in the config file (for unit test purposes).

    Methods inherited from class java.lang.Object

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

    • builder

      protected org.apache.commons.configuration2.builder.ReloadingFileBasedConfigurationBuilder<org.apache.commons.configuration2.XMLConfiguration> builder
    • builderLocal

      protected org.apache.commons.configuration2.builder.ReloadingFileBasedConfigurationBuilder<org.apache.commons.configuration2.XMLConfiguration> builderLocal
    • localConfigDisabled

      protected boolean localConfigDisabled
    • localConfigDisabledTimestamp

      protected long localConfigDisabledTimestamp
  • Constructor Details

    • AbstractConfiguration

      public AbstractConfiguration()
  • Method Details

    • getConfig

      protected org.apache.commons.configuration2.XMLConfiguration getConfig()
      Returns:
      XMLConfiguration that is synced with the current state of the config file
    • getConfigLocal

      protected org.apache.commons.configuration2.XMLConfiguration getConfigLocal()
      Returns:
      XMLConfiguration that is synced with the current state of the config file
      Throws:
      org.apache.commons.configuration2.ex.ConfigurationException
    • getDefaultConfigFile

      public File getDefaultConfigFile()
    • getLocalInt

      protected int getLocalInt(String inPath, int inDefault)
      getLocalInt.
      Parameters:
      inPath - XML configuration path to look up
      inDefault - fallback value if path is not configured
      Returns:
      a int.
    • getLocalFloat

      protected float getLocalFloat(String inPath)
      getLocalFloat.
      Parameters:
      inPath - XML configuration path to look up
      Returns:
      a float.
    • getLocalFloat

      protected float getLocalFloat(String inPath, float inDefault)
      getLocalFloat.
      Parameters:
      inPath - XML configuration path to look up
      inDefault - fallback value if path is not configured
      Returns:
      a float.
    • getLocalString

      protected String getLocalString(String inPath, String inDefault)
      getLocalString.
      Parameters:
      inPath - XML configuration path to look up
      inDefault - fallback value if path is not configured
      Returns:
      the configured string value at the given path, preferring local config over global config, or the default if not configured
    • getLocalString

      protected String getLocalString(String inPath)
      getLocalString.
      Parameters:
      inPath - XML configuration path to look up
      Returns:
      the configured string value at the given path, preferring local config over global config, or null if not configured
    • getLocalNodeList

      protected List<Object> getLocalNodeList(String inPath)
      getLocalNodeList.
      Parameters:
      inPath - XML configuration path to look up
      Returns:
      a list of configuration node objects at the given path, preferring local config over global config
    • getLocalList

      protected static List<String> getLocalList(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> altConfig, String inPath, List<String> defaultList)
      getLocalList.
      Parameters:
      config - Preferred configuration
      altConfig - Alternative configuration
      inPath - XML path
      defaultList - List of default values to return if none found in config
      Returns:
      a list of string values from the preferred config, falling back to the alternative config and then the default list
    • getLocalList

      protected List<String> getLocalList(String inPath, List<String> defaultList)
      getLocalList.
      Parameters:
      inPath - XML configuration path to look up
      defaultList - fallback list if path is not configured
      Returns:
      configured list; defaultList if none found
    • getLocalList

      protected List<String> getLocalList(String inPath)
      getLocalList.
      Parameters:
      inPath - XML configuration path to look up
      Returns:
      configured list; empty list if none found
    • getLocalBoolean

      protected boolean getLocalBoolean(String inPath, boolean inDefault)
      getLocalBoolean.
      Parameters:
      inPath - XML configuration path to look up
      inDefault - fallback value if path is not configured
      Returns:
      the boolean value at the given path, or inDefault if the path is not configured
    • getLocalConfigurationsAt

      protected static List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> getLocalConfigurationsAt(org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> config, org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> altConfig, String inPath)
      Parameters:
      config - the primary configuration to query
      altConfig - the fallback configuration used when config yields no results
      inPath - the XPath path to look up in the configuration
      Returns:
      List<HierarchicalConfiguration<ImmutableNode>>
    • getLocalConfigurationsAt

      protected List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> getLocalConfigurationsAt(String inPath)
      getLocalConfigurationsAt.
      Parameters:
      inPath - XML configuration path to look up
      Returns:
      a list of hierarchical sub-configurations at the given path, preferring local config over global config
    • getAllConfigurationsAt

      protected List<org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode>> getAllConfigurationsAt(String inPath)
      Gathers all configuration nodes from both the local and global config, local first.
      Parameters:
      inPath - the configuration path
      Returns:
      A list of all found configurations ath 'inPath'
    • getLocalConfigurationAt

      protected org.apache.commons.configuration2.HierarchicalConfiguration<org.apache.commons.configuration2.tree.ImmutableNode> getLocalConfigurationAt(String inPath)
      getLocalConfigurationAt.
      Parameters:
      inPath - XML configuration path to look up
      Returns:
      the first matching hierarchical configuration node for the given path, or null if not found
    • overrideValue

      public void overrideValue(String property, Object value)
      Overrides values in the config file (for unit test purposes).
      Parameters:
      property - Property path (e.g. "accessConditions.fullAccessForLocalhost")
      value - New value to set