Class ConfigurationManager

java.lang.Object
ch.autumo.commons.generic.PropertiesManager
ch.autumo.commons.configuration.ConfigurationManager

public class ConfigurationManager extends PropertiesManager
Configuration manager.
  • Field Details

    • LOG

      protected static final org.slf4j.Logger LOG
      Logger.
  • Method Details

    • getInstance

      public static ConfigurationManager getInstance()
      Get configuration manager.
      Returns:
      manager
    • initializeManager

      public void initializeManager(Properties config) throws Exception
      Description copied from class: PropertiesManager
      Customized initialization with configuration properties.
      Specified by:
      initializeManager in class PropertiesManager
      Parameters:
      config - configuration properties
      Throws:
      Exception - if manager cannot be initialized
    • getString

      public String getString(String key)
      Get a string value.
      Parameters:
      key - key
      Returns:
      value
    • getString

      public String getString(String key, String defaultVal)
      Get a string value or default value if non-existent.
      Parameters:
      key - key
      defaultVal - default value
      Returns:
      value
    • getStringNoWarn

      public String getStringNoWarn(String key)
      Get a string value; no warning if value is not available.
      Parameters:
      key - key
      Returns:
      value
    • getKeys

      public String[] getKeys(String keyPrefix)
      Get all keys starting with a specific key-prefix.
      Parameters:
      keyPrefix - key prefix, e.g. 'dispatcher_'
      Returns:
      collected values
    • getValues

      public String[] getValues(String keyPrefix)
      Get all values starting with a specific key-prefix.
      Parameters:
      keyPrefix - key prefix, e.g. 'dispatcher_'
      Returns:
      collected values
    • getInt

      public int getInt(String key)
      Get integer value.
      Parameters:
      key - key
      Returns:
      integer value
    • getInt

      public int getInt(String key, int defaultVal)
      Get integer value.
      Parameters:
      key - key
      defaultVal - default value or default value if non-existent.
      Returns:
      integer value
    • getIntNoWarn

      public int getIntNoWarn(String key)
      Get integer value; no warning if value is not available.
      Parameters:
      key - key
      Returns:
      integer value
    • getYesOrNo

      public boolean getYesOrNo(String key)
      Get yes (true) or no (false), if the configuration is messed up false is returned.
      Parameters:
      key - key
      Returns:
      true or false
    • getYesOrNoNoWarn

      public boolean getYesOrNoNoWarn(String key)
      Get yes (true) or no (false), if the configuration is messed up false is returned. No warning if key is missing.
      Parameters:
      key - key
      Returns:
      true or false
    • getDecodedString

      public String getDecodedString(String key, SecureApplication app) throws UtilsException
      Decode encrypted value, if it is encrypted by ifacex standards! See 'encoder.sh'.
      Parameters:
      key - key
      app - ifacex secure application
      Returns:
      encrypted value
      Throws:
      UtilsException - if decoding fails
    • getAppRoles

      public String[] getAppRoles()
      Get web app roles.
      Returns:
      web app roles
    • getSepValuesNoWarn

      public String[] getSepValuesNoWarn(String key)
      Get comma-separated values, e.g. 'a,b,c'. If the configuration is messed up an empty array is returned. No warning if key is missing.
      Parameters:
      key - key
      Returns:
      values
    • getSepValues

      public String[] getSepValues(String key)
      Get comma-separated values, e.g. 'a,b,c'.
      Parameters:
      key - key
      Returns:
      values
    • getMimeTypes

      public List<String> getMimeTypes(String key)
      Get allowed mime types.
      Parameters:
      key - mime type key
      Returns:
      allowed mime types
    • getModuleConfig

      public static Properties getModuleConfig(String configFile) throws Exception
      Get module root configuration.
      Parameters:
      configFile - only the file name, path is concluded by ROOTPATH and cfg-directory
      Returns:
      properties
      Throws:
      Exception - if module configuration cannot be loaded
    • getModuleConfigRelative

      public static Properties getModuleConfigRelative(String relativePath) throws Exception
      Get module root configuration.
      Parameters:
      relativePath - relative path that is concluded with ROOTPATH
      Returns:
      doc root
      Throws:
      Exception - if module configuration cannot be loaded
    • getModuleConfigWithFullPath

      public static Properties getModuleConfigWithFullPath(String configFilePath) throws Exception
      Get module root configuration.
      Parameters:
      configFilePath - the full configuration file path
      Returns:
      properties
      Throws:
      Exception - if module configuration cannot be loaded
    • getXMLModuleConfig

      public static Document getXMLModuleConfig(String xmlConfigFile, String moduleName)
      Get XML module root configuration. No resource paths!
      Parameters:
      xmlConfigFile - only the file name, path is concluded by ROOTPATH and cfg-directory
      moduleName - module name
      Returns:
      XML doc root
    • getXMLModuleConfigRelative

      public static Document getXMLModuleConfigRelative(String xmlRelativePath, String moduleName)
      Get XML module root configuration. No resource paths!
      Parameters:
      xmlRelativePath - relative path that is concluded with ROOTPATH
      moduleName - module name
      Returns:
      XML doc root
    • getXMLModuleConfigWithFullPath

      public static Document getXMLModuleConfigWithFullPath(String xmlConfigFilePath, String moduleName)
      Get XML module root configuration. The given path can be a resource too, but make sure there are no mixed path separators, e.g. "/\"!
      Parameters:
      xmlConfigFilePath - the full configuration file path
      moduleName - module name
      Returns:
      XML doc root
    • writeXMLModuleConfigWithFullPath

      public static void writeXMLModuleConfigWithFullPath(String xmlConfigFilePath, Document xmlDoc)
      Write XML module configuration.
      Parameters:
      xmlConfigFilePath - the full config file path
      xmlDoc - XML doc