Package org.opencms.module
Class CmsModuleXmlHandler
java.lang.Object
org.opencms.module.CmsModuleXmlHandler
Adds the XML handler rules for import and export of a single module.
- Since:
- 6.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
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
Modifier and TypeFieldDescriptionstatic final String
The "name" attribute.static final String
The "version" attribute.static final String
The node name for the authoremail node.static final String
The node name for the authorname node.static final String
The node name for the auto increment mode.static final String
The node name for the checkpoint time.static final String
The node name for the class node.static final String
The node name for the datecreated node.static final String
The node name for the date installed node.static final String
The node name for the dependencies node.static final String
The node name for the dependency node.static final String
The node name for the description node.static final String
The node name for the resources node.static final String
The node name for the import site.static final String
The node name for the group node.static final String
Node for the import script.static final String
The node name for a module.static final String
The node name for the name node.static final String
The node name for the nicename node.static final String
The "param" node name for generic parameters.static final String
The node name for the parameters node.static final String
The node name for the resources node.static final String
The node name for the module site.static final String
The node name for the user installed node.static final String
The node name for the version node. -
Constructor Summary
ConstructorDescriptionPublic constructor, will be called by digester during import. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addDependency
(String name, String version) Adds a module dependency to the current module.void
addExcludeResource
(String resource) Adds a resource to the list module resources.void
Adds an explorer type setting object to the list of type settings.void
addExportPoint
(String uri, String destination) Adds an export point to the module configuration.void
addParameter
(String key, String value) Adds a module parameter to the module configuration.void
addResource
(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
(String name, String niceName, String group, String actionClass, String importScript, String importSite, String site, String exportModeName, String description, String version, String authorName, String authorEmail, String dateCreated, String userInstalled, 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.Returns the generated module.static String
makeValidJavaClassName
(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
Sets the current imported module to an old (5.0.x) style module.
-
Field Details
-
A_NAME
The "name" attribute.- See Also:
-
A_VERSION
The "version" attribute.- See Also:
-
N_AUTHOREMAIL
The node name for the authoremail node.- See Also:
-
N_AUTHORNAME
The node name for the authorname node.- See Also:
-
N_AUTOINCREMENT
The node name for the auto increment mode.- See Also:
-
N_CHECKPOINT_TIME
The node name for the checkpoint time.- See Also:
-
N_CLASS
The node name for the class node.- See Also:
-
N_DATECREATED
The node name for the datecreated node.- See Also:
-
N_DATEINSTALLED
The node name for the date installed node.- See Also:
-
N_DEPENDENCIES
The node name for the dependencies node.- See Also:
-
N_DEPENDENCY
The node name for the dependency node.- See Also:
-
N_DESCRIPTION
The node name for the description node.- See Also:
-
N_EXCLUDERESOURCES
The node name for the resources node.- See Also:
-
N_EXPORT_MODE
The node name for the import site.- See Also:
-
N_GROUP
The node name for the group node.- See Also:
-
N_IMPORT_SCRIPT
Node for the import script.- See Also:
-
N_MODULE
The node name for a module.- See Also:
-
N_NAME
The node name for the name node.- See Also:
-
N_NICENAME
The node name for the nicename node.- See Also:
-
N_PARAM
The "param" node name for generic parameters.- See Also:
-
N_PARAMETERS
The node name for the parameters node.- See Also:
-
N_RESOURCES
The node name for the resources node.- See Also:
-
N_SITE
The node name for the module site.- See Also:
-
N_USERINSTALLED
The node name for the user installed node.- See Also:
-
N_VERSION
The node name for the version node.- See Also:
-
-
Constructor Details
-
CmsModuleXmlHandler
public CmsModuleXmlHandler()Public constructor, will be called by digester during import.
-
-
Method Details
-
addXmlDigesterRules
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
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
Adds a module dependency to the current module.- Parameters:
name
- the module name of the dependencyversion
- the module version of the dependency
-
addExcludeResource
Adds a resource to the list module resources.- Parameters:
resource
- a resources uri in the OpenCms VFS
-
addExplorerTypeSetting
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
Adds an export point to the module configuration.- Parameters:
uri
- the export point uridestination
- the export point destination
-
addParameter
Adds a module parameter to the module configuration.- Parameters:
key
- the parameter keyvalue
- the parameter value
-
addResource
Adds a resource to the list module resources.- Parameters:
resource
- a resources uri in the OpenCms VFS
-
addResourceType
Adds a new resource type to the internal list of loaded resource types.- Parameters:
resourceType
- the resource type to add- See Also:
-
createdModule
public void createdModule(String name, String niceName, String group, String actionClass, String importScript, String importSite, String site, String exportModeName, String description, String version, String authorName, String authorEmail, String dateCreated, String userInstalled, 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
-
getModule
Returns the generated module.- Returns:
- the generated module
-
setAutoIncrement
Sets the auto-increment mode.- Parameters:
autoincrement
- true if version auto-incrementation should be enabled
-
setCheckpointTime
Sets the checkpoint time.- Parameters:
time
- the checkpoint time
-
setOldModule
Sets the current imported module to an old (5.0.x) style module.
-