public class CmsModuleUpdater extends java.lang.Object
This class updates modules in a smarter way than simply deleting and importing them again: The resources in the import ZIP file are compared to the resources in the currently installed module and only makes changes when necessary. The reason for this is that deletions of resources can be slow in some very large OpenCms installations, and the classic way of updating modules (delete/import) can take a long time because of this.
Constructor and Description |
---|
CmsModuleUpdater(CmsModuleImportData moduleData,
I_CmsReport report)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
checkCompatibleModuleResources(CmsModule installedModule,
CmsModule newModule)
Checks whether the module resources and sites of the two module versions are suitable for updating.
|
static java.util.Optional<CmsModuleUpdater> |
create(CmsObject cms,
java.lang.String importFile,
I_CmsReport report)
Tries to create a new updater instance.
|
protected CmsProject |
createAndSetModuleImportProject(CmsObject cms,
CmsModule module)
Creates the project used to import module resources and sets it on the CmsObject.
|
protected void |
deleteConflictingResources(CmsObject cms,
CmsModule module,
java.util.Map<CmsUUID,CmsUUID> conflictingIds)
Deletes and publishes resources with ID conflicts.
|
void |
importRelations(CmsObject cms)
Update relations for all imported resources.
|
static boolean |
needToUpdateResourceFields(CmsResource existingRes,
CmsResource newRes,
boolean reduced)
Check if a resource needs to be updated because of its direct fields.
|
static java.lang.String |
normalizePath(java.lang.String... pathComponents)
Normalizes the path.
|
protected void |
parseLinks(CmsObject cms)
Parses links for XMLContents etc.
|
protected void |
processDeletions(CmsObject cms,
java.util.List<CmsResource> toDelete)
Handles the file deletions.
|
protected void |
processImportResource(CmsObject cms,
CmsResourceImportData resData,
int index)
Processes single resource from module import data.
|
static CmsModuleImportData |
readModuleData(CmsObject cms,
java.lang.String importFile,
I_CmsReport report)
Reads the module data from an import zip file.
|
void |
run()
Performs the module update.
|
protected void |
runImportScript(CmsObject cms,
CmsModule module)
Runs the module import script.
|
boolean |
updateAcls(CmsObject cms,
CmsResourceImportData resData,
CmsResource resource)
Updates the access control list fr a resource.
|
public CmsModuleUpdater(CmsModuleImportData moduleData, I_CmsReport report)
moduleData
- the module import datareport
- the report to write topublic static boolean checkCompatibleModuleResources(CmsModule installedModule, CmsModule newModule)
installedModule
- the installed modulenewModule
- the module to importpublic static java.util.Optional<CmsModuleUpdater> create(CmsObject cms, java.lang.String importFile, I_CmsReport report) throws CmsException
If the module is deemed non-updatable, an empty result is returned.
cms
- the current CMS contextimportFile
- the import file pathreport
- the report to write toCmsException
- if something goes wrongpublic static boolean needToUpdateResourceFields(CmsResource existingRes, CmsResource newRes, boolean reduced)
existingRes
- the existing resourcenewRes
- the new resourcereduced
- true if we are in reduced export modepublic static java.lang.String normalizePath(java.lang.String... pathComponents)
pathComponents
- the path componentspublic static CmsModuleImportData readModuleData(CmsObject cms, java.lang.String importFile, I_CmsReport report) throws CmsException
cms
- the CMS contextimportFile
- the import filereport
- the report to write toCmsException
- if something goes wrongpublic void importRelations(CmsObject cms) throws CmsException
cms
- the current CMS contextCmsException
- if something goes wrongpublic void run()
public boolean updateAcls(CmsObject cms, CmsResourceImportData resData, CmsResource resource) throws CmsException
cms
- the current cms contextresData
- the resource dataresource
- the existing resourceCmsException
- if something goes wrongprotected CmsProject createAndSetModuleImportProject(CmsObject cms, CmsModule module) throws CmsException
cms
- the CmsObject to set the project onmodule
- the moduleCmsException
- if something goes wrongprotected void deleteConflictingResources(CmsObject cms, CmsModule module, java.util.Map<CmsUUID,CmsUUID> conflictingIds) throws CmsException, java.lang.Exception
cms
- the CMS context to usemodule
- the moduleconflictingIds
- the conflicting idsCmsException
- if something goes wrongjava.lang.Exception
- if something goes wrongprotected void parseLinks(CmsObject cms) throws CmsException
cms
- the CMS context to useCmsException
- if something goes wrongprotected void processDeletions(CmsObject cms, java.util.List<CmsResource> toDelete) throws CmsException
cms
- the CMS context to usetoDelete
- the resources to deleteCmsException
- if something goes wrongprotected void processImportResource(CmsObject cms, CmsResourceImportData resData, int index)
cms
- the CMS context to useresData
- the resource data from the module importindex
- index of the current import resourceprotected void runImportScript(CmsObject cms, CmsModule module)
cms
- the CMS context to usemodule
- the module for which to run the script