Class ConfigManager

java.lang.Object
org.ametys.runtime.config.ConfigManager
All Implemented Interfaces:
Model, ModelItemAccessor, ModelItemContainer, Initializable, Contextualizable, Serviceable

public final class ConfigManager extends Object implements Model, Contextualizable, Serviceable, Initializable
This manager handle the parameters of the application that have to be stored by the plugins.
  • Method Details

    • getInstance

      public static ConfigManager getInstance()
      Returns the shared instance of the ConfigManager
      Returns:
      the shared instance of the ConfigManager
    • contextualize

      public void contextualize(Context context)
      Specified by:
      contextualize in interface Contextualizable
    • service

      public void service(ServiceManager manager) throws ServiceException
      Specified by:
      service in interface Serviceable
      Throws:
      ServiceException
    • initialize

      public void initialize()
      Specified by:
      initialize in interface Initializable
    • addPluginConfig

      public void addPluginConfig(String pluginName, Map<String,ConfigParameterInfo> parameters, Map<String,ConfigParameterInfo> parameterCheckers)
      Registers new available parameters. The addFeatureConfig() method allows to select which ones are actually useful.
      Parameters:
      pluginName - the name of the plugin defining the parameters
      parameters - the configuration parameters definition
      parameterCheckers - the parameters checkers definition
    • addFeatureConfig

      public void addFeatureConfig(String featureId, Map<String,ConfigParameterInfo> parameters, Map<String,ConfigParameterInfo> parameterCheckers, Collection<String> parameterReferences)
      Registers a new parameter or references a globalConfig parameter.
      Parameters:
      featureId - the id of the feature defining the parameters
      parameters - the configuration parameters definition
      parameterCheckers - the parameters checkers definition
      parameterReferences - references to already defined parameters
    • parseAndValidate

      public void parseAndValidate()
      Ends the initialization of the config parameters, by checking against the already valued parameters.
      If at least one parameter has no value, the application won't start.
    • save

      public Map<String,List<I18nizableText>> save(Map<String,Object> values, String fileName) throws Exception
      Update the configuration file with the given values
      Values are untyped (all are of type String) and might be null.
      Parameters:
      values - A map (key, value).
      fileName - the configuration file absolute path
      Returns:
      errors The fields in error
      Throws:
      Exception - If an error occurred while saving values
    • getOldDefinitionAndValues

      Retrieves old definition and values if the configuration is not well initialized
      Returns:
      the old definition and values pairs
    • resolveValueForParameterChecker

      public String resolveValueForParameterChecker(String parameterName, Object value, Map<String,DefinitionAndValue> oldDefinitionAndValues)
      Resolve the given value for the parameter check
      Parameters:
      parameterName - name of the parameter to resolve
      value - the value to resolve
      oldDefinitionAndValues - the old definition and values if the configuration is not initialized
      Returns:
      the resolved value as a String
    • evaluateDisableConditions

      public boolean evaluateDisableConditions(DisableConditions disableConditions, Map<String,Object> values)
      Recursively evaluate the DisableConditions against the configuration values
      Parameters:
      disableConditions - the disable conditions to evaluate
      values - the configuration values
      Returns:
      true if the disable conditions are true, false otherwise
    • getModelItem

      Description copied from interface: ModelItemAccessor
      Retrieves the model item at given path
      Specified by:
      getModelItem in interface ModelItemAccessor
      Parameters:
      itemPath - the item path
      Returns:
      the model item.
      Throws:
      UndefinedItemPathException - if there is no item defined at the given path
    • getConfigurationParameters

      Retrieves all configuration parameters
      Returns:
      all configuration parameters
    • getModelItems

      Description copied from interface: ModelItemAccessor
      Retrieves all the model items of this accessor
      Specified by:
      getModelItems in interface ModelItemAccessor
      Returns:
      the model items
    • getView

      public View getView(I18nUtils i18nUtils)
      Retrieves the view of Configuration
      Parameters:
      i18nUtils - the i18nUtils to use categories's sorting
      Returns:
      the configuration's view
    • getParameterChecker

      Gets the parameter checker with its id
      Parameters:
      id - the id of the parameter checker to get
      Returns:
      the associated parameter checker descriptor
    • isComplete

      public boolean isComplete()
      Returns true if the model is initialized and all parameters are valued
      Returns:
      true if the model is initialized and all parameters are valued
    • isEmpty

      public boolean isEmpty()
      Returns true if the config file does not exist
      Returns:
      true if the config file does not exist
    • dispose

      public void dispose()
      Dispose the manager before restarting it
    • getId

      public String getId()
      Description copied from interface: Model
      Retrieves the model id (an id must be unique in the family Model.getFamilyId()
      Specified by:
      getId in interface Model
      Returns:
      model id (for example the content type id for a content)
    • getFamilyId

      public String getFamilyId()
      Description copied from interface: Model
      Retrieves the Family Id (for example the extension point) Each model Id have to be unique in it's family Id
      Specified by:
      getFamilyId in interface Model
      Returns:
      content point (for example "org.ametys.cms.contenttype.ContentTypeExtensionPoint" for a content)