public class CmsModule extends java.lang.Object implements java.lang.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.
I_CmsModuleAction
,
A_CmsModuleAction
Modifier and Type | Class and Description |
---|---|
static class |
CmsModule.ExportMode
The available module export modes.
|
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_DATE
The default date for module created / installed if not provided.
|
Constructor and Description |
---|
CmsModule()
Creates a new, empty CmsModule object.
|
CmsModule(java.lang.String name,
java.lang.String niceName,
java.lang.String group,
java.lang.String actionClass,
java.lang.String importScript,
java.lang.String importSite,
CmsModule.ExportMode exportMode,
java.lang.String description,
CmsModuleVersion version,
java.lang.String authorName,
java.lang.String authorEmail,
long dateCreated,
java.lang.String userInstalled,
long dateInstalled,
java.util.List<CmsModuleDependency> dependencies,
java.util.List<CmsExportPoint> exportPoints,
java.util.List<java.lang.String> resources,
java.util.List<java.lang.String> excluderesources,
java.util.Map<java.lang.String,java.lang.String> parameters)
Creates a new module description with the specified values.
|
Modifier and Type | Method and Description |
---|---|
static void |
addCalculatedModuleResources(java.util.List<CmsResource> result,
CmsObject cms,
java.util.List<CmsResource> moduleResources,
java.util.List<java.lang.String> excludeResources)
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). |
static java.util.List<java.lang.String> |
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 java.util.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.
|
CmsModuleDependency |
checkDependency(CmsModule module)
Checks if this module depends on another given module,
will return the dependency, or
null if no dependency was found. |
protected void |
checkFrozen()
Checks if this modules configuration is frozen.
|
void |
checkResources(CmsObject cms)
Checks if all resources of the module are present.
|
java.lang.Object |
clone()
Clones a CmsModule which is not set to frozen.
|
int |
compareTo(CmsModule obj) |
boolean |
equals(java.lang.Object obj)
Two instances of a module are considered equal if their name is equal.
|
java.lang.String |
getActionClass()
Returns the class name of this modules (optional) action class.
|
I_CmsModuleAction |
getActionInstance()
Returns the module action instance of this module, or
null
if no module action instance is configured. |
java.lang.String |
getAuthorEmail()
Returns the email of the module author.
|
java.lang.String |
getAuthorName()
Returns the name of the author of this module.
|
java.lang.String |
getConfigurationPath()
Gets the module configuration path.
|
long |
getDateCreated()
Returns the date this module was created by the author.
|
long |
getDateInstalled()
Returns the date this module was uploaded.
|
java.util.List<CmsModuleDependency> |
getDependencies()
Returns the list of dependencies of this module.
|
java.lang.String |
getDescription()
Returns the description of this module.
|
java.util.List<java.lang.String> |
getExcludeResources()
Returns the list of VFS resources that do not belong to this module.
|
java.util.List<CmsExplorerTypeSettings> |
getExplorerTypes()
Returns the list of explorer resource types that belong to this module.
|
CmsModule.ExportMode |
getExportMode()
Returns the export mode specified for the module.
|
java.util.List<CmsExportPoint> |
getExportPoints()
Returns the list of export point added by this module.
|
java.lang.String |
getGroup()
Returns the group name of this module.
|
java.lang.String |
getImportScript()
Returns the importScript.
|
java.lang.String |
getImportSite()
Gets the import site.
|
java.lang.String |
getName()
Returns the name of this module.
|
java.lang.String |
getNiceName()
Returns the "nice" display name of this module.
|
long |
getObjectCreateTime()
Gets the timestamp of this object's creation time.
|
java.lang.String |
getParameter(java.lang.String key)
Returns a parameter value from the module parameters.
|
java.lang.String |
getParameter(java.lang.String key,
java.lang.String defaultValue)
Returns a parameter value from the module parameters,
or a given default value in case the parameter is not set.
|
java.util.SortedMap<java.lang.String,java.lang.String> |
getParameters()
Returns the configured (immutable) module parameters.
|
java.util.List<java.lang.String> |
getResources()
Returns the list of VFS resources that belong to this module.
|
java.util.List<I_CmsResourceType> |
getResourceTypes()
Returns the list of additional resource types that belong to this module.
|
java.lang.String |
getUserInstalled()
Returns the name of the user who uploaded this module.
|
CmsModuleVersion |
getVersion()
Returns the version of this module.
|
int |
hashCode() |
protected void |
initialize(CmsObject cms)
Initializes this module, also freezing the module configuration.
|
boolean |
isCreateClassesFolder()
Returns the createClassesFolder flag.
|
boolean |
isCreateElementsFolder()
Returns the createElementsFolder flag.
|
boolean |
isCreateFormattersFolder()
Returns the createFormattersFolder flag.
|
boolean |
isCreateLibFolder()
Returns the createLibFolder flag.
|
boolean |
isCreateModuleFolder()
Returns the createModuleFolder flag.
|
boolean |
isCreateResourcesFolder()
Returns the createResourcesFolder flag.
|
boolean |
isCreateSchemasFolder()
Returns the createSchemasFolder flag.
|
boolean |
isCreateTemplateFolder()
Returns the createTemplateFolder flag.
|
boolean |
isIdentical(CmsModule other)
Checks if this module is identical with another module.
|
boolean |
isReducedExportMode()
Checks, if the module should use the reduced export mode.
|
void |
setActionClass(java.lang.String value)
Sets the class name of this modules (optional) action class.
|
void |
setAuthorEmail(java.lang.String value)
Sets the author email of this module.
|
void |
setAuthorName(java.lang.String value)
Sets the author name of this module.
|
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 |
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(java.util.List<CmsModuleDependency> dependencies)
Sets the list of module dependencies.
|
void |
setDescription(java.lang.String value)
Sets the description of this module.
|
void |
setExcludeResources(java.util.List<java.lang.String> value)
Sets the resources excluded from this module.
|
void |
setExplorerTypes(java.util.List<CmsExplorerTypeSettings> explorerTypeSettings)
Sets the additional explorer types that belong to this module.
|
void |
setExportPoints(java.util.List<CmsExportPoint> exportPoints)
Sets the export points of this module.
|
void |
setGroup(java.lang.String value)
Sets the group name of this module.
|
void |
setImportScript(java.lang.String importScript)
Sets the importScript.
|
void |
setImportSite(java.lang.String importSite)
Sets the import site.
|
void |
setName(java.lang.String value)
Sets the name of this module.
|
void |
setNiceName(java.lang.String value)
Sets the "nice" display name of this module.
|
void |
setParameters(java.util.SortedMap<java.lang.String,java.lang.String> parameters)
Sets the parameters of this module.
|
void |
setReducedExportMode(boolean reducedExportMode)
Set/unset the reduced export mode.
|
void |
setResources(java.util.List<java.lang.String> value)
Sets the resources of this module.
|
void |
setResourceTypes(java.util.List<I_CmsResourceType> resourceTypes)
Sets the list of additional resource types that belong to this module.
|
void |
setUserInstalled(java.lang.String value)
Sets the user who installed of this module.
|
public static final long DEFAULT_DATE
public CmsModule()
public CmsModule(java.lang.String name, java.lang.String niceName, java.lang.String group, java.lang.String actionClass, java.lang.String importScript, java.lang.String importSite, CmsModule.ExportMode exportMode, java.lang.String description, CmsModuleVersion version, java.lang.String authorName, java.lang.String authorEmail, long dateCreated, java.lang.String userInstalled, long dateInstalled, java.util.List<CmsModuleDependency> dependencies, java.util.List<CmsExportPoint> exportPoints, java.util.List<java.lang.String> resources, java.util.List<java.lang.String> excluderesources, java.util.Map<java.lang.String,java.lang.String> 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 importedimportSite
- the site root into which this module should be importedexportMode
- 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 modulepublic static void addCalculatedModuleResources(java.util.List<CmsResource> result, CmsObject cms, java.util.List<CmsResource> moduleResources, java.util.List<java.lang.String> excludeResources) throws CmsException
CmsObject
,moduleResources
(or in a folder of these resources) andexcludedResources
(or a folder of these resources).result
result
- the resource list, that gets extended by the calculated resources.cms
- the CmsObject
used to read resources.moduleResources
- the resources to include.excludeResources
- the site paths of the resources to exclude.CmsException
- thrown if reading resources fails.public static java.util.List<java.lang.String> calculateModuleResourceNames(CmsObject cms, CmsModule module) throws CmsException
For more details of the returned resource, see calculateModuleResources(CmsObject, CmsModule)
.
cms
- the CmsObject
used to read the resources.module
- the module, for which the resources should be calculatedCmsException
- thrown if reading resources fails.public static java.util.List<CmsResource> calculateModuleResources(CmsObject cms, CmsModule module) throws CmsException
CmsObject
cms
- the CmsObject
used to read the resources.module
- the module, for which the resources should be calculatedCmsException
- thrown if reading resources fails.public CmsModuleDependency checkDependency(CmsModule module)
null
if no dependency was found.module
- the other module to check againstpublic void checkResources(CmsObject cms) throws CmsIllegalArgumentException
cms
- an initialized OpenCms user context which must have read access to all module resourcesCmsIllegalArgumentException
- in case not all module resources exist or can be read with the given OpenCms user contextpublic java.lang.Object clone()
This clones module can be used to be update the module information.
clone
in class java.lang.Object
Object.clone()
public int compareTo(CmsModule obj)
compareTo
in interface java.lang.Comparable<CmsModule>
Comparable.compareTo(java.lang.Object)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compareObject.equals(java.lang.Object)
,
isIdentical(CmsModule)
public java.lang.String getActionClass()
If this module does not use an action class,
null
is returned.
public I_CmsModuleAction getActionInstance()
null
if no module action instance is configured.public java.lang.String getAuthorEmail()
public java.lang.String getAuthorName()
public java.lang.String getConfigurationPath()
public long getDateCreated()
public long getDateInstalled()
public java.util.List<CmsModuleDependency> getDependencies()
public java.lang.String getDescription()
public java.util.List<java.lang.String> getExcludeResources()
In particular, files / folders that would be included otherwise, considering the module resources.
public java.util.List<CmsExplorerTypeSettings> getExplorerTypes()
public CmsModule.ExportMode getExportMode()
public java.util.List<CmsExportPoint> getExportPoints()
public java.lang.String getGroup()
public java.lang.String getImportScript()
public java.lang.String getImportSite()
If this is not empty, then it will be used as the site root for importing and exporting this module.
public java.lang.String getName()
The module name must be a valid java package name.
public java.lang.String getNiceName()
public long getObjectCreateTime()
public java.lang.String getParameter(java.lang.String key)
key
- the parameter to return the value forpublic java.lang.String getParameter(java.lang.String key, java.lang.String defaultValue)
key
- the parameter to return the value fordefaultValue
- the default value in case there is no value stored for this keypublic java.util.SortedMap<java.lang.String,java.lang.String> getParameters()
public java.util.List<java.lang.String> getResources()
public java.util.List<I_CmsResourceType> getResourceTypes()
public java.lang.String getUserInstalled()
public CmsModuleVersion getVersion()
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public boolean isCreateClassesFolder()
public boolean isCreateElementsFolder()
public boolean isCreateFormattersFolder()
public boolean isCreateLibFolder()
public boolean isCreateModuleFolder()
public boolean isCreateResourcesFolder()
public boolean isCreateSchemasFolder()
public boolean isCreateTemplateFolder()
public boolean isIdentical(CmsModule other)
Modules A, B are identical if all values of A are equal to B.
The values from getUserInstalled()
and getDateInstalled()
are ignored for this test.
Modules A, B are equal if just the name of A is equal to the name of B.
other
- the module to compare withequals(Object)
public boolean isReducedExportMode()
true
, otherwise false
.public void setActionClass(java.lang.String value)
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.
value
- the class name of this modules (optional) action class to setpublic void setAuthorEmail(java.lang.String value)
Please note:It's not possible to set the modules author email once the module configuration has been frozen.
value
- the module description to setpublic void setAuthorName(java.lang.String value)
Please note:It's not possible to set the modules author name once the module configuration has been frozen.
value
- the module description to setpublic void setCreateClassesFolder(boolean createClassesFolder)
createClassesFolder
- the createClassesFolder flag to setpublic void setCreateElementsFolder(boolean createElementsFolder)
createElementsFolder
- the createElementsFolder flag to setpublic void setCreateFormattersFolder(boolean createFormattersFolder)
createFormattersFolder
- the createFormattersFolder flag to setpublic void setCreateLibFolder(boolean createLibFolder)
createLibFolder
- the createLibFolder flag to setpublic void setCreateModuleFolder(boolean createModuleFolder)
createModuleFolder
- the createModuleFolder flag to setpublic void setCreateResourcesFolder(boolean createResourcesFolder)
createResourcesFolder
- the createResourcesFolder flag to setpublic void setCreateSchemasFolder(boolean createSchemasFolder)
createSchemasFolder
- the createSchemasFolder flag to setpublic void setCreateTemplateFolder(boolean createTemplateFolder)
createTemplateFolder
- the createTemplateFolder flag to setpublic void setDateCreated(long value)
Please note:It's not possible to set the module date created once the module configuration has been frozen.
value
- the date created to setpublic void setDateInstalled(long value)
Please note:It's not possible to set the installation date once the module configuration has been frozen.
value
- the installation date this modulepublic void setDependencies(java.util.List<CmsModuleDependency> dependencies)
dependencies
- list of module dependenciespublic void setDescription(java.lang.String value)
Please note:It's not possible to set the modules description once the module configuration has been frozen.
value
- the module description to setpublic void setExcludeResources(java.util.List<java.lang.String> value)
Please note:It's not possible to set the module resources once the module configuration has been frozen.
value
- the resources to exclude from the modulepublic void setExplorerTypes(java.util.List<CmsExplorerTypeSettings> explorerTypeSettings)
explorerTypeSettings
- the explorer type settings.public void setExportPoints(java.util.List<CmsExportPoint> exportPoints)
exportPoints
- the export points of this module.public void setGroup(java.lang.String value)
Please note:It's not possible to set the modules group name once the module configuration has been frozen.
value
- the module group name to setpublic void setImportScript(java.lang.String importScript)
importScript
- the importScript to setpublic void setImportSite(java.lang.String importSite)
importSite
- the import sitepublic void setName(java.lang.String value)
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.
value
- the module name to setpublic void setNiceName(java.lang.String value)
Please note:It's not possible to set the modules "nice" name once the module configuration has been frozen.
value
- the "nice" display name of this module to setpublic void setParameters(java.util.SortedMap<java.lang.String,java.lang.String> parameters)
Please note:It's not possible to set the module parameters once the module configuration has been frozen.
parameters
- the module parameters to setpublic void setReducedExportMode(boolean reducedExportMode)
reducedExportMode
- if true
, the export mode is set to CmsModule.ExportMode.REDUCED
, otherwise to CmsModule.ExportMode.DEFAULT
.public void setResources(java.util.List<java.lang.String> value)
Please note:It's not possible to set the module resources once the module configuration has been frozen.
value
- the module resources to setpublic void setResourceTypes(java.util.List<I_CmsResourceType> resourceTypes)
resourceTypes
- list of additional resource types that belong to this modulepublic void setUserInstalled(java.lang.String value)
Please note:It's not possible to set the user installed once the module configuration has been frozen.
value
- the user who installed this moduleprotected void checkFrozen() throws CmsIllegalArgumentException
CmsIllegalArgumentException
- in case the configuration is already frozenprotected void initialize(CmsObject cms) throws CmsRoleViolationException
cms
- an initialized OpenCms user contextCmsRoleViolationException
- if the given users does not have the CmsRole.DATABASE_MANAGER
role