org.opencms.widgets
Class CmsCategoryXmlContentHandler

java.lang.Object
  extended byorg.opencms.xml.content.CmsDefaultXmlContentHandler
      extended byorg.opencms.widgets.CmsCategoryXmlContentHandler
All Implemented Interfaces:
I_CmsXmlContentHandler

public class CmsCategoryXmlContentHandler
extends CmsDefaultXmlContentHandler

This handler adds the categories to the current resource and all siblings.

Since:
7.0.5
Version:
$Revision: 1.2 $
Author:
Michael Moossen

Field Summary
 
Fields inherited from class org.opencms.xml.content.CmsDefaultXmlContentHandler
APPINFO_APPINFO, APPINFO_ATTR_CONFIGURATION, APPINFO_ATTR_ELEMENT, APPINFO_ATTR_INVALIDATE, APPINFO_ATTR_MAPTO, APPINFO_ATTR_MESSAGE, APPINFO_ATTR_NAME, APPINFO_ATTR_REGEX, APPINFO_ATTR_SEARCHCONTENT, APPINFO_ATTR_TYPE, APPINFO_ATTR_TYPE_NODE, APPINFO_ATTR_TYPE_PARENT, APPINFO_ATTR_TYPE_WARNING, APPINFO_ATTR_URI, APPINFO_ATTR_VALUE, APPINFO_ATTR_WIDGET, APPINFO_DEFAULT, APPINFO_DEFAULTS, APPINFO_LAYOUT, APPINFO_LAYOUTS, APPINFO_MAPPING, APPINFO_MAPPINGS, APPINFO_MODELFOLDER, APPINFO_PREVIEW, APPINFO_RELATION, APPINFO_RELATIONS, APPINFO_RESOURCEBUNDLE, APPINFO_RULE, APPINFO_SCHEMA_FILE, APPINFO_SCHEMA_FILE_TYPES, APPINFO_SCHEMA_SYSTEM_ID, APPINFO_SCHEMA_TYPES_SYSTEM_ID, APPINFO_SEARCHSETTING, APPINFO_SEARCHSETTINGS, APPINFO_VALIDATIONRULE, APPINFO_VALIDATIONRULES, m_configurationValues, m_defaultValues, m_elementMappings, m_elementWidgets, m_messageBundleName, m_modelFolder, m_previewLocation, m_relations, m_searchSettings, m_validationErrorMessages, m_validationErrorRules, m_validationWarningMessages, m_validationWarningRules, MACRO_PREVIEW_TEMPFILE, MESSAGE_VALIDATION_DEFAULT_ERROR, MESSAGE_VALIDATION_DEFAULT_WARNING
 
Fields inherited from interface org.opencms.xml.content.I_CmsXmlContentHandler
ATTRIBUTES, MAPTO_ATTRIBUTE, MAPTO_PROPERTY, MAPTO_PROPERTY_INDIVIDUAL, MAPTO_PROPERTY_LIST, MAPTO_PROPERTY_LIST_INDIVIDUAL, MAPTO_PROPERTY_LIST_SHARED, MAPTO_PROPERTY_SHARED
 
Constructor Summary
CmsCategoryXmlContentHandler()
          Default constructor.
 
Method Summary
protected  java.util.List getCategories(CmsXmlContent content, java.util.Locale locale)
          Returns all categories set for the given locale.
static java.util.Locale getDefaultLocale(CmsObject cms, java.lang.String resource)
          Returns the default locale in the content of the given resource.
 CmsFile prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file)
          Prepares the given XML content to be written to the OpenCms VFS.
protected  void resetCategories(CmsObject cms, CmsResource resource)
          Removes this resource from all categories.
 CmsXmlContentErrorHandler resolveValidation(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler)
          Performs a validation of the given XML content value, and saves all errors or warnings found in the provided XML content error handler.
protected  void setCategories(CmsObject cms, CmsXmlContent content, CmsResource resource, java.util.Locale locale)
          Sets categories from any category widget for the given locale.
 
Methods inherited from class org.opencms.xml.content.CmsDefaultXmlContentHandler
addCheckRule, addConfiguration, addDefault, addDefaultCheckRules, addMapping, addSearchSetting, addValidationRule, addWidget, getConfiguration, getDefault, getMapping, getMappings, getMessages, getModelFolder, getPreview, getRelationType, getValidationMessage, getWidget, init, initDefaultValues, initialize, initLayouts, initMappings, initModelFolder, initPreview, initRelations, initResourceBundle, initSearchSettings, initValidationRules, invalidateBrokenLinks, isInvalidateParent, isSearchable, key, prepareForUse, removeEmptyMappings, resolveMapping, validateAppinfoElement, validateLink, validateValue, validateValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsCategoryXmlContentHandler

public CmsCategoryXmlContentHandler()
Default constructor.

Method Detail

getDefaultLocale

public static java.util.Locale getDefaultLocale(CmsObject cms,
                                                java.lang.String resource)
Returns the default locale in the content of the given resource.

Parameters:
cms - the cms context
resource - the resource path to get the default locale for
Returns:
the default locale of the resource

prepareForWrite

public CmsFile prepareForWrite(CmsObject cms,
                               CmsXmlContent content,
                               CmsFile file)
                        throws CmsException
Description copied from interface: I_CmsXmlContentHandler
Prepares the given XML content to be written to the OpenCms VFS.

This method is always called before any content gets written. It can be used to perform XML validation, pretty - printing or customized actions on the given XML content.

Specified by:
prepareForWrite in interface I_CmsXmlContentHandler
Overrides:
prepareForWrite in class CmsDefaultXmlContentHandler
Throws:
CmsException
See Also:
I_CmsXmlContentHandler.prepareForWrite(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.file.CmsFile)

resolveValidation

public CmsXmlContentErrorHandler resolveValidation(CmsObject cms,
                                                   I_CmsXmlContentValue value,
                                                   CmsXmlContentErrorHandler errorHandler)
Description copied from interface: I_CmsXmlContentHandler
Performs a validation of the given XML content value, and saves all errors or warnings found in the provided XML content error handler.

The errorHandler parameter is optional, if null is given a new error handler instance must be created.

Specified by:
resolveValidation in interface I_CmsXmlContentHandler
Overrides:
resolveValidation in class CmsDefaultXmlContentHandler
See Also:
CmsDefaultXmlContentHandler.resolveValidation(org.opencms.file.CmsObject, org.opencms.xml.types.I_CmsXmlContentValue, org.opencms.xml.content.CmsXmlContentErrorHandler)

getCategories

protected java.util.List getCategories(CmsXmlContent content,
                                       java.util.Locale locale)
Returns all categories set for the given locale.

Parameters:
content - the xml content to check
locale - the locale to use
Returns:
true, if there is a category widget present

resetCategories

protected void resetCategories(CmsObject cms,
                               CmsResource resource)
                        throws CmsException
Removes this resource from all categories.

Parameters:
cms - the cms context
resource - the resource to reset the categories for
Throws:
CmsException - if something goes wrong

setCategories

protected void setCategories(CmsObject cms,
                             CmsXmlContent content,
                             CmsResource resource,
                             java.util.Locale locale)
                      throws CmsException
Sets categories from any category widget for the given locale.

Parameters:
cms - the cms context
resource - the resource to set the categories for
content - the xml content
locale - the locale to read the categories from
Throws:
CmsException - if an error occurred.