org.opencms.module
Class CmsModule

java.lang.Object
  extended by org.opencms.module.CmsModule
All Implemented Interfaces:
Comparable<CmsModule>

public class CmsModule
extends Object
implements Comparable<CmsModule>

Describes an OpenCms module.

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:
I_CmsModuleAction, A_CmsModuleAction

Field Summary
static long DEFAULT_DATE
          The default date for module created / installed if not provided.
 
Constructor Summary
CmsModule()
          Creates a new, empty CmsModule object.
CmsModule(String name, String niceName, String group, String actionClass, String description, CmsModuleVersion version, String authorName, String authorEmail, long dateCreated, String userInstalled, long dateInstalled, List<CmsModuleDependency> dependencies, List<CmsExportPoint> exportPoints, List<String> resources, Map<String,String> parameters)
          Creates a new module description with the specified values.
 
Method Summary
 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.
 Object clone()
          Clones a CmsModule which is not set to frozen.
 int compareTo(CmsModule obj)
           
 boolean equals(Object obj)
          Two instances of a module are considered equal if their name is equal.
 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.
 String getAuthorEmail()
          Returns the email of the module author.
 String getAuthorName()
          Returns the name of the author of this module.
 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.
 List<CmsModuleDependency> getDependencies()
          Returns the list of dependencies of this module.
 String getDescription()
          Returns the description of this module.
 List<CmsExplorerTypeSettings> getExplorerTypes()
          Returns the list of explorer resource types that belong to this module.
 List<CmsExportPoint> getExportPoints()
          Returns the list of export point added by this module.
 String getGroup()
          Returns the group name of this module.
 String getName()
          Returns the name of this module.
 String getNiceName()
          Returns the "nice" display name of this module.
 String getParameter(String key)
          Returns a parameter value from the module parameters.
 String 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.
 SortedMap<String,String> getParameters()
          Returns the configured (immutable) module parameters.
 List<String> getResources()
          Returns the list of VFS resources that belong to this module.
 List<I_CmsResourceType> getResourceTypes()
          Returns the list of additional resource types that belong to this module.
 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.
 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 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(List<CmsModuleDependency> dependencies)
          Sets the list of module dependencies.
 void setDescription(String value)
          Sets the description of 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 setGroup(String value)
          Sets the group name of this module.
 void setName(String value)
          Sets the name of this module.
 void setNiceName(String value)
          Sets the "nice" display name of this module.
 void setParameters(SortedMap<String,String> value)
          Sets the parameters of this module.
 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 setUserInstalled(String value)
          Sets the user who installed of this module.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DATE

public static final long DEFAULT_DATE
The default date for module created / installed if not provided.

See Also:
Constant Field Values
Constructor Detail

CmsModule

public CmsModule()
Creates a new, empty CmsModule object.


CmsModule

public CmsModule(String name,
                 String niceName,
                 String group,
                 String actionClass,
                 String description,
                 CmsModuleVersion version,
                 String authorName,
                 String authorEmail,
                 long dateCreated,
                 String userInstalled,
                 long dateInstalled,
                 List<CmsModuleDependency> dependencies,
                 List<CmsExportPoint> exportPoints,
                 List<String> resources,
                 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 name
niceName - the "nice" display name of this module
group - the group of this module
actionClass - the (optional) module class name
description - the description of this module
version - the version of this module
authorName - the name of the author of this module
authorEmail - the email of the author of this module
dateCreated - the date this module was created by the author
userInstalled - the name of the user who uploaded this module
dateInstalled - the date this module was uploaded
dependencies - a list of dependencies of this module
exportPoints - a list of export point added by this module
resources - a list of VFS resources that belong to this module
parameters - the parameters for this module
Method Detail

checkDependency

public CmsModuleDependency checkDependency(CmsModule module)
Checks if this module depends on another given module, will return the dependency, or null if no dependency was found.

Parameters:
module - the other module to check against
Returns:
the dependency, or null if no dependency was found

checkResources

public void checkResources(CmsObject cms)
                    throws CmsIllegalArgumentException
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

public Object clone()
Clones a CmsModule which is not set to frozen.

This clones module can be used to be update the module information.

Overrides:
clone in class Object
See Also:
Object.clone()

compareTo

public int compareTo(CmsModule obj)
Specified by:
compareTo in interface Comparable<CmsModule>
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(Object obj)
Two instances of a module are considered equal if their name is equal.

Overrides:
equals in class Object
Parameters:
obj - the object to compare
Returns:
true if the objects are equal
See Also:
Object.equals(java.lang.Object), isIdentical(CmsModule)

getActionClass

public String 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

public I_CmsModuleAction getActionInstance()
Returns the module action instance of this module, or null if no module action instance is configured.

Returns:
the module action instance of this module

getAuthorEmail

public String getAuthorEmail()
Returns the email of the module author.

Returns:
the email of the module author

getAuthorName

public String getAuthorName()
Returns the name of the author of this module.

Returns:
the name of the author of this module

getConfigurationPath

public String getConfigurationPath()
Gets the module configuration path.

Returns:
the module configuration path

getDateCreated

public long getDateCreated()
Returns the date this module was created by the author.

Returns:
the date this module was created by the author

getDateInstalled

public long getDateInstalled()
Returns the date this module was uploaded.

Returns:
the date this module was uploaded

getDependencies

public List<CmsModuleDependency> getDependencies()
Returns the list of dependencies of this module.

Returns:
the list of dependencies of this module

getDescription

public String getDescription()
Returns the description of this module.

Returns:
the description of this module

getExplorerTypes

public List<CmsExplorerTypeSettings> 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

getExportPoints

public List<CmsExportPoint> getExportPoints()
Returns the list of export point added by this module.

Returns:
the list of export point added by this module

getGroup

public String getGroup()
Returns the group name of this module.

Returns:
the group name of this module

getName

public String getName()
Returns the name of this module.

The module name must be a valid java package name.

Returns:
the name of this module

getNiceName

public String getNiceName()
Returns the "nice" display name of this module.

Returns:
the "nice" display name of this module

getParameter

public String getParameter(String key)
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

public String 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.

Parameters:
key - the parameter to return the value for
defaultValue - the default value in case there is no value stored for this key
Returns:
the parameter value from the module parameters

getParameters

public SortedMap<String,String> getParameters()
Returns the configured (immutable) module parameters.

Returns:
the configured (immutable) module parameters

getResources

public List<String> getResources()
Returns the list of VFS resources that belong to this module.

Returns:
the list of VFS resources that belong to this module

getResourceTypes

public List<I_CmsResourceType> 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

getUserInstalled

public String getUserInstalled()
Returns the name of the user who uploaded this module.

Returns:
the name of the user who uploaded this module

getVersion

public CmsModuleVersion getVersion()
Returns the version of this module.

Returns:
the version of this module

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

isCreateClassesFolder

public boolean isCreateClassesFolder()
Returns the createClassesFolder flag.

Returns:
the createClassesFolder flag

isCreateElementsFolder

public boolean isCreateElementsFolder()
Returns the createElementsFolder flag.

Returns:
the createElementsFolder flag

isCreateFormattersFolder

public boolean isCreateFormattersFolder()
Returns the createFormattersFolder flag.

Returns:
the createFormattersFolder flag

isCreateLibFolder

public boolean isCreateLibFolder()
Returns the createLibFolder flag.

Returns:
the createLibFolder flag

isCreateModuleFolder

public boolean isCreateModuleFolder()
Returns the createModuleFolder flag.

Returns:
the createModuleFolder flag

isCreateResourcesFolder

public boolean isCreateResourcesFolder()
Returns the createResourcesFolder flag.

Returns:
the createResourcesFolder flag

isCreateSchemasFolder

public boolean isCreateSchemasFolder()
Returns the createSchemasFolder flag.

Returns:
the createSchemasFolder flag

isCreateTemplateFolder

public boolean isCreateTemplateFolder()
Returns the createTemplateFolder flag.

Returns:
the createTemplateFolder flag

isIdentical

public boolean isIdentical(CmsModule other)
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() 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.

Parameters:
other - the module to compare with
Returns:
if the modules are identical
See Also:
equals(Object)

setActionClass

public void setActionClass(String value)
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

public void setAuthorEmail(String value)
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

public void setAuthorName(String value)
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

setCreateClassesFolder

public void setCreateClassesFolder(boolean createClassesFolder)
Sets the createClassesFolder flag.

Parameters:
createClassesFolder - the createClassesFolder flag to set

setCreateElementsFolder

public void setCreateElementsFolder(boolean createElementsFolder)
Sets the createElementsFolder flag.

Parameters:
createElementsFolder - the createElementsFolder flag to set

setCreateFormattersFolder

public void setCreateFormattersFolder(boolean createFormattersFolder)
Sets the createFormattersFolder flag.

Parameters:
createFormattersFolder - the createFormattersFolder flag to set

setCreateLibFolder

public void setCreateLibFolder(boolean createLibFolder)
Sets the createLibFolder flag.

Parameters:
createLibFolder - the createLibFolder flag to set

setCreateModuleFolder

public void setCreateModuleFolder(boolean createModuleFolder)
Sets the createModuleFolder flag.

Parameters:
createModuleFolder - the createModuleFolder flag to set

setCreateResourcesFolder

public void setCreateResourcesFolder(boolean createResourcesFolder)
Sets the createResourcesFolder flag.

Parameters:
createResourcesFolder - the createResourcesFolder flag to set

setCreateSchemasFolder

public void setCreateSchemasFolder(boolean createSchemasFolder)
Sets the createSchemasFolder flag .

Parameters:
createSchemasFolder - the createSchemasFolder flag to set

setCreateTemplateFolder

public void setCreateTemplateFolder(boolean createTemplateFolder)
Sets the createTemplateFolder flag .

Parameters:
createTemplateFolder - the createTemplateFolder flag to set

setDateCreated

public void setDateCreated(long value)
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

public void setDateInstalled(long value)
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

public void setDependencies(List<CmsModuleDependency> dependencies)
Sets the list of module dependencies.

Parameters:
dependencies - list of module dependencies

setDescription

public void setDescription(String value)
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

setExplorerTypes

public void setExplorerTypes(List<CmsExplorerTypeSettings> explorerTypeSettings)
Sets the additional explorer types that belong to this module.

Parameters:
explorerTypeSettings - the explorer type settings.

setExportPoints

public void setExportPoints(List<CmsExportPoint> exportPoints)
Sets the export points of this module.

Parameters:
exportPoints - the export points of this module.

setGroup

public void setGroup(String value)
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

setName

public void setName(String value)
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

public void setNiceName(String value)
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

public void setParameters(SortedMap<String,String> value)
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:
value - the module parameters to set

setResources

public void setResources(List<String> value)
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

public void setResourceTypes(List<I_CmsResourceType> resourceTypes)
Sets the list of additional resource types that belong to this module.

Parameters:
resourceTypes - list of additional resource types that belong to this module

setUserInstalled

public void setUserInstalled(String value)
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

checkFrozen

protected void checkFrozen()
                    throws CmsIllegalArgumentException
Checks if this modules configuration is frozen.

Throws:
CmsIllegalArgumentException - in case the configuration is already frozen

initialize

protected void initialize(CmsObject cms)
                   throws CmsRoleViolationException
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 CmsRole.DATABASE_MANAGER role