Class ScriptVersionHandler
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.migration.handler.impl.ScriptVersionHandler
- All Implemented Interfaces:
VersionHandler
,LogEnabled
,Serviceable
Version Handler which use a script as version storage
-
Field Summary
Modifier and TypeFieldDescriptionprotected ScriptHandler
Script Handlerprotected SourceResolver
Source resolver -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription_getAdditionalParameters
(String componentId, Configuration versionConfiguration) Generate a Map of objects that will be passed to the scriptprotected String
_getScript
(String componentId, Configuration versionConfiguration) Get the content of the script from the actionDatavoid
addVersion
(Version newVersion) Adds a new version for a componentgetConfiguration
(String componentId, Configuration versionConfiguration) Create a specific object containing usefull data for the handler/storagegetCurrentVersions
(String componentId, VersionConfiguration configuration) Get the list of all curent versions for this component id based on the configurationvoid
service
(ServiceManager manager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
_sourceResolver
Source resolver -
_scriptHandler
Script Handler
-
-
Constructor Details
-
ScriptVersionHandler
public ScriptVersionHandler()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getCurrentVersions
public List<Version> getCurrentVersions(String componentId, VersionConfiguration configuration) throws MigrationException, NotMigrableInSafeModeException Description copied from interface:VersionHandler
Get the list of all curent versions for this component id based on the configuration- Specified by:
getCurrentVersions
in interfaceVersionHandler
- Parameters:
componentId
- id to checkconfiguration
- configuration of this version- Returns:
- a non-null list of
Version
. Can be an empty list if no version can be computed (e.g. configuration not filled). Beware, returning an empty list will not initialize the component ; to initialize a component, you need to return a list with a Version with null id. - Throws:
MigrationException
- Something went wrongNotMigrableInSafeModeException
- Impossible to determine the version (e.g. Safe Mode without access to the conf)
-
addVersion
Description copied from interface:VersionHandler
Adds a new version for a component- Specified by:
addVersion
in interfaceVersionHandler
- Parameters:
newVersion
- Version to set- Throws:
MigrationException
- Something went wrong
-
_getScript
protected String _getScript(String componentId, Configuration versionConfiguration) throws MigrationException Get the content of the script from the actionData- Parameters:
componentId
- id of the componentversionConfiguration
- configuration of this version- Returns:
- The script as a String (either from the config or from a file to parse)
- Throws:
MigrationException
- Something went wrong
-
getConfiguration
public VersionConfiguration getConfiguration(String componentId, Configuration versionConfiguration) throws ConfigurationException, NotMigrableInSafeModeException Description copied from interface:VersionHandler
Create a specific object containing usefull data for the handler/storage- Specified by:
getConfiguration
in interfaceVersionHandler
- Parameters:
componentId
- id of the componentversionConfiguration
- configuration from the plugin.xml- Returns:
- the confuguration object
- Throws:
ConfigurationException
- something wrong in the configurationNotMigrableInSafeModeException
- Impossible to determine the version (e.g. Safe Mode without access to the conf)
-
_getAdditionalParameters
protected Map<String,Object> _getAdditionalParameters(String componentId, Configuration versionConfiguration) Generate a Map of objects that will be passed to the script- Parameters:
componentId
- id of the componentversionConfiguration
- configuration from the plugin.xml- Returns:
- a Map of objects that will be passed to the script (componentId, versionConfiguration, logger)
-