org.exoplatform.commons.upgrade
Class UpgradeProductPlugin

java.lang.Object
  extended by org.exoplatform.container.component.BaseComponentPlugin
      extended by org.exoplatform.commons.upgrade.UpgradeProductPlugin
All Implemented Interfaces:
Comparable<UpgradeProductPlugin>, org.exoplatform.container.component.ComponentPlugin

public abstract class UpgradeProductPlugin
extends org.exoplatform.container.component.BaseComponentPlugin
implements Comparable<UpgradeProductPlugin>


Field Summary
protected  String oldProductGroupId
           
protected  String productGroupId
          The plugin's product maven group identifier, by example: org.exoplatform.portal for gatein.
 
Fields inherited from class org.exoplatform.container.component.BaseComponentPlugin
desc, name
 
Constructor Summary
UpgradeProductPlugin(org.exoplatform.container.xml.InitParams initParams)
           
 
Method Summary
 void addNodeVersion(javax.jcr.Node nodeToAddVersion, String versionLabel)
          Add node's version with a label.
 int compareTo(UpgradeProductPlugin o)
          
 boolean equals(Object obj)
          
 String getOldProductGroupId()
          Gets old version what needs to upgrade
 int getPluginExecutionOrder()
           
 String getProductGroupId()
           
 int hashCode()
          
 boolean isEnabled()
          Determines if the plugin is enabled, this method will be called when adding the plugin to the upgradePlugins list.
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 Product Version stored in the JCR and the one declared in ProductInfo are different
abstract  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.
 
Methods inherited from class org.exoplatform.container.component.BaseComponentPlugin
getDescription, getName, setDescription, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

productGroupId

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


oldProductGroupId

protected String oldProductGroupId
Constructor Detail

UpgradeProductPlugin

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

getProductGroupId

public String getProductGroupId()

getOldProductGroupId

public String getOldProductGroupId()
Gets old version what needs to upgrade

Returns:

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

addNodeVersion

public void addNodeVersion(javax.jcr.Node nodeToAddVersion,
                           String versionLabel)
                    throws javax.jcr.nodetype.NoSuchNodeTypeException,
                           javax.jcr.version.VersionException,
                           javax.jcr.nodetype.ConstraintViolationException,
                           javax.jcr.lock.LockException,
                           javax.jcr.AccessDeniedException,
                           javax.jcr.ItemExistsException,
                           javax.jcr.InvalidItemStateException,
                           javax.jcr.ReferentialIntegrityException,
                           javax.jcr.RepositoryException
Add node's version with a label. The node's session have to still open, and this method don't handle the node's session closure.

Parameters:
nodeToAddVersion - the node that will be versioned
versionLabel - the label to apply to the new created version
Throws:
javax.jcr.nodetype.NoSuchNodeTypeException
javax.jcr.version.VersionException
javax.jcr.nodetype.ConstraintViolationException
javax.jcr.lock.LockException
javax.jcr.AccessDeniedException
javax.jcr.ItemExistsException
javax.jcr.InvalidItemStateException
javax.jcr.ReferentialIntegrityException
javax.jcr.RepositoryException

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 Product Version stored in the JCR and the one declared in ProductInfo are different

Parameters:
oldVersion - the old version that is stored in the JCR
newVersion - the new version read from ProductInfo Service

shouldProceedToUpgrade

public abstract 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 true: 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

compareTo

public int compareTo(UpgradeProductPlugin o)

Specified by:
compareTo in interface Comparable<UpgradeProductPlugin>

getPluginExecutionOrder

public int getPluginExecutionOrder()


Copyright © 2003-2013 eXo Platform SAS. All Rights Reserved.