Class ConfigPropertiesCascadeBase

java.lang.Object
edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase
Direct Known Subclasses:
GrouperClientConfig, GrouperHibernateConfigClient

public abstract class ConfigPropertiesCascadeBase extends Object
Base class for a cascaded config. Extend this class to have a config based on a certain file.
  • Constructor Details

    • ConfigPropertiesCascadeBase

      public ConfigPropertiesCascadeBase()
  • Method Details

    • assignInitted

      public static void assignInitted()
      assign that things are initted, so database config is ok to use and errors should be thrown
    • internalProperties

      protected Properties internalProperties()
      help subclasses manipulate properties. note, this is only for subclasses...
      Returns:
      properties
    • retrieveConfig

      protected static <T extends ConfigPropertiesCascadeBase> T retrieveConfig(Class<T> configClass)
      retrieve a config from the config file or from cache
      Type Parameters:
      T - class which is the return type of config class
      Parameters:
      configClass -
      Returns:
      the config object never null
    • getClassInSiblingJar

      protected Class<?> getClassInSiblingJar()
      if its ok to put the config file in the same directory as a jar, then return a class in the jar here
      Returns:
      the class or null if not available
    • getSecondsToCheckConfigKey

      protected abstract String getSecondsToCheckConfigKey()
      config key of the time in seconds to check config. -1 means dont check again
      Returns:
      config key
    • clearCache

      public static void clearCache()
    • clearCacheThisOnly

      public static void clearCacheThisOnly()
    • clearCachedCalculatedValues

      public abstract void clearCachedCalculatedValues()
      if there are things that are calculated, clear them out (e.g. if an override is set)
    • propertiesThreadLocalOverrideMap

      public Map<String,String> propertiesThreadLocalOverrideMap()
      override map for properties in thread local to be used in a web server or the like, based on property class this is static since the properties class can get reloaded, but these shouldnt
      Returns:
      the override map
    • propertyNames

      public Set<String> propertyNames()
      Returns:
      the set of names
    • propertiesOverrideMap

      public Map<String,String> propertiesOverrideMap()
      override map for properties for testing
      Returns:
      the override map
    • properties

      public Properties properties()
      get the properties object for this config file
      Returns:
      the properties
    • propertiesHelper

      protected Properties propertiesHelper(boolean setValues)
      get the properties object for this config file
      Parameters:
      setValues - if we should set the values for the properties. if not, the values might not be correct, but this will be more performant depending on how many EL properties there are
      Returns:
      the properties
    • substituteLocalReferences

      protected void substituteLocalReferences(Properties result)
      you can refer to other properties with $$propertyName$$
      Parameters:
      result -
    • propertyValueStringRequired

      public String propertyValueStringRequired(String key)
      get the property value as a string
      Parameters:
      key -
      Returns:
      the property value
    • propertyValueString

      public String propertyValueString(String key, String defaultValue)
      get the property value as a string
      Parameters:
      key -
      defaultValue -
      Returns:
      the property value
    • propertyValueString

      public String propertyValueString(String key)
      get the property value as a string or null if not there
      Parameters:
      key -
      Returns:
      the property value
    • propertyValueString

      protected edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase.PropertyValueResult propertyValueString(String key, String defaultValue, boolean required)
      get the property value as a string
      Parameters:
      key -
      defaultValue -
      required - true if required, if doesnt exist, throw exception
      Returns:
      the property value
    • propertyValueStringHelper

      protected edu.internet2.middleware.grouperClient.config.ConfigPropertiesCascadeBase.PropertyValueResult propertyValueStringHelper(String key, String defaultValue, boolean required)
      get the property value as a string
      Parameters:
      key -
      defaultValue -
      required - true if required, if doesnt exist, throw exception
      Returns:
      the property value
    • substituteCommonVars

      protected static String substituteCommonVars(String string)
      substitute common vars like $space$ and $newline$
      Parameters:
      string -
      Returns:
      the string
    • getTimeToCheckConfigSeconds

      protected Integer getTimeToCheckConfigSeconds()
      when we build the config object, get the time to check config in seconds
      Returns:
      the time to check config foe changes (in seconds)
    • isInDatabase

      public static boolean isInDatabase()
      is in database
      Returns:
      if in database
    • retrieveFromConfigFiles

      protected ConfigPropertiesCascadeBase retrieveFromConfigFiles()
      get the config object from config files
      Returns:
      the config object
    • retrieveFromConfigFiles

      public ConfigPropertiesCascadeBase retrieveFromConfigFiles(boolean includeBaseConfig)
      get the config object from config files. You should call the method that gets these from cache, probably shouldnt call this method except for config in UI reasons
      Parameters:
      includeBaseConfig - true if we include base config
      Returns:
      the config object
    • internalRetrieveConfigFiles

      public List<ConfigPropertiesCascadeBase.ConfigFile> internalRetrieveConfigFiles()
      get the underlying properties for the config ui
      Returns:
      the config files
    • logInfo

      protected static void logInfo(String logMessage, Throwable t)
      make sure LOG is there, after things are initialized
      Parameters:
      logMessage -
      t -
    • logError

      protected static void logError(String logMessage, Throwable t)
      make sure LOG is there, after things are initialized
      Parameters:
      logMessage -
      t -
    • retrieveFromConfigFileOrCache

      protected ConfigPropertiesCascadeBase retrieveFromConfigFileOrCache()
      see if there is one in cache, if so, use it, if not, get from config files
      Returns:
      the config from file or cache
    • needToCheckIfFilesNeedReloading

      protected boolean needToCheckIfFilesNeedReloading()
      Returns:
      true if need to reload this config, false if not
    • filesNeedReloadingBasedOnContents

      protected boolean filesNeedReloadingBasedOnContents()
      Returns:
      true if need to reload this config, false if not
    • getMainConfigFileName

      public String getMainConfigFileName()
      Returns:
      e.g. grouper.properties
    • getMainConfigClasspath

      protected abstract String getMainConfigClasspath()
      get the main config classpath, e.g. grouper.properties
      Returns:
      the classpath of the main config file
    • getHierarchyConfigKey

      protected abstract String getHierarchyConfigKey()
      config key of the hierarchy value
      Returns:
      the classpath of the main config file
    • getMainExampleConfigClasspath

      protected abstract String getMainExampleConfigClasspath()
      get the example config classpath, e.g. grouper.example.properties
      Returns:
      the classpath of the example config file
    • propertyValueBoolean

      public boolean propertyValueBoolean(String key, boolean defaultValue)
      get a boolean and validate from grouper.client.properties
      Parameters:
      key -
      defaultValue -
      Returns:
      the string
    • containsKey

      public boolean containsKey(String key)
      if the key is there, whether or not the value is blank
      Parameters:
      key -
      Returns:
      true or false
    • propertyValueBoolean

      public Boolean propertyValueBoolean(String key)
      get a boolean and validate from grouper.client.properties or null if not there
      Parameters:
      key -
      Returns:
      the boolean or null
    • propertyValueBoolean

      protected Boolean propertyValueBoolean(String key, Boolean defaultValue, boolean required)
      get a boolean and validate from the config file
      Parameters:
      key -
      defaultValue -
      required -
      Returns:
      the string
    • propertyValueInt

      protected Integer propertyValueInt(String key, Integer defaultValue, boolean required)
      get an int and validate from the config file
      Parameters:
      key -
      defaultValue -
      required -
      Returns:
      the string
    • propertyValueBooleanRequired

      public boolean propertyValueBooleanRequired(String key)
      get a boolean and validate from grouper.client.properties
      Parameters:
      key -
      Returns:
      the string
    • propertyValueIntRequired

      public int propertyValueIntRequired(String key)
      get a boolean and validate from grouper.client.properties
      Parameters:
      key -
      Returns:
      the string
    • propertyValueInt

      public int propertyValueInt(String key, int defaultValue)
      get a boolean and validate from grouper.client.properties
      Parameters:
      key -
      defaultValue -
      Returns:
      the string
    • propertyValueInt

      public Integer propertyValueInt(String key)
      get a boolean and validate from grouper.client.properties
      Parameters:
      key -
      Returns:
      the int or null if there
    • propertiesFromResourceName

      protected static Properties propertiesFromResourceName(String resourceName, boolean exceptionIfNotExist)
      read properties from a resource, dont modify the properties returned since they are cached
      Parameters:
      resourceName -
      exceptionIfNotExist -
      Returns:
      the properties or null if not exist
    • propertiesFromResourceName

      protected static Properties propertiesFromResourceName(String resourceName, boolean exceptionIfNotExist, Class<?> classInSiblingJar)
      read properties from a resource, dont modify the properties returned since they are cached
      Parameters:
      resourceName -
      exceptionIfNotExist -
      classInSiblingJar - if also looking for config next to a jar
      Returns:
      the properties or null if not exist
    • assertPropertyValueRequired

      public boolean assertPropertyValueRequired(String key)
      make sure a value exists in properties
      Parameters:
      key -
      Returns:
      true if ok, false if not
    • assertPropertyValueBoolean

      public boolean assertPropertyValueBoolean(String key, boolean required)
      make sure a value is boolean in properties
      Parameters:
      key -
      required -
      Returns:
      true if ok, false if not
    • assertPropertyValueClass

      public boolean assertPropertyValueClass(String key, Class<?> classType, boolean required)
      make sure a property is a class of a certain type
      Parameters:
      key -
      classType -
      required -
      Returns:
      true if ok
    • propertiesMap

      public Map<String,String> propertiesMap(Pattern pattern)
      find all keys/values with a certain pattern in a properties file. return the keys. if none, will return the empty set, not null set
      Parameters:
      pattern -
      Returns:
      the keys. if none, will return the empty set, not null set
    • propertyConfigIds

      public Set<String> propertyConfigIds(Pattern pattern)
      find all config ids that match a pattern and return the configId (first match)
      Parameters:
      pattern - e.g. "^grouperOsgiPlugin\\.([^.]+)\\.jarName$
      Returns:
      the config ids. if none, will return the empty set, not null set
    • substituteLocalReferencesOneField

      protected String substituteLocalReferencesOneField(Object thePropertiesOrConfigPropertiesCascadeBase, String value)
      Parameters:
      thePropertiesOrConfigPropertiesCascadeBase - to get data from
      value -
      Returns:
      the subsituted string
    • substituteLocalReferencesOneSubstitution

      protected String substituteLocalReferencesOneSubstitution(Object thePropertiesOrConfigPropertiesCascadeBase, String value)
      Parameters:
      thePropertiesOrConfigPropertiesCascadeBase - to get data from. either Properties or ConfigPropertiesCascadeBAse
      value -
      Returns:
      the subsituted string
    • hasExpressionLanguage

      public boolean hasExpressionLanguage(String propertyName)
    • rawExpressionLanguage

      public String rawExpressionLanguage(String propertyName)
    • configExistsNotInBaseOrDatabase

      public boolean configExistsNotInBaseOrDatabase(String propertyName)
      see if property name exists not in base or database (config file or db or override)
      Parameters:
      propertyName -
      Returns:
      if configured other than base