Package org.opencms.i18n.tools
Class CmsContainerPageCopier
java.lang.Object
org.opencms.i18n.tools.CmsContainerPageCopier
Helper class for copying container pages including some of their elements.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enum representing the element copy mode.static class
Exception indicating that no custom replacement element was found for a type which requires replacement. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
adjustLocalesForElement
(CmsResource elementResource, CmsResource originalResource) Converts locales for the copied container element.void
copyPageOnly
(CmsResource originalPage, String targetPageRootPath) Copies the given container page to the provided root path.Gets the copied folder or page.Returns the target folder.replaceContainerElement
(CmsResource targetPage, CmsContainerElementBean originalElement) Produces the replacement for a container page element to use in a copy of an existing container page.void
replaceElements
(CmsResource containerPage) Replaces the elements in the copied container page with copies, if appropriate based on the current copy mode.void
run
(CmsResource source, CmsResource target) Starts the page copying process.void
run
(CmsResource source, CmsResource target, String targetName) Starts the page copying process.void
setCopyMode
(CmsContainerPageCopier.CopyMode copyMode) Sets the copy mode.
-
Constructor Details
-
CmsContainerPageCopier
Creates a new instance.- Parameters:
cms
- the CMS context to use
-
-
Method Details
-
adjustLocalesForElement
public void adjustLocalesForElement(CmsResource elementResource, CmsResource originalResource) throws CmsException Converts locales for the copied container element.- Parameters:
elementResource
- the copied container element resourceoriginalResource
- the original container element resource- Throws:
CmsException
- if something goes wrong
-
copyPageOnly
public void copyPageOnly(CmsResource originalPage, String targetPageRootPath) throws CmsException, CmsContainerPageCopier.NoCustomReplacementException Copies the given container page to the provided root path.- Parameters:
originalPage
- the page to copytargetPageRootPath
- the root path of the copy target.- Throws:
CmsException
- thrown if something goes wrong.CmsContainerPageCopier.NoCustomReplacementException
- if a custom replacement is not found for a type which requires it.
-
getCopiedFolderOrPage
Gets the copied folder or page.- Returns:
- the copied folder or page
-
getTargetFolder
Returns the target folder.- Returns:
- the target folder
-
replaceContainerElement
public CmsContainerElementBean replaceContainerElement(CmsResource targetPage, CmsContainerElementBean originalElement) throws CmsException, CmsContainerPageCopier.NoCustomReplacementException Produces the replacement for a container page element to use in a copy of an existing container page.- Parameters:
targetPage
- the target container pageoriginalElement
- the original element- Returns:
- the replacement element for the copied page
- Throws:
CmsException
- if something goes wrongCmsContainerPageCopier.NoCustomReplacementException
- if a custom replacement is not found for a type which requires it
-
replaceElements
public void replaceElements(CmsResource containerPage) throws CmsException, CmsContainerPageCopier.NoCustomReplacementException Replaces the elements in the copied container page with copies, if appropriate based on the current copy mode.- Parameters:
containerPage
- the container page copy whose elements should be replaced with copies- Throws:
CmsException
- if something goes wrongCmsContainerPageCopier.NoCustomReplacementException
- if a custom replacement element was not found for a type which requires it
-
run
public void run(CmsResource source, CmsResource target) throws CmsException, CmsContainerPageCopier.NoCustomReplacementException Starts the page copying process.- Parameters:
source
- the source (can be either a container page, or a folder whose default file is a container page)target
- the target folder- Throws:
CmsException
- if soemthing goes wrongCmsContainerPageCopier.NoCustomReplacementException
- if a custom replacement element was not found
-
run
public void run(CmsResource source, CmsResource target, String targetName) throws CmsException, CmsContainerPageCopier.NoCustomReplacementException Starts the page copying process.- Parameters:
source
- the source (can be either a container page, or a folder whose default file is a container page)target
- the target foldertargetName
- the name to give the new folder- Throws:
CmsException
- if something goes wrongCmsContainerPageCopier.NoCustomReplacementException
- if a custom replacement element was not found
-
setCopyMode
Sets the copy mode.- Parameters:
copyMode
- the copy mode
-