org.opencms.xml.containerpage
Class CmsXmlContainerPage

java.lang.Object
  extended by org.opencms.xml.A_CmsXmlDocument
      extended by org.opencms.xml.content.CmsXmlContent
          extended by org.opencms.xml.containerpage.CmsXmlContainerPage
All Implemented Interfaces:
I_CmsXmlDocument

public class CmsXmlContainerPage
extends CmsXmlContent

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:
getContainerPage(CmsObject, Locale)

Nested Class Summary
static class CmsXmlContainerPage.XmlNode
          XML node name constants.
 
Field Summary
 
Fields inherited from class org.opencms.xml.content.CmsXmlContent
AUTO_CORRECTION_ATTRIBUTE, m_autoCorrectionEnabled, m_contentDefinition, XERCES_SCHEMA_PROPERTY
 
Fields inherited from class org.opencms.xml.A_CmsXmlDocument
m_conversion, m_document, m_elementLocales, m_elementNames, m_encoding, m_file, m_locales
 
Constructor Summary
protected CmsXmlContainerPage()
          Hides the public constructor.
protected CmsXmlContainerPage(CmsObject cms, Document document, String encoding, EntityResolver resolver)
          Creates a new container page based on the provided XML document.
protected CmsXmlContainerPage(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.
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.
 
Method Summary
protected  CmsContainerPageBean addUnusedContainers(CmsObject cms, Locale locale, CmsContainerPageBean cntPage)
          Merges the containers of the current document that are not used in the given container page with it.
 byte[] createContainerPageXml(CmsObject cms, Locale locale, CmsContainerPageBean cntPage)
          Saves a container page bean to the in-memory XML structure and returns the changed content.
protected  CmsResource fillResource(CmsObject cms, Element element, CmsUUID resourceId)
          Fills a CmsXmlVfsFileValue with the resource identified by the given id.
 CmsContainerPageBean getContainerPage(CmsObject cms, Locale locale)
          Returns the container page bean for the given locale.
protected  void initDocument(Document document, String encoding, CmsXmlContentDefinition definition)
          Initializes an XML document based on the provided document, encoding and content definition.
 boolean isAutoCorrectionEnabled()
          Returns true if the auto correction feature is enabled for saving this XML content.
 void save(CmsObject cms, Locale locale, CmsContainerPageBean cntPage)
          Saves given container page in the current locale, and not only in memory but also to VFS.
protected  void saveContainerPage(CmsObject cms, Element parent, CmsContainerPageBean cntPage)
          Adds the given container page to the given element.
protected  void setFile(CmsFile file)
          Sets the file this XML content is written to.
 void writeContainerPage(CmsObject cms, Locale locale, 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, copyLocale, getBookmark, getBookmarks, getChoiceOptions, getContentDefinition, getContentDefinition, getHandler, getLinkProcessor, getLocaleNode, getSubValues, getValue, getValueSequence, hasChoiceOptions, initDocument, processSchemaNode, removeValue, resolveMappings, setAutoCorrectionEnabled, validate, visitAllValuesWith
 
Methods 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, getValue, getValueInternal, getValues, getValues, hasLocale, hasValue, hasValue, initDocument, isEnabled, isEnabled, marshal, marshal, moveLocale, removeBookmark, removeLocale, setConversion, toString, validateXmlStructure
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CmsXmlContainerPage

protected CmsXmlContainerPage()
Hides the public constructor.


CmsXmlContainerPage

protected CmsXmlContainerPage(CmsObject cms,
                              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, if null no link validation is performed
document - the document to create the container page from
encoding - the encoding of the container page
resolver - the XML entity resolver to use

CmsXmlContainerPage

protected CmsXmlContainerPage(CmsObject cms,
                              Locale locale,
                              String modelUri)
                       throws CmsException
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 content
locale - the locale to generate the default content for
modelUri - 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 content
locale - the locale to generate the default content for
encoding - the encoding to use when marshalling the container page later
contentDefinition - the content definition to create the content for
Method Detail

createContainerPageXml

public byte[] createContainerPageXml(CmsObject cms,
                                     Locale locale,
                                     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 context
locale - the locale for which the content should be replaced
cntPage - the container page bean
Returns:
the new content for the container page
Throws:
CmsException - if something goes wrong

getContainerPage

public CmsContainerPageBean getContainerPage(CmsObject cms,
                                             Locale locale)
Returns the container page bean for the given locale.

Parameters:
cms - the cms context
locale - the locale to use
Returns:
the container page bean

isAutoCorrectionEnabled

public boolean isAutoCorrectionEnabled()
Description copied from class: A_CmsXmlDocument
Returns true if the auto correction feature is enabled for saving this XML content.

Overrides:
isAutoCorrectionEnabled in class CmsXmlContent
Returns:
true if the auto correction feature is enabled for saving this XML content
See Also:
CmsXmlContent.isAutoCorrectionEnabled()

save

public void save(CmsObject cms,
                 Locale locale,
                 CmsContainerPageBean cntPage)
          throws CmsException
Saves given container page in the current locale, and not only in memory but also to VFS.

Parameters:
cms - the current cms context
locale - the content locale
cntPage - the container page to save
Throws:
CmsException - if something goes wrong

writeContainerPage

public void writeContainerPage(CmsObject cms,
                               Locale locale,
                               CmsContainerPageBean cntPage)
                        throws CmsException
Saves a container page in in-memory XML structure.

Parameters:
cms - the current CMS context
locale - the locale for which the content should be replaced
cntPage - the container page bean to save
Throws:
CmsException - if something goes wrong

addUnusedContainers

protected CmsContainerPageBean addUnusedContainers(CmsObject cms,
                                                   Locale locale,
                                                   CmsContainerPageBean cntPage)
Merges the containers of the current document that are not used in the given container page with it.

Parameters:
cms - the current CMS context
locale - the content locale
cntPage - the container page to merge
Returns:
a new container page with the additional unused containers

fillResource

protected CmsResource fillResource(CmsObject cms,
                                   Element element,
                                   CmsUUID resourceId)
                            throws CmsException
Fills a CmsXmlVfsFileValue with the resource identified by the given id.

Parameters:
cms - the current CMS context
element - the XML element to fill
resourceId - the ID identifying the resource to use
Returns:
the resource
Throws:
CmsException - if the resource can not be read

initDocument

protected void initDocument(Document document,
                            String encoding,
                            CmsXmlContentDefinition definition)
Description copied from class: A_CmsXmlDocument
Initializes an XML document based on the provided document, encoding and content definition.

Overrides:
initDocument in class CmsXmlContent
Parameters:
document - the base XML document to use for initializing
encoding - the encoding to use when marshalling the document later
definition - the content definition to use
See Also:
A_CmsXmlDocument.initDocument(org.dom4j.Document, java.lang.String, org.opencms.xml.CmsXmlContentDefinition)

saveContainerPage

protected void saveContainerPage(CmsObject cms,
                                 Element parent,
                                 CmsContainerPageBean cntPage)
                          throws CmsException
Adds the given container page to the given element.

Parameters:
cms - the current CMS object
parent - the element to add it
cntPage - the container page to add
Throws:
CmsException - if something goes wrong

setFile

protected void setFile(CmsFile file)
Description copied from class: CmsXmlContent
Sets the file this XML content is written to.

Overrides:
setFile in class CmsXmlContent
Parameters:
file - the file this XML content content is written to
See Also:
CmsXmlContent.setFile(org.opencms.file.CmsFile)