Class CmsModule

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<CmsModule>

    public class CmsModule
    extends java.lang.Object
    implements java.lang.Comparable<CmsModule>, java.io.Serializable
    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, Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  CmsModule.ExportMode
      The available module export modes.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static long DEFAULT_DATE
      The default date for module created / installed if not provided.
    • Constructor Summary

      Constructors 
      Constructor 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 site, boolean isImportSite, 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.
    • Constructor Detail

      • CmsModule

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

      • 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 site,
                         boolean isImportSite,
                         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.

        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
        importScript - the script to execute when the module is imported
        site - the site the module belongs to
        isImportSite - true if the module site should be used as a fixed import site
        exportMode - the export mode that should be used for the module
        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
        excluderesources - a list of VFS resources that are exclude from the module's resources
        parameters - the parameters for this module
    • Method Detail

      • addCalculatedModuleResources

        public static void addCalculatedModuleResources​(java.util.List<CmsResource> result,
                                                        CmsObject cms,
                                                        java.util.List<CmsResource> moduleResources,
                                                        java.util.List<java.lang.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).
        and adds the to result
        Parameters:
        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.
        Throws:
        CmsException - thrown if reading resources fails.
      • calculateModuleResourceNames

        public static java.util.List<java.lang.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 - the CmsObject 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 java.util.List<CmsResourcecalculateModuleResources​(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 - the CmsObject 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.
      • 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
      • clone

        public CmsModule 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 java.lang.Object
        See Also:
        Object.clone()
      • compareTo

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

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

        Overrides:
        equals in class java.lang.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 java.lang.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 java.lang.String getAuthorEmail()
        Returns the email of the module author.

        Returns:
        the email of the module author
      • getAuthorName

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

        Returns:
        the name of the author of this module
      • getCheckpointTime

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

        public java.lang.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 java.util.List<CmsModuleDependencygetDependencies()
        Returns the list of dependencies of this module.

        Returns:
        the list of dependencies of this module
      • getDescription

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

        Returns:
        the description of this module
      • getExcludeResources

        public java.util.List<java.lang.String> 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

        public java.util.List<CmsExplorerTypeSettingsgetExplorerTypes()
        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 java.util.List<CmsExportPointgetExportPoints()
        Returns the list of export point added by this module.

        Returns:
        the list of export point added by this module
      • getExportVersion

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

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

        Returns:
        the group name of this module
      • getHasImportSite

        public boolean getHasImportSite()
        Returns true if the module has an import site set.

        Returns:
        true if the module has an import site set
      • getImportScript

        public java.lang.String getImportScript()
        Returns the importScript.

        Returns:
        the importScript
      • getImportSite

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

        public java.lang.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 java.lang.String getNiceName()
        Returns the "nice" display name of this module.

        Returns:
        the "nice" display name of this module
      • getObjectCreateTime

        public long getObjectCreateTime()
        Gets the timestamp of this object's creation time.

        Returns:
        the object creation timestamp
      • getParameter

        public java.lang.String getParameter​(java.lang.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 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.

        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 java.util.SortedMap<java.lang.String,​java.lang.String> getParameters()
        Returns the configured (immutable) module parameters.

        Returns:
        the configured (immutable) module parameters
      • getResources

        public java.util.List<java.lang.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 java.util.List<I_CmsResourceTypegetResourceTypes()
        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

        public java.lang.String getSite()
        Gets the module's site.

        Returns:
        the site of the module
      • getUserInstalled

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

        Returns:
        the name of the user who uploaded this module
      • getVersionStr

        public java.lang.String getVersionStr()
        Gets the version number as a string.

        Returns:
        the version number as a string
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        Object.hashCode()
      • hasImportSite

        public boolean hasImportSite()
        Returns true if the module has a fixed import site.

        Returns:
        true if the module has a fixed import site
      • hasModuleResourcesWithUndefinedSite

        public boolean hasModuleResourcesWithUndefinedSite()
        Determines if the module haas resources whose site is undefined.

        Returns:
        true if there are module resources with an undefined site
      • hasOnlySystemAndSharedResources

        public boolean hasOnlySystemAndSharedResources()
        Check if all module resources are under /system or the shared folder.

        Returns:
        true if the module only has resources under system or the shared folder
      • isAutoIncrement

        public boolean isAutoIncrement()
        Returns true if version auto-incrementation is enabled for this module.
        Returns:
        true if version auto-incrementation is enabled for this module
      • 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
      • isCreateI18NFolder

        public boolean isCreateI18NFolder()
        Returns the createI18NFolder flag.

        Returns:
        boolean
      • 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)
      • isReducedExportMode

        public boolean isReducedExportMode()
        Checks, if the module should use the reduced export mode.
        Returns:
        if reduce export mode should be used true, otherwise false.
      • setActionClass

        public void setActionClass​(java.lang.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​(java.lang.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​(java.lang.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
      • setAutoIncrement

        public void setAutoIncrement​(boolean autoIncrement)
        Sets auto-increment mode.
        Parameters:
        autoIncrement - true if version auto-incrementation should be enabled
      • setCheckpointTime

        public void setCheckpointTime​(long checkpointTime)
        Sets the module checkpoint time.
        Parameters:
        checkpointTime - the module checkpoint time
      • 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
      • setCreateI18NFolder

        public void setCreateI18NFolder​(boolean createI18NFolder)
        Sets the createI18NFolder flag.

        Parameters:
        createI18NFolder - boolean
      • 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​(java.util.List<CmsModuleDependency> dependencies)
        Sets the list of module dependencies.

        Parameters:
        dependencies - list of module dependencies
      • setDescription

        public void setDescription​(java.lang.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
      • setExcludeResources

        public void setExcludeResources​(java.util.List<java.lang.String> value)
        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

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

        Parameters:
        explorerTypeSettings - the explorer type settings.
      • setExportPoints

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

        Parameters:
        exportPoints - the export points of this module.
      • setExportVersion

        public void setExportVersion​(java.lang.String exportVersion)
        Sets the export version.

        Parameters:
        exportVersion - the export version
      • setGroup

        public void setGroup​(java.lang.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
      • setHasImportSite

        public void setHasImportSite​(boolean isImportSite)
        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

        public void setImportScript​(java.lang.String importScript)
        Sets the importScript.

        Parameters:
        importScript - the importScript to set
      • setImportSite

        public void setImportSite​(java.lang.String importSite)
        Sets the import site.

        Parameters:
        importSite - the import site
      • setName

        public void setName​(java.lang.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​(java.lang.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​(java.util.SortedMap<java.lang.String,​java.lang.String> parameters)
        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
      • setResources

        public void setResources​(java.util.List<java.lang.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​(java.util.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
      • setSite

        public void setSite​(java.lang.String siteRoot)
        Sets the module site.
        Parameters:
        siteRoot - the module site root
      • setUserInstalled

        public void setUserInstalled​(java.lang.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
      • setVersionStr

        public void setVersionStr​(java.lang.String versionString)
        Sets the version number as a string.
        Parameters:
        versionString - the version number string
      • shouldIncrementVersionBasedOnResources

        public boolean shouldIncrementVersionBasedOnResources​(CmsObject cms)
                                                       throws CmsException
        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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()