Package org.opencms.xml.containerpage
Class CmsXmlContainerPage
java.lang.Object
org.opencms.xml.A_CmsXmlDocument
org.opencms.xml.content.CmsXmlContent
org.opencms.xml.containerpage.CmsXmlContainerPage
- All Implemented Interfaces:
I_CmsXmlDocument
Implementation of a object used to access and manage the xml data of a container page.
In addition to the XML content interface. It also provides access to more comfortable beans.
- Since:
- 7.5.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumXML node name constants. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSitemap attribute to re-enable storing setting values that match the default.Name for old internal setting names that are not used with the SYSTEM:: prefix in code.static final StringPrefix for system element settings.Fields inherited from class org.opencms.xml.content.CmsXmlContent
A_VERSION, AUTO_CORRECTION_ATTRIBUTE, m_autoCorrectionEnabled, m_contentDefinition, m_hasInvalidatedBrokenLinks, XERCES_SCHEMA_PROPERTYFields inherited from class org.opencms.xml.A_CmsXmlDocument
m_conversion, m_document, m_elementLocales, m_elementNames, m_encoding, m_file, m_locales -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHides the public constructor.protectedCmsXmlContainerPage(CmsObject cms, Locale locale, String modelUri) Create a new container page based on the given default content, that will have all language nodes of the default content and ensures the presence of the given locale.protectedCmsXmlContainerPage(CmsObject cms, Locale locale, String encoding, CmsXmlContentDefinition contentDefinition) Create a new container page based on the given content definition, that will have one language node for the given locale all initialized with default values.protectedCmsXmlContainerPage(CmsObject cms, org.dom4j.Document document, String encoding, EntityResolver resolver) Creates a new container page based on the provided XML document. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidChecks the link consistency for a given locale and reinitializes the document afterwards.protected CmsContainerPageBeancleanupContainersContainers(CmsObject cms, CmsContainerPageBean cntPage) Removes all empty containers and merges the containers of the current document that are not used in the given container page with it.byte[]createContainerPageXml(CmsObject cms, CmsContainerPageBean cntPage) Saves a container page bean to the in-memory XML structure and returns the changed content.protected CmsResourcefillResource(CmsObject cms, org.dom4j.Element element, CmsUUID resourceId) Fills aCmsXmlVfsFileValuewith the resource identified by the given id.Gets the container page content as a bean.Gets the container page content as a bean.protected voidinitDocument(org.dom4j.Document document, String encoding, CmsXmlContentDefinition definition) Initializes an XML document based on the provided document, encoding and content definition.voidinitDocument(CmsObject cms) Calls initDocument, but with a different CmsObjectprotected voidinitDocument(CmsObject cms, org.dom4j.Document document, String encoding, CmsXmlContentDefinition definition) Initializes an XML document based on the provided document, encoding and content definition.booleanReturnstrueif the auto correction feature is enabled for saving this XML content.protected CmsContainerPageBeanRemoves all empty containers to clean up container page XML.voidsave(CmsObject cms, CmsContainerPageBean cntPage) Saves given container page in the current locale, and not only in memory but also to VFS.voidsave(CmsObject cms, CmsContainerPageBean cntPage, boolean ifChangedOnly) Saves given container page in the current locale, and not only in memory but also to VFS.protected voidsaveContainerPage(CmsObject cms, org.dom4j.Element parent, CmsContainerPageBean cntPage) Adds the given container page to the given element.protected voidSets the file this XML content is written to.voidwriteContainerPage(CmsObject cms, CmsContainerPageBean cntPage) Saves a container page in in-memory XML structure.Methods inherited from class org.opencms.xml.content.CmsXmlContent
addBookmarkForElement, addBookmarkForValue, addLocale, addValue, addValue, clone, copyLocale, getAllSimpleSubValues, getBookmark, getBookmarks, getChoiceOptions, getContentDefinition, getContentDefinition, getHandler, getLinkProcessor, getLocaleNode, getSchemaVersion, getSimpleValuesBelowPath, getSubValues, getValuesByPath, getValueSequence, hasChoiceOptions, hasInvalidatedBrokenLinks, isLocaleIndependent, isTransformedVersion, processSchemaNode, removeValue, resolveMappings, setAutoCorrectionEnabled, synchronizeLocaleIndependentValues, validate, visitAllValuesWithMethods inherited from class org.opencms.xml.A_CmsXmlDocument
addBookmark, addLocale, clearBookmarks, copyLocale, copyLocale, correctXmlStructure, createDeepElementCopy, getBestMatchingLocale, getBookmark, getBookmarkName, getConversion, getEncoding, getFile, getIndexCount, getLocales, getLocales, getNames, getStringValue, getStringValue, getTempDataCache, getValue, getValue, getValueInternal, getValues, getValues, hasLocale, hasValue, hasValue, initDocument, isEnabled, isEnabled, marshal, marshal, moveLocale, removeBookmark, removeLocale, setConversion, toString, updateLocaleNodeSorting, validateXmlStructure
-
Field Details
-
ATTR_STORE_DEFAULT_SETTINGS
Sitemap attribute to re-enable storing setting values that match the default.- See Also:
-
LEGACY_SYSTEM_SETTING_NAMES
Name for old internal setting names that are not used with the SYSTEM:: prefix in code. -
SYSTEM_SETTING_PREFIX
Prefix for system element settings.- See Also:
-
-
Constructor Details
-
CmsXmlContainerPage
protected CmsXmlContainerPage()Hides the public constructor. -
CmsXmlContainerPage
protected CmsXmlContainerPage(CmsObject cms, org.dom4j.Document document, String encoding, EntityResolver resolver) Creates a new container page based on the provided XML document.The given encoding is used when marshalling the XML again later.
- Parameters:
cms- the cms context, ifnullno link validation is performeddocument- the document to create the container page fromencoding- the encoding of the container pageresolver- the XML entity resolver to use
-
CmsXmlContainerPage
Create a new container page based on the given default content, that will have all language nodes of the default content and ensures the presence of the given locale.The given encoding is used when marshalling the XML again later.
- Parameters:
cms- the current users OpenCms contentlocale- the locale to generate the default content formodelUri- the absolute path to the container page file acting as model- Throws:
CmsException- in case the model file is not found or not valid
-
CmsXmlContainerPage
protected CmsXmlContainerPage(CmsObject cms, Locale locale, String encoding, CmsXmlContentDefinition contentDefinition) Create a new container page based on the given content definition, that will have one language node for the given locale all initialized with default values.The given encoding is used when marshalling the XML again later.
- Parameters:
cms- the current users OpenCms contentlocale- the locale to generate the default content forencoding- the encoding to use when marshalling the container page latercontentDefinition- the content definition to create the content for
-
-
Method Details
-
createContainerPageXml
public byte[] createContainerPageXml(CmsObject cms, CmsContainerPageBean cntPage) throws CmsException Saves a container page bean to the in-memory XML structure and returns the changed content.- Parameters:
cms- the current CMS contextcntPage- the container page bean- Returns:
- the new content for the container page
- Throws:
CmsException- if something goes wrong
-
getContainerPage
Gets the container page content as a bean.Always creates a new copy of the bean.
- Parameters:
cms- the current CMS context- Returns:
- the bean containing the container page data
-
getOriginalContainerPage
Gets the container page content as a bean.- Parameters:
cms- the current CMS context- Returns:
- the bean containing the container page data
-
initDocument
Calls initDocument, but with a different CmsObject- Parameters:
cms- the CmsObject to use
-
isAutoCorrectionEnabled
Description copied from class:A_CmsXmlDocumentReturnstrueif the auto correction feature is enabled for saving this XML content.- Overrides:
isAutoCorrectionEnabledin classCmsXmlContent- Returns:
trueif the auto correction feature is enabled for saving this XML content- See Also:
-
save
Saves given container page in the current locale, and not only in memory but also to VFS.- Parameters:
cms- the current cms contextcntPage- the container page to save- Throws:
CmsException- if something goes wrong
-
save
public void save(CmsObject cms, CmsContainerPageBean cntPage, boolean ifChangedOnly) throws CmsException Saves given container page in the current locale, and not only in memory but also to VFS.- Parameters:
cms- the current cms contextcntPage- the container page to saveifChangedOnly-trueto only write the file if the content has changed- Throws:
CmsException- if something goes wrong
-
writeContainerPage
Saves a container page in in-memory XML structure.- Parameters:
cms- the current CMS contextcntPage- the container page bean to save- Throws:
CmsException- if something goes wrong
-
checkLinkConcistency
Checks the link consistency for a given locale and reinitializes the document afterwards.- Parameters:
cms- the cms context
-
cleanupContainersContainers
protected CmsContainerPageBean cleanupContainersContainers(CmsObject cms, CmsContainerPageBean cntPage) Removes all empty containers and merges the containers of the current document that are not used in the given container page with it.- Parameters:
cms- the current CMS contextcntPage- the container page to merge- Returns:
- a new container page with the additional unused containers
-
fillResource
protected CmsResource fillResource(CmsObject cms, org.dom4j.Element element, CmsUUID resourceId) throws CmsException Fills aCmsXmlVfsFileValuewith the resource identified by the given id.- Parameters:
cms- the current CMS contextelement- the XML element to fillresourceId- the ID identifying the resource to use- Returns:
- the resource
- Throws:
CmsException- if the resource can not be read
-
initDocument
protected void initDocument(CmsObject cms, org.dom4j.Document document, String encoding, CmsXmlContentDefinition definition) Description copied from class:CmsXmlContentInitializes an XML document based on the provided document, encoding and content definition.Checks the links and removes invalid ones in the initialized document.
- Overrides:
initDocumentin classCmsXmlContent- Parameters:
cms- the current users OpenCms contentdocument- the base XML document to use for initializingencoding- the encoding to use when marshalling the document laterdefinition- the content definition to use- See Also:
-
initDocument
protected void initDocument(org.dom4j.Document document, String encoding, CmsXmlContentDefinition definition) Description copied from class:A_CmsXmlDocumentInitializes an XML document based on the provided document, encoding and content definition.- Overrides:
initDocumentin classCmsXmlContent- Parameters:
document- the base XML document to use for initializingencoding- the encoding to use when marshalling the document laterdefinition- the content definition to use- See Also:
-
removeEmptyContainers
Removes all empty containers to clean up container page XML.- Parameters:
cntPage- the container page bean- Returns:
- the newly generated result
-
saveContainerPage
protected void saveContainerPage(CmsObject cms, org.dom4j.Element parent, CmsContainerPageBean cntPage) throws CmsException Adds the given container page to the given element.- Parameters:
cms- the current CMS objectparent- the element to add itcntPage- the container page to add- Throws:
CmsException- if something goes wrong
-
setFile
Description copied from class:CmsXmlContentSets the file this XML content is written to.- Overrides:
setFilein classCmsXmlContent- Parameters:
file- the file this XML content content is written to- See Also:
-