Class CmsModule
- All Implemented Interfaces:
Serializable
,Comparable<CmsModule>
OpenCms modules provide a standard mechanism to extend the OpenCms functionality. Modules can contain VFS data, Java classes and a number of configuration options.
- Since:
- 6.0.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The available module export modes. -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
The default date for module created / installed if not provided. -
Constructor Summary
ConstructorDescriptionCreates a new, empty CmsModule object.CmsModule
(String name, String niceName, String group, String actionClass, String importScript, String site, boolean isImportSite, CmsModule.ExportMode exportMode, String description, CmsModuleVersion version, String authorName, String authorEmail, long dateCreated, String userInstalled, long dateInstalled, List<CmsModuleDependency> dependencies, List<CmsExportPoint> exportPoints, List<String> resources, List<String> excluderesources, Map<String, String> parameters) Creates a new module description with the specified values. -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCalculatedModuleResources
(List<CmsResource> result, CmsObject cms, List<CmsResource> moduleResources, List<String> excludeResources) Determines the resources that are: accessible with the providedCmsObject
, part of themoduleResources
(or in a folder of these resources) and not contained inexcludedResources
(or a folder of these resources). and adds the toresult
calculateModuleResourceNames
(CmsObject cms, CmsModule module) Calculates the resources belonging to the module, taking excluded resources and readability of resources into account, and returns site paths of the module resources.static List<CmsResource>
calculateModuleResources
(CmsObject cms, CmsModule module) Calculates and returns the resources belonging to the module, taking excluded resources and readability of resources into account.checkDependency
(CmsModule module) Checks if this module depends on another given module, will return the dependency, ornull
if no dependency was found.protected void
Checks if this modules configuration is frozen.void
checkResources
(CmsObject cms) Checks if all resources of the module are present.clone()
Clones a CmsModule which is not set to frozen.int
boolean
Two instances of a module are considered equal if their name is equal.Returns the class name of this modules (optional) action class.Returns the module action instance of this module, ornull
if no module action instance is configured.Returns the email of the module author.Returns the name of the author of this module.long
Gets the module checkpoint time.Gets the module configuration path.long
Returns the date this module was created by the author.long
Returns the date this module was uploaded.Returns the list of dependencies of this module.Returns the description of this module.Returns the list of VFS resources that do not belong to this module.Returns the list of explorer resource types that belong to this module.Returns the export mode specified for the module.Returns the list of export point added by this module.Gets the export version.getGroup()
Returns the group name of this module.boolean
Returns true if the module has an import site set.Returns the importScript.Gets the import site.getName()
Returns the name of this module.Returns the "nice" display name of this module.long
Gets the timestamp of this object's creation time.getParameter
(String key) Returns a parameter value from the module parameters.getParameter
(String key, String defaultValue) Returns a parameter value from the module parameters, or a given default value in case the parameter is not set.Returns the configured (immutable) module parameters.Returns the list of VFS resources that belong to this module.Returns the list of additional resource types that belong to this module.getSite()
Gets the module's site.Returns the name of the user who uploaded this module.Returns the version of this module.Gets the version number as a string.int
hashCode()
boolean
Returns true if the module has a fixed import site.boolean
Determines if the module haas resources whose site is undefined.boolean
Check if all module resources are under /system or the shared folder.protected void
initialize
(CmsObject cms) Initializes this module, also freezing the module configuration.boolean
Returns true if version auto-incrementation is enabled for this module.boolean
Returns the createClassesFolder flag.boolean
Returns the createElementsFolder flag.boolean
Returns the createFormattersFolder flag.boolean
Returns the createI18NFolder flag.boolean
Returns the createLibFolder flag.boolean
Returns the createModuleFolder flag.boolean
Returns the createResourcesFolder flag.boolean
Returns the createSchemasFolder flag.boolean
Returns the createTemplateFolder flag.boolean
isIdentical
(CmsModule other) Checks if this module is identical with another module.boolean
Checks, if the module should use the reduced export mode.void
setActionClass
(String value) Sets the class name of this modules (optional) action class.void
setAuthorEmail
(String value) Sets the author email of this module.void
setAuthorName
(String value) Sets the author name of this module.void
setAutoIncrement
(boolean autoIncrement) Sets auto-increment mode.void
setCheckpointTime
(long checkpointTime) Sets the module checkpoint time.void
setCreateClassesFolder
(boolean createClassesFolder) Sets the createClassesFolder flag.void
setCreateElementsFolder
(boolean createElementsFolder) Sets the createElementsFolder flag.void
setCreateFormattersFolder
(boolean createFormattersFolder) Sets the createFormattersFolder flag.void
setCreateI18NFolder
(boolean createI18NFolder) Sets the createI18NFolder flag.void
setCreateLibFolder
(boolean createLibFolder) Sets the createLibFolder flag.void
setCreateModuleFolder
(boolean createModuleFolder) Sets the createModuleFolder flag.void
setCreateResourcesFolder
(boolean createResourcesFolder) Sets the createResourcesFolder flag.void
setCreateSchemasFolder
(boolean createSchemasFolder) Sets the createSchemasFolder flag .void
setCreateTemplateFolder
(boolean createTemplateFolder) Sets the createTemplateFolder flag .void
setDateCreated
(long value) Sets the date created of this module.void
setDateInstalled
(long value) Sets the installation date of this module.void
setDependencies
(List<CmsModuleDependency> dependencies) Sets the list of module dependencies.void
setDescription
(String value) Sets the description of this module.void
setExcludeResources
(List<String> value) Sets the resources excluded from this module.void
setExplorerTypes
(List<CmsExplorerTypeSettings> explorerTypeSettings) Sets the additional explorer types that belong to this module.void
setExportPoints
(List<CmsExportPoint> exportPoints) Sets the export points of this module.void
setExportVersion
(String exportVersion) Sets the export version.void
Sets the group name of this module.void
setHasImportSite
(boolean isImportSite) Sets the hasImportSite flag, which determines whether the module site should be used as a fixed import site.void
setImportScript
(String importScript) Sets the importScript.void
setImportSite
(String importSite) Sets the import site.void
Sets the name of this module.void
setNiceName
(String value) Sets the "nice" display name of this module.void
setParameters
(SortedMap<String, String> parameters) Sets the parameters of this module.void
setReducedExportMode
(boolean reducedExportMode) Set/unset the reduced export mode.void
setResources
(List<String> value) Sets the resources of this module.void
setResourceTypes
(List<I_CmsResourceType> resourceTypes) Sets the list of additional resource types that belong to this module.void
Sets the module site.void
setUserInstalled
(String value) Sets the user who installed of this module.void
setVersionStr
(String versionString) Sets the version number as a string.boolean
Determines if the version should be incremented based on the module resources' modification dates.toString()
-
Field Details
-
DEFAULT_DATE
The default date for module created / installed if not provided.- See Also:
-
-
Constructor Details
-
CmsModule
public CmsModule()Creates a new, empty CmsModule object. -
CmsModule
public CmsModule(String name, String niceName, String group, String actionClass, String importScript, String site, boolean isImportSite, CmsModule.ExportMode exportMode, String description, CmsModuleVersion version, String authorName, String authorEmail, long dateCreated, String userInstalled, long dateInstalled, List<CmsModuleDependency> dependencies, List<CmsExportPoint> exportPoints, List<String> resources, List<String> excluderesources, Map<String, String> parameters) Creates a new module description with the specified values.- Parameters:
name
- the name of this module, must be a valid Java package nameniceName
- the "nice" display name of this modulegroup
- the group of this moduleactionClass
- the (optional) module class nameimportScript
- the script to execute when the module is importedsite
- the site the module belongs toisImportSite
- true if the module site should be used as a fixed import siteexportMode
- the export mode that should be used for the moduledescription
- the description of this moduleversion
- the version of this moduleauthorName
- the name of the author of this moduleauthorEmail
- the email of the author of this moduledateCreated
- the date this module was created by the authoruserInstalled
- the name of the user who uploaded this moduledateInstalled
- the date this module was uploadeddependencies
- a list of dependencies of this moduleexportPoints
- a list of export point added by this moduleresources
- a list of VFS resources that belong to this moduleexcluderesources
- a list of VFS resources that are exclude from the module's resourcesparameters
- the parameters for this module
-
-
Method Details
-
addCalculatedModuleResources
public static void addCalculatedModuleResources(List<CmsResource> result, CmsObject cms, List<CmsResource> moduleResources, List<String> excludeResources) throws CmsException Determines the resources that are:- accessible with the provided
CmsObject
, - part of the
moduleResources
(or in a folder of these resources) and - not contained in
excludedResources
(or a folder of these resources).
result
- Parameters:
result
- the resource list, that gets extended by the calculated resources.cms
- theCmsObject
used to read resources.moduleResources
- the resources to include.excludeResources
- the site paths of the resources to exclude.- Throws:
CmsException
- thrown if reading resources fails.
- accessible with the provided
-
calculateModuleResourceNames
public static List<String> calculateModuleResourceNames(CmsObject cms, CmsModule module) throws CmsException Calculates the resources belonging to the module, taking excluded resources and readability of resources into account, and returns site paths of the module resources.For more details of the returned resource, see
calculateModuleResources(CmsObject, CmsModule)
.- Parameters:
cms
- theCmsObject
used to read the resources.module
- the module, for which the resources should be calculated- Returns:
- the calculated module resources
- Throws:
CmsException
- thrown if reading resources fails.
-
calculateModuleResources
public static List<CmsResource> calculateModuleResources(CmsObject cms, CmsModule module) throws CmsException Calculates and returns the resources belonging to the module, taking excluded resources and readability of resources into account. The list of returned resources contains:- Only resources that are readable (present at the system and accessible with the provided
CmsObject
- Only the resource for a folder, if all resources in the folder belong to the module.
- Only resources that are specified as module resources and not excluded by the module's exclude resources.
- Parameters:
cms
- theCmsObject
used to read the resources.module
- the module, for which the resources should be calculated- Returns:
- the calculated module resources
- Throws:
CmsException
- thrown if reading resources fails.
- Only resources that are readable (present at the system and accessible with the provided
-
checkDependency
Checks if this module depends on another given module, will return the dependency, ornull
if no dependency was found.- Parameters:
module
- the other module to check against- Returns:
- the dependency, or null if no dependency was found
-
checkResources
Checks if all resources of the module are present.- Parameters:
cms
- an initialized OpenCms user context which must have read access to all module resources- Throws:
CmsIllegalArgumentException
- in case not all module resources exist or can be read with the given OpenCms user context
-
clone
Clones a CmsModule which is not set to frozen.This clones module can be used to be update the module information.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<CmsModule>
- See Also:
-
equals
Two instances of a module are considered equal if their name is equal. -
getActionClass
Returns the class name of this modules (optional) action class.If this module does not use an action class,
null
is returned.- Returns:
- the class name of this modules (optional) action class
-
getActionInstance
Returns the module action instance of this module, ornull
if no module action instance is configured.- Returns:
- the module action instance of this module
-
getAuthorEmail
Returns the email of the module author.- Returns:
- the email of the module author
-
getAuthorName
Returns the name of the author of this module.- Returns:
- the name of the author of this module
-
getCheckpointTime
Gets the module checkpoint time.This timestamp is used for auto-incrementing the version: if module resources have been modified in the VFS after this timestamp, increment the version.
Note: This is not exported in the manifest. *
- Returns:
- the checkpoint timestamp
-
getConfigurationPath
Gets the module configuration path.- Returns:
- the module configuration path
-
getDateCreated
Returns the date this module was created by the author.- Returns:
- the date this module was created by the author
-
getDateInstalled
Returns the date this module was uploaded.- Returns:
- the date this module was uploaded
-
getDependencies
Returns the list of dependencies of this module.- Returns:
- the list of dependencies of this module
-
getDescription
Returns the description of this module.- Returns:
- the description of this module
-
getExcludeResources
Returns the list of VFS resources that do not belong to this module.In particular, files / folders that would be included otherwise, considering the module resources.
- Returns:
- the list of VFS resources that do not belong to this module
-
getExplorerTypes
Returns the list of explorer resource types that belong to this module.- Returns:
- the list of explorer resource types that belong to this module
-
getExportMode
Returns the export mode specified for the module.- Returns:
- the module's export mode.
-
getExportPoints
Returns the list of export point added by this module.- Returns:
- the list of export point added by this module
-
getExportVersion
Gets the export version.This is only used for module objects which have been read from a zip file.
- Returns:
- the export version
-
getGroup
Returns the group name of this module.- Returns:
- the group name of this module
-
getHasImportSite
Returns true if the module has an import site set.- Returns:
- true if the module has an import site set
-
getImportScript
Returns the importScript.- Returns:
- the importScript
-
getImportSite
Gets the import site.If this is not empty, then it will be used as the site root for importing and exporting this module.
- Returns:
- the import site
-
getName
Returns the name of this module.The module name must be a valid java package name.
- Returns:
- the name of this module
-
getNiceName
Returns the "nice" display name of this module.- Returns:
- the "nice" display name of this module
-
getObjectCreateTime
Gets the timestamp of this object's creation time.- Returns:
- the object creation timestamp
-
getParameter
Returns a parameter value from the module parameters.- Parameters:
key
- the parameter to return the value for- Returns:
- the parameter value from the module parameters
-
getParameter
Returns a parameter value from the module parameters, or a given default value in case the parameter is not set.- Parameters:
key
- the parameter to return the value fordefaultValue
- the default value in case there is no value stored for this key- Returns:
- the parameter value from the module parameters
-
getParameters
Returns the configured (immutable) module parameters.- Returns:
- the configured (immutable) module parameters
-
getResources
Returns the list of VFS resources that belong to this module.- Returns:
- the list of VFS resources that belong to this module
-
getResourceTypes
Returns the list of additional resource types that belong to this module.- Returns:
- the list of additional resource types that belong to this module
-
getSite
Gets the module's site.- Returns:
- the site of the module
-
getUserInstalled
Returns the name of the user who uploaded this module.- Returns:
- the name of the user who uploaded this module
-
getVersion
Returns the version of this module.- Returns:
- the version of this module
-
getVersionStr
Gets the version number as a string.- Returns:
- the version number as a string
-
hashCode
-
hasImportSite
Returns true if the module has a fixed import site.- Returns:
- true if the module has a fixed import site
-
hasModuleResourcesWithUndefinedSite
Determines if the module haas resources whose site is undefined.- Returns:
- true if there are module resources with an undefined site
-
isAutoIncrement
Returns true if version auto-incrementation is enabled for this module.- Returns:
- true if version auto-incrementation is enabled for this module
-
isCreateClassesFolder
Returns the createClassesFolder flag.- Returns:
- the createClassesFolder flag
-
isCreateElementsFolder
Returns the createElementsFolder flag.- Returns:
- the createElementsFolder flag
-
isCreateFormattersFolder
Returns the createFormattersFolder flag.- Returns:
- the createFormattersFolder flag
-
isCreateI18NFolder
Returns the createI18NFolder flag.- Returns:
- boolean
-
isCreateLibFolder
Returns the createLibFolder flag.- Returns:
- the createLibFolder flag
-
isCreateModuleFolder
Returns the createModuleFolder flag.- Returns:
- the createModuleFolder flag
-
isCreateResourcesFolder
Returns the createResourcesFolder flag.- Returns:
- the createResourcesFolder flag
-
isCreateSchemasFolder
Returns the createSchemasFolder flag.- Returns:
- the createSchemasFolder flag
-
isCreateTemplateFolder
Returns the createTemplateFolder flag.- Returns:
- the createTemplateFolder flag
-
isIdentical
Checks if this module is identical with another module.Modules A, B are identical if all values of A are equal to B. The values from
getUserInstalled()
andgetDateInstalled()
are ignored for this test.Modules A, B are equal if just the name of A is equal to the name of B.
- Parameters:
other
- the module to compare with- Returns:
- if the modules are identical
- See Also:
-
isReducedExportMode
Checks, if the module should use the reduced export mode.- Returns:
- if reduce export mode should be used
true
, otherwisefalse
.
-
setActionClass
Sets the class name of this modules (optional) action class.Providing
null
as a value indicates that this module does not use an action class.Please note:It's not possible to set the action class name once the module configuration has been frozen.
- Parameters:
value
- the class name of this modules (optional) action class to set
-
setAuthorEmail
Sets the author email of this module.Please note:It's not possible to set the modules author email once the module configuration has been frozen.
- Parameters:
value
- the module description to set
-
setAuthorName
Sets the author name of this module.Please note:It's not possible to set the modules author name once the module configuration has been frozen.
- Parameters:
value
- the module description to set
-
setAutoIncrement
Sets auto-increment mode.- Parameters:
autoIncrement
- true if version auto-incrementation should be enabled
-
setCheckpointTime
Sets the module checkpoint time.- Parameters:
checkpointTime
- the module checkpoint time
-
setCreateClassesFolder
Sets the createClassesFolder flag.- Parameters:
createClassesFolder
- the createClassesFolder flag to set
-
setCreateElementsFolder
Sets the createElementsFolder flag.- Parameters:
createElementsFolder
- the createElementsFolder flag to set
-
setCreateFormattersFolder
Sets the createFormattersFolder flag.- Parameters:
createFormattersFolder
- the createFormattersFolder flag to set
-
setCreateI18NFolder
Sets the createI18NFolder flag.- Parameters:
createI18NFolder
- boolean
-
setCreateLibFolder
Sets the createLibFolder flag.- Parameters:
createLibFolder
- the createLibFolder flag to set
-
setCreateModuleFolder
Sets the createModuleFolder flag.- Parameters:
createModuleFolder
- the createModuleFolder flag to set
-
setCreateResourcesFolder
Sets the createResourcesFolder flag.- Parameters:
createResourcesFolder
- the createResourcesFolder flag to set
-
setCreateSchemasFolder
Sets the createSchemasFolder flag .- Parameters:
createSchemasFolder
- the createSchemasFolder flag to set
-
setCreateTemplateFolder
Sets the createTemplateFolder flag .- Parameters:
createTemplateFolder
- the createTemplateFolder flag to set
-
setDateCreated
Sets the date created of this module.Please note:It's not possible to set the module date created once the module configuration has been frozen.
- Parameters:
value
- the date created to set
-
setDateInstalled
Sets the installation date of this module.Please note:It's not possible to set the installation date once the module configuration has been frozen.
- Parameters:
value
- the installation date this module
-
setDependencies
Sets the list of module dependencies.- Parameters:
dependencies
- list of module dependencies
-
setDescription
Sets the description of this module.Please note:It's not possible to set the modules description once the module configuration has been frozen.
- Parameters:
value
- the module description to set
-
setExcludeResources
Sets the resources excluded from this module.Please note:It's not possible to set the module resources once the module configuration has been frozen.
- Parameters:
value
- the resources to exclude from the module
-
setExplorerTypes
Sets the additional explorer types that belong to this module.- Parameters:
explorerTypeSettings
- the explorer type settings.
-
setExportPoints
Sets the export points of this module.- Parameters:
exportPoints
- the export points of this module.
-
setExportVersion
Sets the export version.- Parameters:
exportVersion
- the export version
-
setGroup
Sets the group name of this module.Please note:It's not possible to set the modules group name once the module configuration has been frozen.
- Parameters:
value
- the module group name to set
-
setHasImportSite
Sets the hasImportSite flag, which determines whether the module site should be used as a fixed import site.- Parameters:
isImportSite
- true if the module site should be treated as a fixed import site
-
setImportScript
Sets the importScript.- Parameters:
importScript
- the importScript to set
-
setImportSite
Sets the import site.- Parameters:
importSite
- the import site
-
setName
Sets the name of this module.The module name must be a valid java package name.
Please note:It's not possible to set the modules name once the module configuration has been frozen.
- Parameters:
value
- the module name to set
-
setNiceName
Sets the "nice" display name of this module.Please note:It's not possible to set the modules "nice" name once the module configuration has been frozen.
- Parameters:
value
- the "nice" display name of this module to set
-
setParameters
Sets the parameters of this module.Please note:It's not possible to set the module parameters once the module configuration has been frozen.
- Parameters:
parameters
- the module parameters to set
-
setReducedExportMode
Set/unset the reduced export mode.- Parameters:
reducedExportMode
- iftrue
, the export mode is set toCmsModule.ExportMode.REDUCED
, otherwise toCmsModule.ExportMode.DEFAULT
.
-
setResources
Sets the resources of this module.Please note:It's not possible to set the module resources once the module configuration has been frozen.
- Parameters:
value
- the module resources to set
-
setResourceTypes
Sets the list of additional resource types that belong to this module.- Parameters:
resourceTypes
- list of additional resource types that belong to this module
-
setSite
Sets the module site.- Parameters:
siteRoot
- the module site root
-
setUserInstalled
Sets the user who installed of this module.Please note:It's not possible to set the user installed once the module configuration has been frozen.
- Parameters:
value
- the user who installed this module
-
setVersionStr
Sets the version number as a string.- Parameters:
versionString
- the version number string
-
shouldIncrementVersionBasedOnResources
Determines if the version should be incremented based on the module resources' modification dates.- Parameters:
cms
- the CMS context- Returns:
- true if the version number should be incremented
- Throws:
CmsException
- if something goes wrong
-
toString
-
checkFrozen
Checks if this modules configuration is frozen.- Throws:
CmsIllegalArgumentException
- in case the configuration is already frozen
-
initialize
Initializes this module, also freezing the module configuration.- Parameters:
cms
- an initialized OpenCms user context- Throws:
CmsRoleViolationException
- if the given users does not have the
roleCmsRole.DATABASE_MANAGER
-