Package org.opencms.module
Class CmsModuleXmlHandler
- java.lang.Object
-
- org.opencms.module.CmsModuleXmlHandler
-
public class CmsModuleXmlHandler extends java.lang.Object
Adds the XML handler rules for import and export of a single module.- Since:
- 6.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CmsModuleXmlHandler.XmlWriteMode
Enum used to distinguish whether we want to generate the XML for a module export's manifest or the XML for writing back opencms-modules.xml.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
A_NAME
The "name" attribute.static java.lang.String
A_VERSION
The "version" attribute.static java.lang.String
N_AUTHOREMAIL
The node name for the authoremail node.static java.lang.String
N_AUTHORNAME
The node name for the authorname node.static java.lang.String
N_AUTOINCREMENT
The node name for the auto increment mode.static java.lang.String
N_CHECKPOINT_TIME
The node name for the checkpoint time.static java.lang.String
N_CLASS
The node name for the class node.static java.lang.String
N_DATECREATED
The node name for the datecreated node.static java.lang.String
N_DATEINSTALLED
The node name for the date installed node.static java.lang.String
N_DEPENDENCIES
The node name for the dependencies node.static java.lang.String
N_DEPENDENCY
The node name for the dependency node.static java.lang.String
N_DESCRIPTION
The node name for the description node.static java.lang.String
N_EXCLUDERESOURCES
The node name for the resources node.static java.lang.String
N_EXPORT_MODE
The node name for the import site.static java.lang.String
N_GROUP
The node name for the group node.static java.lang.String
N_IMPORT_SCRIPT
Node for the import script.static java.lang.String
N_MODULE
The node name for a module.static java.lang.String
N_NAME
The node name for the name node.static java.lang.String
N_NICENAME
The node name for the nicename node.static java.lang.String
N_PARAM
The "param" node name for generic parameters.static java.lang.String
N_PARAMETERS
The node name for the parameters node.static java.lang.String
N_RESOURCES
The node name for the resources node.static java.lang.String
N_SITE
The node name for the module site.static java.lang.String
N_USERINSTALLED
The node name for the user installed node.static java.lang.String
N_VERSION
The node name for the version node.
-
Constructor Summary
Constructors Constructor Description CmsModuleXmlHandler()
Public constructor, will be called by digester during import.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDependency(java.lang.String name, java.lang.String version)
Adds a module dependency to the current module.void
addExcludeResource(java.lang.String resource)
Adds a resource to the list module resources.void
addExplorerTypeSetting(CmsExplorerTypeSettings settings)
Adds an explorer type setting object to the list of type settings.void
addExportPoint(java.lang.String uri, java.lang.String destination)
Adds an export point to the module configuration.void
addParameter(java.lang.String key, java.lang.String value)
Adds a module parameter to the module configuration.void
addResource(java.lang.String resource)
Adds a resource to the list module resources.void
addResourceType(I_CmsResourceType resourceType)
Adds a new resource type to the internal list of loaded resource types.static void
addXmlDigesterRules(org.apache.commons.digester3.Digester digester)
Adds the XML digester rules for a single module.void
createdModule(java.lang.String name, java.lang.String niceName, java.lang.String group, java.lang.String actionClass, java.lang.String importScript, java.lang.String importSite, java.lang.String site, java.lang.String exportModeName, java.lang.String description, java.lang.String version, java.lang.String authorName, java.lang.String authorEmail, java.lang.String dateCreated, java.lang.String userInstalled, java.lang.String dateInstalled)
Created a new module from the provided parameters.static org.dom4j.Element
generateXml(CmsModule module, CmsModuleXmlHandler.XmlWriteMode writeMode)
Generates a detached XML element for a module.CmsModule
getModule()
Returns the generated module.static java.lang.String
makeValidJavaClassName(java.lang.String className)
Generates a (hopefully) valid Java class name from an invalid class name.void
setAutoIncrement(boolean autoincrement)
Sets the auto-increment mode.void
setCheckpointTime(long time)
Sets the checkpoint time.void
setOldModule()
Sets the current imported module to an old (5.0.x) style module.
-
-
-
Field Detail
-
A_NAME
public static final java.lang.String A_NAME
The "name" attribute.- See Also:
- Constant Field Values
-
A_VERSION
public static final java.lang.String A_VERSION
The "version" attribute.- See Also:
- Constant Field Values
-
N_AUTHOREMAIL
public static final java.lang.String N_AUTHOREMAIL
The node name for the authoremail node.- See Also:
- Constant Field Values
-
N_AUTHORNAME
public static final java.lang.String N_AUTHORNAME
The node name for the authorname node.- See Also:
- Constant Field Values
-
N_AUTOINCREMENT
public static final java.lang.String N_AUTOINCREMENT
The node name for the auto increment mode.- See Also:
- Constant Field Values
-
N_CHECKPOINT_TIME
public static final java.lang.String N_CHECKPOINT_TIME
The node name for the checkpoint time.- See Also:
- Constant Field Values
-
N_CLASS
public static final java.lang.String N_CLASS
The node name for the class node.- See Also:
- Constant Field Values
-
N_DATECREATED
public static final java.lang.String N_DATECREATED
The node name for the datecreated node.- See Also:
- Constant Field Values
-
N_DATEINSTALLED
public static final java.lang.String N_DATEINSTALLED
The node name for the date installed node.- See Also:
- Constant Field Values
-
N_DEPENDENCIES
public static final java.lang.String N_DEPENDENCIES
The node name for the dependencies node.- See Also:
- Constant Field Values
-
N_DEPENDENCY
public static final java.lang.String N_DEPENDENCY
The node name for the dependency node.- See Also:
- Constant Field Values
-
N_DESCRIPTION
public static final java.lang.String N_DESCRIPTION
The node name for the description node.- See Also:
- Constant Field Values
-
N_EXCLUDERESOURCES
public static final java.lang.String N_EXCLUDERESOURCES
The node name for the resources node.- See Also:
- Constant Field Values
-
N_EXPORT_MODE
public static final java.lang.String N_EXPORT_MODE
The node name for the import site.- See Also:
- Constant Field Values
-
N_GROUP
public static final java.lang.String N_GROUP
The node name for the group node.- See Also:
- Constant Field Values
-
N_IMPORT_SCRIPT
public static final java.lang.String N_IMPORT_SCRIPT
Node for the import script.- See Also:
- Constant Field Values
-
N_MODULE
public static final java.lang.String N_MODULE
The node name for a module.- See Also:
- Constant Field Values
-
N_NAME
public static final java.lang.String N_NAME
The node name for the name node.- See Also:
- Constant Field Values
-
N_NICENAME
public static final java.lang.String N_NICENAME
The node name for the nicename node.- See Also:
- Constant Field Values
-
N_PARAM
public static final java.lang.String N_PARAM
The "param" node name for generic parameters.- See Also:
- Constant Field Values
-
N_PARAMETERS
public static final java.lang.String N_PARAMETERS
The node name for the parameters node.- See Also:
- Constant Field Values
-
N_RESOURCES
public static final java.lang.String N_RESOURCES
The node name for the resources node.- See Also:
- Constant Field Values
-
N_SITE
public static final java.lang.String N_SITE
The node name for the module site.- See Also:
- Constant Field Values
-
N_USERINSTALLED
public static final java.lang.String N_USERINSTALLED
The node name for the user installed node.- See Also:
- Constant Field Values
-
N_VERSION
public static final java.lang.String N_VERSION
The node name for the version node.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CmsModuleXmlHandler
public CmsModuleXmlHandler()
Public constructor, will be called by digester during import.
-
-
Method Detail
-
addXmlDigesterRules
public static void addXmlDigesterRules(org.apache.commons.digester3.Digester digester)
Adds the XML digester rules for a single module.- Parameters:
digester
- the digester to add the rules to
-
generateXml
public static org.dom4j.Element generateXml(CmsModule module, CmsModuleXmlHandler.XmlWriteMode writeMode)
Generates a detached XML element for a module.- Parameters:
module
- the module to generate the XML element forwriteMode
- enum value representing the context for which we are generating the XML- Returns:
- the detached XML element for the module
-
makeValidJavaClassName
public static java.lang.String makeValidJavaClassName(java.lang.String className)
Generates a (hopefully) valid Java class name from an invalid class name.All invalid characters are replaced by an underscore "_". This is for example used to make sure old (5.0) modules can still be imported, by converting the name to a valid class name.
- Parameters:
className
- the class name to make valid- Returns:
- a valid Java class name from an invalid class name
-
addDependency
public void addDependency(java.lang.String name, java.lang.String version)
Adds a module dependency to the current module.- Parameters:
name
- the module name of the dependencyversion
- the module version of the dependency
-
addExcludeResource
public void addExcludeResource(java.lang.String resource)
Adds a resource to the list module resources.- Parameters:
resource
- a resources uri in the OpenCms VFS
-
addExplorerTypeSetting
public void addExplorerTypeSetting(CmsExplorerTypeSettings settings)
Adds an explorer type setting object to the list of type settings.Adds the type setting as well to a map with the resource type name as key.
- Parameters:
settings
- the explorer type settings
-
addExportPoint
public void addExportPoint(java.lang.String uri, java.lang.String destination)
Adds an export point to the module configuration.- Parameters:
uri
- the export point uridestination
- the export point destination
-
addParameter
public void addParameter(java.lang.String key, java.lang.String value)
Adds a module parameter to the module configuration.- Parameters:
key
- the parameter keyvalue
- the parameter value
-
addResource
public void addResource(java.lang.String resource)
Adds a resource to the list module resources.- Parameters:
resource
- a resources uri in the OpenCms VFS
-
addResourceType
public void addResourceType(I_CmsResourceType resourceType)
Adds a new resource type to the internal list of loaded resource types.- Parameters:
resourceType
- the resource type to add- See Also:
I_CmsResourceType.ADD_RESOURCE_TYPE_METHOD
-
createdModule
public void createdModule(java.lang.String name, java.lang.String niceName, java.lang.String group, java.lang.String actionClass, java.lang.String importScript, java.lang.String importSite, java.lang.String site, java.lang.String exportModeName, java.lang.String description, java.lang.String version, java.lang.String authorName, java.lang.String authorEmail, java.lang.String dateCreated, java.lang.String userInstalled, java.lang.String dateInstalled)
Created a new module from the provided parameters.- Parameters:
name
- the name of this module, usually looks like a java package nameniceName
- the "nice" display name of this modulegroup
- the group of the moduleactionClass
- the (optional) module action class nameimportScript
- the import scriptimportSite
- the import site (only one of importSite and site is not null)site
- the module siteexportModeName
- the export mode namedescription
- the description of this moduleversion
- the version of this moduleauthorName
- the name of the author of this moduleauthorEmail
- the email of the module authordateCreated
- the date this module was created by the authoruserInstalled
- the name of the user who uploaded this moduledateInstalled
- the date this module was uploaded
-
setAutoIncrement
public void setAutoIncrement(boolean autoincrement)
Sets the auto-increment mode.- Parameters:
autoincrement
- true if version auto-incrementation should be enabled
-
setCheckpointTime
public void setCheckpointTime(long time)
Sets the checkpoint time.- Parameters:
time
- the checkpoint time
-
setOldModule
public void setOldModule()
Sets the current imported module to an old (5.0.x) style module.
-
-