org.opencms.setup.xml
Class A_CmsSetupXmlUpdate

java.lang.Object
  extended by org.opencms.setup.xml.A_CmsSetupXmlUpdate
All Implemented Interfaces:
I_CmsSetupXmlUpdate
Direct Known Subclasses:
A_CmsXmlWorkplace, CmsXmlAddBackupResourceHandler, CmsXmlAddContentNotification, CmsXmlAddDEHelpSearchIndex, CmsXmlAddImageLoader, CmsXmlAddImgGalleryParam, CmsXmlAddImportClasses, CmsXmlAddMimeTypes, CmsXmlAddMultiContextMenu, CmsXmlAddXmlContentWidgets, CmsXmlRemovePageSearchIndexSource1, CmsXmlRemoveSysSearchIndex, CmsXmlReplaceHtmlAreaWidgets, CmsXmlUpdateDefaultProperties, CmsXmlUpdateHistoryContextMenu

public abstract class A_CmsSetupXmlUpdate
extends java.lang.Object
implements I_CmsSetupXmlUpdate

Skeleton for xml update plugins.

Since:
6.1.8
Version:
$Revision: 1.3 $
Author:
Michael Moossen

Constructor Summary
A_CmsSetupXmlUpdate()
           
 
Method Summary
 void execute(CmsSetupBean setupBean)
          Execute the change.
protected  boolean executeUpdate(org.dom4j.Document document, java.lang.String xpath)
          Executes the adding/updating changes on the given document.
 java.lang.String getCodeToChange(CmsSetupBean setupBean)
          Returns the code to be added OR removed in the xml file.
protected  java.lang.String getCommonPath()
          Returns a parent path that is common for all nodes to modify.
protected  java.util.List getXPathsToRemove()
          Returns a list of xpaths for the nodes to remove.
protected  java.util.List getXPathsToUpdate()
          Returns a list of xpaths for the nodes to add/update.
protected  org.dom4j.Document prepareDoc(org.dom4j.Document doc)
          Prepares a new document.
protected  void updateDoc(org.dom4j.Document document, org.dom4j.Document newDoc, java.lang.String xpath)
          Updates the given doc inserting the given node corresponding to the given xpath.
 boolean validate(CmsSetupBean setupBean)
          Validates the need to apply this change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.opencms.setup.xml.I_CmsSetupXmlUpdate
getName, getXmlFilename
 

Constructor Detail

A_CmsSetupXmlUpdate

public A_CmsSetupXmlUpdate()
Method Detail

execute

public void execute(CmsSetupBean setupBean)
             throws java.lang.Exception
Description copied from interface: I_CmsSetupXmlUpdate
Execute the change.

Specified by:
execute in interface I_CmsSetupXmlUpdate
Parameters:
setupBean - the setup bean
Throws:
java.lang.Exception - if something goes wrong
See Also:
I_CmsSetupXmlUpdate.execute(org.opencms.setup.CmsSetupBean)

getCodeToChange

public java.lang.String getCodeToChange(CmsSetupBean setupBean)
                                 throws java.lang.Exception
Description copied from interface: I_CmsSetupXmlUpdate
Returns the code to be added OR removed in the xml file.

Specified by:
getCodeToChange in interface I_CmsSetupXmlUpdate
Parameters:
setupBean - the setup bean
Returns:
the code to be changed
Throws:
java.lang.Exception - if something goes wrong
See Also:
I_CmsSetupXmlUpdate.getCodeToChange(org.opencms.setup.CmsSetupBean)

updateDoc

protected void updateDoc(org.dom4j.Document document,
                         org.dom4j.Document newDoc,
                         java.lang.String xpath)
Updates the given doc inserting the given node corresponding to the given xpath.

Parameters:
document - the original document to update
newDoc - the document to update
xpath - the corresponding xpath

getCommonPath

protected java.lang.String getCommonPath()
Returns a parent path that is common for all nodes to modify.

Returns:
common parent path

validate

public boolean validate(CmsSetupBean setupBean)
                 throws java.lang.Exception
Description copied from interface: I_CmsSetupXmlUpdate
Validates the need to apply this change.

Specified by:
validate in interface I_CmsSetupXmlUpdate
Parameters:
setupBean - the setup bean
Returns:
true if needed
Throws:
java.lang.Exception - if something goes wrong
See Also:
I_CmsSetupXmlUpdate.validate(org.opencms.setup.CmsSetupBean)

executeUpdate

protected boolean executeUpdate(org.dom4j.Document document,
                                java.lang.String xpath)
Executes the adding/updating changes on the given document.

Only needs to be overriden if getXPathsToUpdate() is not empty.

Parameters:
document - the document to apply the changes to
xpath - the xpath to execute the changes for
Returns:
if something was modified

getXPathsToRemove

protected java.util.List getXPathsToRemove()
Returns a list of xpaths for the nodes to remove.

Returns:
a list of strings

getXPathsToUpdate

protected java.util.List getXPathsToUpdate()
Returns a list of xpaths for the nodes to add/update.

Returns:
a list of strings

prepareDoc

protected org.dom4j.Document prepareDoc(org.dom4j.Document doc)
Prepares a new document.

Parameters:
doc - the original document
Returns:
a new document