Package org.ametys.runtime.config
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 Summary
Modifier and TypeMethodDescriptionvoid
addFeatureConfig
(String featureId, Map<String, ConfigParameterInfo> parameters, Map<String, ConfigParameterInfo> parameterCheckers, Collection<String> parameterReferences) Registers a new parameter or references a globalConfig parameter.void
addPluginConfig
(String pluginName, Map<String, ConfigParameterInfo> parameters, Map<String, ConfigParameterInfo> parameterCheckers) Registers new available parameters.void
contextualize
(Context context) void
dispose()
Dispose the manager before restarting itboolean
evaluateDisableConditions
(ElementDefinition definition, Config config) Evaluate theDisableConditions
of the given configuration parameter against the configuration valuesRetrieves all configuration parametersRetrieves the Family Id (for example the extension point) Each model Id have to be unique in it's family IdgetId()
Retrieves the model id (an id must be unique in the familyModel.getFamilyId()
static ConfigManager
Returns the shared instance of the ConfigManagergetModelItem
(String itemPath) Retrieves the model item at given pathRetrieves all the model items of this accessorRetrieves old values if the configuration is not well initializedGets the parameter checker with its idRetrieves the view of Configurationvoid
boolean
Returns true if the model is initialized and all parameters are valuedboolean
isEmpty()
Returns true if the config file does not existvoid
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.Resolve the given value for the parameter checkUpdate the configuration file with the given values
Values are untyped (all are of type String) and might be null.void
service
(ServiceManager manager) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.runtime.model.ModelItemAccessor
getChild, hasModelItem
-
Method Details
-
getInstance
Returns the shared instance of the ConfigManager- Returns:
- the shared instance of the ConfigManager
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
-
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 parametersparameters
- the configuration parameters definitionparameterCheckers
- 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 parametersparameters
- the configuration parameters definitionparameterCheckers
- the parameters checkers definitionparameterReferences
- references to already defined parameters
-
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 ExceptionUpdate 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
-
getOldValues
Retrieves old values if the configuration is not well initialized- Returns:
- the old values
-
resolveValueForParameterChecker
public String resolveValueForParameterChecker(String parameterName, Object value, Map<String, Object> oldValues) Resolve the given value for the parameter check- Parameters:
parameterName
- name of the parameter to resolvevalue
- the value to resolveoldValues
- the old values if the configuration is not initialized- Returns:
- the resolved value as a String
-
evaluateDisableConditions
Evaluate theDisableConditions
of the given configuration parameter against the configuration values- Parameters:
definition
- the configuration parameterconfig
- theConfig
instance- Returns:
true
if the parameter is disabled,false
otherwise
-
getModelItem
Description copied from interface:ModelItemAccessor
Retrieves the model item at given path- Specified by:
getModelItem
in interfaceModelItemAccessor
- 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 interfaceModelItemAccessor
- Returns:
- the model items
-
getView
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
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
Returns true if the config file does not exist- Returns:
- true if the config file does not exist
-
dispose
Dispose the manager before restarting it -
getId
Description copied from interface:Model
Retrieves the model id (an id must be unique in the familyModel.getFamilyId()
-
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 interfaceModel
- Returns:
- content point (for example "org.ametys.cms.contenttype.ContentTypeExtensionPoint" for a content)
-