Class UpgradeProductPlugin

  • All Implemented Interfaces:
    org.exoplatform.container.component.ComponentPlugin

    public abstract class UpgradeProductPlugin
    extends org.exoplatform.container.component.BaseComponentPlugin
    • Field Detail

      • UPGRADE_PLUGIN_EXECUTE_ONCE_PARAMETER

        public static final String UPGRADE_PLUGIN_EXECUTE_ONCE_PARAMETER
        See Also:
        Constant Field Values
      • productGroupId

        protected String productGroupId
        The plugin's product maven group identifier, by example: org.exoplatform.portal for gatein.
      • oldProductGroupId

        protected String oldProductGroupId
      • targetVersion

        protected String targetVersion
        The target version of this upgrade Plugin.
      • asyncUpgradeExecution

        protected boolean asyncUpgradeExecution
        True if the upgrade execution should be processed asynchronously else, it will be executed synchronously
      • executeOnlyOnce

        protected boolean executeOnlyOnce
        Determines whether the plugin should be executed once or even version upgrade. If true, the method shouldProceedToUpgrade will not be called to test if the Upgrade Plugin should be executed or not.
    • Constructor Detail

      • UpgradeProductPlugin

        public UpgradeProductPlugin​(org.exoplatform.commons.api.settings.SettingService settingService,
                                    org.exoplatform.container.xml.InitParams initParams)
      • UpgradeProductPlugin

        public UpgradeProductPlugin​(org.exoplatform.container.xml.InitParams initParams)
    • Method Detail

      • getProductGroupId

        public String getProductGroupId()
      • beforeUpgrade

        public void beforeUpgrade()
        Execute some operations synchronously after the execution of processUpgrade method synchronously or asynchronously
      • afterUpgrade

        public void afterUpgrade()
        Execute some operations synchronously after the execution of processUpgrade method synchronously or asynchronously
      • isAsyncUpgradeExecution

        public boolean isAsyncUpgradeExecution()
      • isExecuteOnlyOnce

        public boolean isExecuteOnlyOnce()
      • getTargetVersion

        public String getTargetVersion()
      • isEnabled

        public boolean isEnabled()
        Determines if the plugin is enabled, this method will be called when adding the plugin to the upgradePlugins list. See UpgradeProductService.addUpgradePlugin(UpgradeProductPlugin)
        Returns:
        true: if the plugin is enabled: should be added to the upgradePlugins list false: if the plugin is disabled: should not be added to the upgradePlugins list
      • processUpgrade

        public abstract void processUpgrade​(String oldVersion,
                                            String newVersion)
        Proceed to the transparent upgrade, this method will be called if the Product version has changed, which means, it will be called once the stored Product Version and the one declared in ProductInfo are different
        Parameters:
        oldVersion - the old version that is stored in internal datasource
        newVersion - the new version read from ProductInfo Service
      • shouldProceedToUpgrade

        public boolean shouldProceedToUpgrade​(String newVersion,
                                              String previousVersion)
        This method is called when a new version has been detected to decide whether proceed to upgrade or not. It should take care that some versions could be skipped while upgrading, i.e: the upgrade could happen when the product is switched from version 1.0 to 1.3.
        Parameters:
        previousVersion - The previous version of plugin's product
        newVersion - The previous version of plugin's product
        Returns:
        true: if the plugin should be executed when switching product from previousVersion to newVersion false: if the upgrade isn't necessary
      • shouldProceedToUpgrade

        public boolean shouldProceedToUpgrade​(String newVersion,
                                              String previousGroupVersion,
                                              UpgradePluginExecutionContext previousUpgradePluginExecution)
        This method is called when a new version has been detected to decide whether proceed to upgrade or not. It will test on previous version of artifact, previous version of group and newer version to decide whether to upgrade or not. This method will call shouldProceedToUpgrade(previousVersion, newVersion) to include optional specific check(s).
        Parameters:
        newVersion - The current version of running server
        previousGroupVersion - The previous version of plugin's product group (social, portal...) This parameter will be equals to '0' if first time it runs.
        previousUpgradePluginExecution - The previous version and execution count of plugin (retrieved from last run) This parameter will be null if first time it runs.
        Returns:
        true: if the plugin should be executed when switching product from previousVersion to newVersion false: if the upgrade isn't necessary
      • equals

        public final boolean equals​(Object obj)
        Overrides:
        equals in class Object
      • hashCode

        public final int hashCode()
        Overrides:
        hashCode in class Object
      • getPluginExecutionOrder

        public int getPluginExecutionOrder()
      • storeValueForPlugin

        public void storeValueForPlugin​(String paramName,
                                        String paramValue)