org.opencms.ade.containerpage.inherited
Class CmsContainerConfigurationWriter

java.lang.Object
  extended by org.opencms.ade.containerpage.inherited.CmsContainerConfigurationWriter

public class CmsContainerConfigurationWriter
extends java.lang.Object

A helper class for writing inherited container configuration back to a VFS file.


Constructor Summary
CmsContainerConfigurationWriter()
           
 
Method Summary
protected  CmsContainerConfiguration createConfigurationBean(boolean newOrdering, java.util.List<CmsContainerElementBean> elements, java.util.Set<java.lang.String> parentKeys)
          Converts a list of container elements into a bean which should be saved to the inherited container configuration.
protected  java.util.Map<java.lang.String,CmsXmlContentProperty> getSettingConfiguration(CmsObject cms, CmsResource resource)
          Gets the setting configuration of an element.
protected  void removeExistingEntry(CmsObject cms, CmsXmlContent content, java.util.Locale locale, java.lang.String name)
          Removes an existing inheritance container entry with a given name from the configuration file.
 void save(CmsObject cms, java.lang.String name, boolean newOrdering, CmsResource pageResource, java.util.List<CmsContainerElementBean> elements)
          Saves a list of container element beans to a file in the VFS.
protected  CmsXmlContent saveInContentObject(CmsObject cms, CmsXmlContent content, java.util.Locale locale, java.lang.String name, CmsContainerConfiguration configuration)
          Saves a single container configuration in an XML content object, but doesn't write it to the VFS.
 org.dom4j.Element serializeSingleConfiguration(CmsObject cms, java.lang.String name, CmsContainerConfiguration config, org.dom4j.Element parentElement)
          Serializes a single container configuration into an XML element.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsContainerConfigurationWriter

public CmsContainerConfigurationWriter()
Method Detail

save

public void save(CmsObject cms,
                 java.lang.String name,
                 boolean newOrdering,
                 CmsResource pageResource,
                 java.util.List<CmsContainerElementBean> elements)
          throws CmsException
Saves a list of container element beans to a file in the VFS.

Parameters:
cms - the current CMS context
name - the name of the configuration to save
newOrdering - true if a new ordering needs to be saved
pageResource - a container page or folder
elements - the elements whose data should be saved
Throws:
CmsException - if something goes wrong

serializeSingleConfiguration

public org.dom4j.Element serializeSingleConfiguration(CmsObject cms,
                                                      java.lang.String name,
                                                      CmsContainerConfiguration config,
                                                      org.dom4j.Element parentElement)
                                               throws CmsException
Serializes a single container configuration into an XML element.

Parameters:
cms - the current CMS context
name - the configuration name
config - the configuration bean
parentElement - the parent element to which the new element should be attached
Returns:
the created XML element
Throws:
CmsException

createConfigurationBean

protected CmsContainerConfiguration createConfigurationBean(boolean newOrdering,
                                                            java.util.List<CmsContainerElementBean> elements,
                                                            java.util.Set<java.lang.String> parentKeys)
Converts a list of container elements into a bean which should be saved to the inherited container configuration.

Parameters:
newOrdering - if true, save a new ordering
elements - the elements which should be converted
parentKeys - the keys for new elements defined in the parent configurations
Returns:
the bean containing the information from the container elements which should be saved

getSettingConfiguration

protected java.util.Map<java.lang.String,CmsXmlContentProperty> getSettingConfiguration(CmsObject cms,
                                                                                        CmsResource resource)
                                                                                 throws CmsException
Gets the setting configuration of an element.

Parameters:
cms - the current CMS context
resource - the resource for which the setting configuration should be returned
Returns:
the setting configuration for that element
Throws:
CmsException - if something goes wrong

removeExistingEntry

protected void removeExistingEntry(CmsObject cms,
                                   CmsXmlContent content,
                                   java.util.Locale locale,
                                   java.lang.String name)
Removes an existing inheritance container entry with a given name from the configuration file.

This does nothing if no such entry actually exists.

Parameters:
cms - the current CMS context
content - the XML content
locale - the locale from which to remove the entry
name - the name of the entry

saveInContentObject

protected CmsXmlContent saveInContentObject(CmsObject cms,
                                            CmsXmlContent content,
                                            java.util.Locale locale,
                                            java.lang.String name,
                                            CmsContainerConfiguration configuration)
                                     throws CmsException
Saves a single container configuration in an XML content object, but doesn't write it to the VFS.

If the XML content passed as a parameter is null, a new XML content object will be created

Parameters:
cms - the current CMS context
content - the XML content
locale - the locale in which the configuration should be written
name - the name of the configuration
configuration - the configuration to write
Returns:
the modified or new XML content
Throws:
CmsException - if something goes wrong