Class CmsModuleManager
- Since:
- 6.0.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Indicates dependency check for module deletion.static final int
Indicates dependency check for module import. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new module to the module manager.buildDepsForAllModules
(String rfsAbsPath, boolean mode) Returns a map of dependencies.buildDepsForModulelist
(List<String> moduleNames, String rfsAbsPath, boolean mode) Returns a map of dependencies between the given modules.checkDependencies
(CmsModule module, int mode) Checks if a modules dependencies are fulfilled.void
checkModuleSelectionList
(List<String> moduleNames, String rfsAbsPath, boolean forDeletion) Checks the module selection list for consistency, that means that if a module is selected, all its dependencies are also selected.void
deleteModule
(CmsObject cms, String moduleName, boolean replace, boolean preserveLibs, I_CmsReport report) Deletes a module from the configuration.void
deleteModule
(CmsObject cms, String moduleName, boolean replace, I_CmsReport report) Deletes a module from the configuration.Returns a list of installed modules.getAllModulesFromPath
(String rfsAbsPath) Returns a map of modules found in the given RFS absolute path.Returns the (immutable) list of configured module export points.Returns the importExportRepository.Returns the module with the given module name, ornull
if no module with the given name is configured.Returns the set of names of all the installed modules.boolean
Checks if this module manager has a module with the given name installed.void
initialize
(CmsObject cms, CmsConfigurationManager configurationManager) Initializes all module instance classes managed in this module manager.replaceModule
(CmsObject cms, String importFile, I_CmsReport report) Replaces an existing module with the one read from an import ZIP file.void
setModuleUpdateEnabled
(boolean enabled) Enables / disables incremental module updates, for testing purposes.void
shutDown()
Shuts down all module instance classes managed in this module manager.topologicalSort
(List<String> moduleNames, String rfsAbsPath) Sorts a given list of module names by dependencies, so that the resulting list can be imported in that given order, that means modules without dependencies first.void
updateModule
(CmsObject cms, CmsModule module) Updates a already configured module with new values.void
Updates the module configuration.
-
Field Details
-
DEPENDENCY_MODE_DELETE
Indicates dependency check for module deletion.- See Also:
-
DEPENDENCY_MODE_IMPORT
Indicates dependency check for module import.- See Also:
-
-
Constructor Details
-
CmsModuleManager
Basic constructor.- Parameters:
configuredModules
- the list of configured modules
-
-
Method Details
-
buildDepsForAllModules
public static Map<String,List<String>> buildDepsForAllModules(String rfsAbsPath, boolean mode) throws CmsConfigurationException Returns a map of dependencies.The module dependencies are get from the installed modules or from the module manifest.xml files found in the given FRS path.
Two types of dependency lists can be generated:
- Forward dependency lists: a list of modules that depends on a module
- Backward dependency lists: a list of modules that a module depends on
- Parameters:
rfsAbsPath
- a RFS absolute path to search for modules, ornull
to use the installed modulesmode
- iftrue
a list of forward dependency is build, is not a list of backward dependency- Returns:
- a Map of module names as keys and a list of dependency names as values
- Throws:
CmsConfigurationException
- if something goes wrong
-
buildDepsForModulelist
public static Map<String,List<String>> buildDepsForModulelist(List<String> moduleNames, String rfsAbsPath, boolean mode) throws CmsConfigurationException Returns a map of dependencies between the given modules.The module dependencies are get from the installed modules or from the module manifest.xml files found in the given FRS path.
Two types of dependency lists can be generated:
- Forward dependency lists: a list of modules that depends on a module
- Backward dependency lists: a list of modules that a module depends on
- Parameters:
moduleNames
- a list of module namesrfsAbsPath
- a RFS absolute path to search for modules, ornull
to use the installed modulesmode
- iftrue
a list of forward dependency is build, is not a list of backward dependency- Returns:
- a Map of module names as keys and a list of dependency names as values
- Throws:
CmsConfigurationException
- if something goes wrong
-
getAllModulesFromPath
public static Map<CmsModule,String> getAllModulesFromPath(String rfsAbsPath) throws CmsConfigurationException Returns a map of modules found in the given RFS absolute path.- Parameters:
rfsAbsPath
- the path to look for module distributions- Returns:
- a map of
objects for keys and filename for valuesCmsModule
- Throws:
CmsConfigurationException
- if something goes wrong
-
topologicalSort
public static List<String> topologicalSort(List<String> moduleNames, String rfsAbsPath) throws CmsConfigurationException Sorts a given list of module names by dependencies, so that the resulting list can be imported in that given order, that means modules without dependencies first.The module dependencies are get from the installed modules or from the module manifest.xml files found in the given FRS path.
- Parameters:
moduleNames
- a list of module namesrfsAbsPath
- a RFS absolute path to search for modules, ornull
to use the installed modules- Returns:
- a sorted list of module names
- Throws:
CmsConfigurationException
- if something goes wrong
-
addModule
public void addModule(CmsObject cms, CmsModule module) throws CmsSecurityException, CmsConfigurationException Adds a new module to the module manager.- Parameters:
cms
- must be initialized with "Admin" permissionsmodule
- the module to add- Throws:
CmsSecurityException
- if the required permissions are not available (i.e. no "Admin" CmsObject has been provided)CmsConfigurationException
- if a module with this name is already configured
-
checkDependencies
Checks if a modules dependencies are fulfilled.The possible values for the
mode
parameter are:DEPENDENCY_MODE_DELETE
- Check for module deleting, i.e. are other modules dependent on the given module?
DEPENDENCY_MODE_IMPORT
- Check for module importing, i.e. are all dependencies required by the given module available?
- Parameters:
module
- the module to check the dependencies formode
- the dependency check mode- Returns:
- a list of dependencies that are not fulfilled, if empty all dependencies are fulfilled
-
checkModuleSelectionList
public void checkModuleSelectionList(List<String> moduleNames, String rfsAbsPath, boolean forDeletion) throws CmsIllegalArgumentException, CmsConfigurationException Checks the module selection list for consistency, that means that if a module is selected, all its dependencies are also selected.The module dependencies are get from the installed modules or from the module manifest.xml files found in the given FRS path.
- Parameters:
moduleNames
- a list of module namesrfsAbsPath
- a RFS absolute path to search for modules, ornull
to use the installed modulesforDeletion
- there are two modes, one for installation of modules, and one for deletion.- Throws:
CmsIllegalArgumentException
- if the module list is not consistentCmsConfigurationException
- if something goes wrong
-
deleteModule
public void deleteModule(CmsObject cms, String moduleName, boolean replace, boolean preserveLibs, I_CmsReport report) throws CmsRoleViolationException, CmsConfigurationException, CmsLockException Deletes a module from the configuration.- Parameters:
cms
- must be initialized with "Admin" permissionsmoduleName
- the name of the module to deletereplace
- indicates if the module is replaced (true) or finally deleted (false)preserveLibs
-true
to keep any exported file exported into the WEB-INF lib folderreport
- the report to print progress messages to- Throws:
CmsRoleViolationException
- if the required module manager role permissions are not availableCmsConfigurationException
- if a module with this name is not available for deletingCmsLockException
- if the module resources can not be locked
-
deleteModule
public void deleteModule(CmsObject cms, String moduleName, boolean replace, I_CmsReport report) throws CmsRoleViolationException, CmsConfigurationException, CmsLockException Deletes a module from the configuration.- Parameters:
cms
- must be initialized with "Admin" permissionsmoduleName
- the name of the module to deletereplace
- indicates if the module is replaced (true) or finally deleted (false)report
- the report to print progress messages to- Throws:
CmsRoleViolationException
- if the required module manager role permissions are not availableCmsConfigurationException
- if a module with this name is not available for deletingCmsLockException
- if the module resources can not be locked
-
getAllInstalledModules
Returns a list of installed modules.- Returns:
- a list of
objectsCmsModule
-
getExportPoints
Returns the (immutable) list of configured module export points.- Returns:
- the (immutable) list of configured module export points
- See Also:
-
getImportExportRepository
Returns the importExportRepository.- Returns:
- the importExportRepository
-
getModule
Returns the module with the given module name, ornull
if no module with the given name is configured.- Parameters:
name
- the name of the module to return- Returns:
- the module with the given module name
-
getModuleNames
Returns the set of names of all the installed modules.- Returns:
- the set of names of all the installed modules
-
hasModule
Checks if this module manager has a module with the given name installed.- Parameters:
name
- the name of the module to check- Returns:
- true if this module manager has a module with the given name installed
-
initialize
public void initialize(CmsObject cms, CmsConfigurationManager configurationManager) throws CmsRoleViolationException Initializes all module instance classes managed in this module manager.- Parameters:
cms
- an initialized CmsObject with "manage modules" role permissionsconfigurationManager
- the initialized OpenCms configuration manager- Throws:
CmsRoleViolationException
- if the provided OpenCms context does not have "manage modules" role permissions
-
replaceModule
public CmsReplaceModuleInfo replaceModule(CmsObject cms, String importFile, I_CmsReport report) throws CmsException Replaces an existing module with the one read from an import ZIP file.If there is not already a module with the same name installed, then the module will just be imported normally.
- Parameters:
cms
- the CMS contextimportFile
- the import filereport
- the report- Returns:
- the module replacement status
- Throws:
CmsException
- if something goes wrong
-
setModuleUpdateEnabled
Enables / disables incremental module updates, for testing purposes.- Parameters:
enabled
- if incremental module updating should be enabled
-
shutDown
Shuts down all module instance classes managed in this module manager. -
updateModule
public void updateModule(CmsObject cms, CmsModule module) throws CmsRoleViolationException, CmsConfigurationException Updates a already configured module with new values.- Parameters:
cms
- must be initialized with "Admin" permissionsmodule
- the module to update- Throws:
CmsRoleViolationException
- if the required module manager role permissions are not availableCmsConfigurationException
- if a module with this name is not available for updating
-
updateModuleConfiguration
Updates the module configuration.
-