Package org.ametys.core.migration
Class MigrationExtensionPoint
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.migration.MigrationExtensionPoint
- All Implemented Interfaces:
LogEnabled
,ExtensionPoint<MigrationConfiguration>
,Component
,Contextualizable
,Serviceable
,ThreadSafe
public class MigrationExtensionPoint
extends AbstractLogEnabled
implements ExtensionPoint<MigrationConfiguration>, ThreadSafe, Component, Serviceable, Contextualizable
Migration Extension Point that will list all migration needed by the current state of the application
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
_applyInitializationActions
(Map<Version, List<ActionData>> allInitializationActions, Logger logger) Execute all needed upgradesprotected boolean
_applyUpgradeActions
(List<ActionData> allActions, Logger logger) Execute all needed upgradesprotected void
_checkFromUpgrades
(List<ActionData> actions, List<Pair<String, String>> fromTo) Tests that in the list of fromTo, that each "fromTo" is linked to an action with the same id and without "from"protected String
_getHigherCurrentUpgradeVersionNumber
(MigrationConfiguration migrationConfiguration) Returns the most recent version to apply (after an initialization)protected Map<Version,
List<ActionData>> _getInitializationActions
(List<Version> currentVersions, MigrationConfiguration migrationConfiguration) Analyze the configuration to get a list of initializations needed based on the current Versionsprotected List<ActionData>
_getUpgradeActions
(List<Version> currentVersions, MigrationConfiguration migrationConfiguration) Analyze the configuration to get a list of upgrades needed based on the current Versionsprotected void
Notify with anEvent
the end of the migration.protected List<ActionData>
_removeDuplicatedActions
(List<ActionData> actions) Parse the list of upgrade to remove the group-migrationprotected void
_upgradeVersion
(ActionData action) When an upgrade (or an initialization) have been done, we write the new versionprotected void
_upgradeVersion
(Version newVersion) When an upgrade (or an initialization) have been done, we write the new versionvoid
addExtension
(String id, String pluginName, String featureName, Configuration configuration) Add an extension to this point.void
contextualize
(Context context) boolean
All migrations are parsed and executed one per one in the right orderGet the expected version for a component.getExtension
(String id) Returns the named extensionReturns a Set containing the ids of all known extensionsboolean
hasExtension
(String id) Returns true if the named extension existsvoid
Finalize the initialization of the extensions.
This method is called after alladdExtension()
calls.
This is the last step before the actual startup of the application.void
service
(ServiceManager smanager) Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon Role
-
-
Constructor Details
-
MigrationExtensionPoint
public MigrationExtensionPoint()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
addExtension
public void addExtension(String id, String pluginName, String featureName, Configuration configuration) throws ConfigurationException Description copied from interface:ExtensionPoint
Add an extension to this point. Each implementation knows the meaning of the given configuration.- Specified by:
addExtension
in interfaceExtensionPoint<MigrationConfiguration>
- Parameters:
id
- the unique identifier of the extension.pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)configuration
- the information about the extension to be added- Throws:
ConfigurationException
- when a configuration problem occurs
-
initializeExtensions
Description copied from interface:ExtensionPoint
Finalize the initialization of the extensions.
This method is called after alladdExtension()
calls.
This is the last step before the actual startup of the application.- Specified by:
initializeExtensions
in interfaceExtensionPoint<MigrationConfiguration>
- Throws:
Exception
- if something wrong occurs
-
doMigration
All migrations are parsed and executed one per one in the right order- Returns:
- true if the migration requires a server restart ; false otherwise
-
_notifyEndOfMigration
Notify with anEvent
the end of the migration. -
_applyInitializationActions
protected boolean _applyInitializationActions(Map<Version, List<ActionData>> allInitializationActions, Logger logger) throws MigrationExceptionExecute all needed upgrades- Parameters:
allInitializationActions
- list of needed upgradeslogger
- The avalon wrapped logger- Returns:
- true if an action requires a restart
- Throws:
MigrationException
- Something went wrong
-
_applyUpgradeActions
protected boolean _applyUpgradeActions(List<ActionData> allActions, Logger logger) throws MigrationException Execute all needed upgrades- Parameters:
allActions
- list of needed upgradeslogger
- The avalon wrapped logger- Returns:
- true if an action requires a restart
- Throws:
MigrationException
- Something went wrong
-
_upgradeVersion
When an upgrade (or an initialization) have been done, we write the new version- Parameters:
action
- upgrade/initialization executed- Throws:
MigrationException
- Something went wrong
-
_upgradeVersion
When an upgrade (or an initialization) have been done, we write the new version- Parameters:
newVersion
- upgrade/initialization executed- Throws:
MigrationException
- Something went wrong
-
_getUpgradeActions
protected List<ActionData> _getUpgradeActions(List<Version> currentVersions, MigrationConfiguration migrationConfiguration) throws MigrationException Analyze the configuration to get a list of upgrades needed based on the current Versions- Parameters:
currentVersions
- list of current versionsmigrationConfiguration
- configuration for this extension- Returns:
- a list of actions to work on, or null if an error occured
- Throws:
MigrationException
- impossible to parse the configuration
-
_getInitializationActions
protected Map<Version,List<ActionData>> _getInitializationActions(List<Version> currentVersions, MigrationConfiguration migrationConfiguration) throws MigrationException Analyze the configuration to get a list of initializations needed based on the current Versions- Parameters:
currentVersions
- list of current versionsmigrationConfiguration
- configuration for this extension- Returns:
- a list of actions to work on, or null if an error occured
- Throws:
MigrationException
- impossible to parse the configuration
-
_getHigherCurrentUpgradeVersionNumber
protected String _getHigherCurrentUpgradeVersionNumber(MigrationConfiguration migrationConfiguration) throws ConfigurationException Returns the most recent version to apply (after an initialization)- Parameters:
migrationConfiguration
- Configuration of the extension- Returns:
- the id of the most current available version, or "0" if none available
- Throws:
ConfigurationException
- Sompthing wrong while reading the configuration
-
_removeDuplicatedActions
protected List<ActionData> _removeDuplicatedActions(List<ActionData> actions) throws MigrationException Parse the list of upgrade to remove the group-migration- Parameters:
actions
- list of upgrades to clean- Returns:
- a list with only needed upgrades.
- Throws:
MigrationException
- list of actions incoherent
-
_checkFromUpgrades
protected void _checkFromUpgrades(List<ActionData> actions, List<Pair<String, String>> fromTo) throws MigrationExceptionTests that in the list of fromTo, that each "fromTo" is linked to an action with the same id and without "from"- Parameters:
actions
- list of actionsfromTo
- list of actions overriding multiple actions- Throws:
MigrationException
- there is an overriding version without a "simple" version with the same id
-
hasExtension
Description copied from interface:ExtensionPoint
Returns true if the named extension exists- Specified by:
hasExtension
in interfaceExtensionPoint<MigrationConfiguration>
- Parameters:
id
- the unique id of the extension- Returns:
- true if the named extension exists
-
getExtension
Description copied from interface:ExtensionPoint
Returns the named extension- Specified by:
getExtension
in interfaceExtensionPoint<MigrationConfiguration>
- Parameters:
id
- the unique id of the extension- Returns:
- the named extension
-
getExtensionsIds
Description copied from interface:ExtensionPoint
Returns a Set containing the ids of all known extensions- Specified by:
getExtensionsIds
in interfaceExtensionPoint<MigrationConfiguration>
- Returns:
- a Set containing the ids of all known extensions
-
getExpectedVersionForComponent
Get the expected version for a component. This is the latest upgrade number declared- Parameters:
id
- the id of the component- Returns:
- the expected version number for each version in this component
- Throws:
MigrationException
- Component not found in the calculated map of expected versions
-