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,- Serviceable,- ThreadSafe
 
 public class MigrationExtensionPoint extends AbstractLogEnabled implements ExtensionPoint<MigrationConfiguration>, ThreadSafe, Component, Serviceable Migration Extension Point that will list all migration needed by the current state of the application
- 
- 
Field SummaryFields Modifier and Type Field Description private Map<String,MigrationConfiguration>_configurationsprivate ActionExtensionPoint_initializationEPprivate ObservationManager_observationManagerprivate ActionExtensionPoint_upgradeEPprivate VersionHandlerExtensionPoint_versionHandlerEPstatic StringROLEAvalon Role
 - 
Constructor SummaryConstructors Constructor Description MigrationExtensionPoint()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_applyInitializationActions(Map<Version,List<ActionData>> allInitializationActions)Execute all needed upgradesprotected void_applyUpgradeActions(List<ActionData> allActions)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(Version version, 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 Versionsprivate VersionHandler_getVersionHandler(Configuration versionConfiguration)protected void_notifyEndOfMigration()Notify with anEventthe 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 versionvoidaddExtension(String id, String pluginName, String featureName, Configuration configuration)Add an extension to this point.voiddoMigration()All migrations are parsed and executed one per one in the right orderMigrationConfigurationgetExtension(String id)Returns the named extensionSet<String>getExtensionsIds()Returns a Set containing the ids of all known extensionsbooleanhasExtension(String id)Returns true if the named extension existsvoidinitializeExtensions()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.voidservice(ServiceManager manager)- 
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabledgetLogger, setLogger
 
- 
 
- 
- 
- 
Field Detail- 
_configurationsprivate Map<String,MigrationConfiguration> _configurations 
 - 
_versionHandlerEPprivate VersionHandlerExtensionPoint _versionHandlerEP 
 - 
_upgradeEPprivate ActionExtensionPoint _upgradeEP 
 - 
_initializationEPprivate ActionExtensionPoint _initializationEP 
 - 
_observationManagerprivate ObservationManager _observationManager 
 
- 
 - 
Constructor Detail- 
MigrationExtensionPointpublic MigrationExtensionPoint() 
 
- 
 - 
Method Detail- 
servicepublic void service(ServiceManager manager) throws ServiceException - Specified by:
- servicein interface- Serviceable
- Throws:
- ServiceException
 
 - 
addExtensionpublic void addExtension(String id, String pluginName, String featureName, Configuration configuration) throws ConfigurationException Description copied from interface:ExtensionPointAdd an extension to this point. Each implementation knows the meaning of the given configuration.- Specified by:
- addExtensionin interface- ExtensionPoint<MigrationConfiguration>
- Parameters:
- id- the unique identifier of the extension.
- pluginName- Unique identifier for the plugin hosting the extension
- featureName- Unique feature identifier (unique for a given pluginName)
- configuration- the information about the extension to be added
- Throws:
- ConfigurationException- when a configuration problem occurs
 
 - 
initializeExtensionspublic void initializeExtensions() throws Exception Description copied from interface:ExtensionPointFinalize 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:
- initializeExtensionsin interface- ExtensionPoint<MigrationConfiguration>
- Throws:
- Exception- if something wrong occurs
 
 - 
doMigrationpublic void doMigration() All migrations are parsed and executed one per one in the right order
 - 
_getVersionHandlerprivate VersionHandler _getVersionHandler(Configuration versionConfiguration) throws ConfigurationException - Throws:
- ConfigurationException
 
 - 
_notifyEndOfMigrationprotected void _notifyEndOfMigration() Notify with anEventthe end of the migration.
 - 
_applyInitializationActionsprotected void _applyInitializationActions(Map<Version,List<ActionData>> allInitializationActions) throws MigrationException Execute all needed upgrades- Parameters:
- allInitializationActions- list of needed upgrades
- Throws:
- MigrationException- Something went wrong
 
 - 
_applyUpgradeActionsprotected void _applyUpgradeActions(List<ActionData> allActions) throws MigrationException Execute all needed upgrades- Parameters:
- allActions- list of needed upgrades
- Throws:
- MigrationException- Something went wrong
 
 - 
_upgradeVersionprotected void _upgradeVersion(ActionData action) throws MigrationException When an upgrade (or an initialization) have been done, we write the new version- Parameters:
- action- upgrade/initialization executed
- Throws:
- MigrationException- Something went wrong
 
 - 
_upgradeVersionprotected void _upgradeVersion(Version newVersion) throws MigrationException When an upgrade (or an initialization) have been done, we write the new version- Parameters:
- newVersion- upgrade/initialization executed
- Throws:
- MigrationException- Something went wrong
 
 - 
_getUpgradeActionsprotected 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 versions
- migrationConfiguration- 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
 
 - 
_getInitializationActionsprotected 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 versions
- migrationConfiguration- 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
 
 - 
_getHigherCurrentUpgradeVersionNumberprotected String _getHigherCurrentUpgradeVersionNumber(Version version, MigrationConfiguration migrationConfiguration) throws MigrationException Returns the most recent version to apply (after an initialization)- Parameters:
- version- Version used
- migrationConfiguration- Configuration of the extension
- Returns:
- the id of the most current available version, or "0" if none available
- Throws:
- MigrationException- Something went wrong
 
 - 
_removeDuplicatedActionsprotected 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
 
 - 
_checkFromUpgradesprotected void _checkFromUpgrades(List<ActionData> actions, List<Pair<String,String>> fromTo) throws MigrationException Tests 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 actions
- fromTo- list of actions overriding multiple actions
- Throws:
- MigrationException- there is an overriding version without a "simple" version with the same id
 
 - 
hasExtensionpublic boolean hasExtension(String id) Description copied from interface:ExtensionPointReturns true if the named extension exists- Specified by:
- hasExtensionin interface- ExtensionPoint<MigrationConfiguration>
- Parameters:
- id- the unique id of the extension
- Returns:
- true if the named extension exists
 
 - 
getExtensionpublic MigrationConfiguration getExtension(String id) Description copied from interface:ExtensionPointReturns the named extension- Specified by:
- getExtensionin interface- ExtensionPoint<MigrationConfiguration>
- Parameters:
- id- the unique id of the extension
- Returns:
- the named extension
 
 - 
getExtensionsIdspublic Set<String> getExtensionsIds() Description copied from interface:ExtensionPointReturns a Set containing the ids of all known extensions- Specified by:
- getExtensionsIdsin interface- ExtensionPoint<MigrationConfiguration>
- Returns:
- a Set containing the ids of all known extensions
 
 
- 
 
-