org.opencms.xml.content
Class CmsDefaultXmlContentHandler

java.lang.Object
  extended by org.opencms.xml.content.CmsDefaultXmlContentHandler
All Implemented Interfaces:
I_CmsXmlContentHandler
Direct Known Subclasses:
CmsCategoryXmlContentHandler

public class CmsDefaultXmlContentHandler
extends java.lang.Object
implements I_CmsXmlContentHandler

Default implementation for the XML content handler, will be used by all XML contents that do not provide their own handler.

Since:
6.0.0
Version:
$Revision: 1.66 $
Author:
Alexander Kandzior, Michael Moossen

Field Summary
static java.lang.String APPINFO_APPINFO
          Constant for the "appinfo" element name itself.
static java.lang.String APPINFO_ATTR_COLLAPSE
          Constant for the "collapse" appinfo attribute name.
static java.lang.String APPINFO_ATTR_CONFIGURATION
          Constant for the "configuration" appinfo attribute name.
static java.lang.String APPINFO_ATTR_ELEMENT
          Constant for the "element" appinfo attribute name.
static java.lang.String APPINFO_ATTR_INVALIDATE
          Constant for the "invalidate" appinfo attribute name.
static java.lang.String APPINFO_ATTR_MAPTO
          Constant for the "mapto" appinfo attribute name.
static java.lang.String APPINFO_ATTR_MESSAGE
          Constant for the "message" appinfo attribute name.
static java.lang.String APPINFO_ATTR_NAME
          Constant for the "name" appinfo attribute name.
static java.lang.String APPINFO_ATTR_REGEX
          Constant for the "regex" appinfo attribute name.
static java.lang.String APPINFO_ATTR_SEARCHCONTENT
          Constant for the "searchcontent" appinfo attribute name.
static java.lang.String APPINFO_ATTR_TYPE
          Constant for the "type" appinfo attribute name.
static java.lang.String APPINFO_ATTR_TYPE_NODE
          Constant for the "node" appinfo attribute value.
static java.lang.String APPINFO_ATTR_TYPE_PARENT
          Constant for the "parent" appinfo attribute value.
static java.lang.String APPINFO_ATTR_TYPE_WARNING
          Constant for the "warning" appinfo attribute value.
static java.lang.String APPINFO_ATTR_URI
          Constant for the "uri" appinfo attribute name.
static java.lang.String APPINFO_ATTR_USEALL
          Constant for the "useall" appinfo attribute name.
static java.lang.String APPINFO_ATTR_VALUE
          Constant for the "value" appinfo attribute name.
static java.lang.String APPINFO_ATTR_WIDGET
          Constant for the "widget" appinfo attribute name.
static java.lang.String APPINFO_DEFAULT
          Constant for the "default" appinfo element name.
static java.lang.String APPINFO_DEFAULTS
          Constant for the "defaults" appinfo element name.
static java.lang.String APPINFO_LAYOUT
          Constant for the "layout" appinfo element name.
static java.lang.String APPINFO_LAYOUTS
          Constant for the "layouts" appinfo element name.
static java.lang.String APPINFO_MAPPING
          Constant for the "mapping" appinfo element name.
static java.lang.String APPINFO_MAPPINGS
          Constant for the "mappings" appinfo element name.
static java.lang.String APPINFO_MODELFOLDER
          Constant for the "modelfolder" appinfo element name.
static java.lang.String APPINFO_PREVIEW
          Constant for the "preview" appinfo element name.
static java.lang.String APPINFO_RELATION
          Constant for the "relation" appinfo element name.
static java.lang.String APPINFO_RELATIONS
          Constant for the "relations" appinfo element name.
static java.lang.String APPINFO_RESOURCEBUNDLE
          Constant for the "resourcebundle" appinfo element name.
static java.lang.String APPINFO_RULE
          Constant for the "rule" appinfo element name.
static java.lang.String APPINFO_SCHEMA_FILE
          The file where the default appinfo schema is located.
static java.lang.String APPINFO_SCHEMA_FILE_TYPES
          The file where the default appinfo schema types are located.
static java.lang.String APPINFO_SCHEMA_SYSTEM_ID
          The XML system id for the default appinfo schema types.
static java.lang.String APPINFO_SCHEMA_TYPES_SYSTEM_ID
          The XML system id for the default appinfo schema types.
static java.lang.String APPINFO_SEARCHSETTING
          Constant for the "searchsetting" appinfo element name.
static java.lang.String APPINFO_SEARCHSETTINGS
          Constant for the "searchsettings" appinfo element name.
static java.lang.String APPINFO_TAB
          Constant for the "tab" appinfo element name.
static java.lang.String APPINFO_TABS
          Constant for the "tabs" appinfo element name.
static java.lang.String APPINFO_VALIDATIONRULE
          Constant for the "validationrule" appinfo element name.
static java.lang.String APPINFO_VALIDATIONRULES
          Constant for the "validationrules" appinfo element name.
protected  java.util.Map<java.lang.String,java.lang.String> m_configurationValues
          The configuration values for the element widgets (as defined in the annotations).
protected  java.util.Map<java.lang.String,java.lang.String> m_defaultValues
          The default values for the elements (as defined in the annotations).
protected  java.util.Map<java.lang.String,java.lang.String[]> m_elementMappings
          The element mappings (as defined in the annotations).
protected  java.util.Map<java.lang.String,I_CmsWidget> m_elementWidgets
          The widgets used for the elements (as defined in the annotations).
protected  java.lang.String m_messageBundleName
          The resource bundle name to be used for localization of this content handler.
protected  java.lang.String m_modelFolder
          The folder containing the model file(s) for the content.
protected  java.lang.String m_previewLocation
          The preview location (as defined in the annotations).
protected  java.util.Map<java.lang.String,java.lang.Boolean> m_relationChecks
          The relation check rules.
protected  java.util.Map<java.lang.String,CmsRelationType> m_relations
          The relation check rules.
protected  java.util.Map<java.lang.String,java.lang.Boolean> m_searchSettings
          The search settings.
protected  java.util.List<CmsXmlContentTab> m_tabs
          The configured tabs.
protected  java.util.Map<java.lang.String,java.lang.String> m_validationErrorMessages
          The messages for the error validation rules.
protected  java.util.Map<java.lang.String,java.lang.String> m_validationErrorRules
          The validation rules that cause an error (as defined in the annotations).
protected  java.util.Map<java.lang.String,java.lang.String> m_validationWarningMessages
          The messages for the warning validation rules.
protected  java.util.Map<java.lang.String,java.lang.String> m_validationWarningRules
          The validation rules that cause a warning (as defined in the annotations).
static java.lang.String MACRO_PREVIEW_TEMPFILE
          Macro for resolving the preview URI.
protected static java.lang.String MESSAGE_VALIDATION_DEFAULT_ERROR
          Default message for validation errors.
protected static java.lang.String MESSAGE_VALIDATION_DEFAULT_WARNING
          Default message for validation warnings.
 
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
CmsDefaultXmlContentHandler()
          Creates a new instance of the default XML content handler.
 
Method Summary
protected  void addCheckRule(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String invalidate, java.lang.String type)
          Adds a check rule for a specified element.
protected  void addConfiguration(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String configurationValue)
          Adds a configuration value for an element widget.
protected  void addDefault(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String defaultValue)
          Adds a default value for an element.
protected  void addDefaultCheckRules(CmsXmlContentDefinition rootContentDefinition, I_CmsXmlSchemaType schemaType, java.lang.String elementPath)
          Adds all needed default check rules recursively for the given schema type.
protected  void addMapping(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String mapping)
          Adds an element mapping.
protected  void addSearchSetting(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.Boolean value)
          Adds a search setting for an element.
protected  void addValidationRule(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String regex, java.lang.String message, boolean isWarning)
          Adds a validation rule for a specified element.
protected  void addWidget(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String widgetClassOrAlias)
          Adds a GUI widget for a specified element.
 java.lang.String getConfiguration(I_CmsXmlSchemaType type)
          Returns the configuration String value for the widget used to edit the given XML content schema type.
 java.lang.String getDefault(CmsObject cms, I_CmsXmlContentValue value, java.util.Locale locale)
          Returns the default String value for the given XML content schema type object in the given XML content.
protected  java.util.Locale getLocaleForResource(CmsObject cms, java.lang.String resource)
          Returns the default locale in the content of the given resource.
 java.lang.String getMapping(java.lang.String elementName)
          Deprecated. use getMappings(String) instead to recieve all mappings
 java.lang.String[] getMappings(java.lang.String elementName)
          Returns the all mappings defined for the given element xpath.
 CmsMessages getMessages(java.util.Locale locale)
          Returns the CmsMessages that are used to resolve localized keys for the given locale in this content handler.
 java.lang.String getModelFolder(CmsObject cms, java.lang.String currentFolder)
          Returns the folder that contains eventual XML content model files to use for this resource type.
 java.lang.String getPreview(CmsObject cms, CmsXmlContent content, java.lang.String resourcename)
          Returns the preview URI for the given XML content value object to be displayed in the editor.
protected  java.lang.String getReferencePath(CmsObject cms, I_CmsXmlContentValue value)
          Returns the category reference path for the given value.
 CmsRelationType getRelationType(I_CmsXmlContentValue value)
          Returns the relation type for the given value.
 java.util.List<CmsXmlContentTab> getTabs()
          Returns the tabs to be displayed in the editor.
protected  java.lang.String getValidationMessage(CmsObject cms, I_CmsXmlContentValue value, java.lang.String regex, java.lang.String valueStr, boolean matchResult, boolean isWarning)
          Returns the validation message to be displayed if a certain rule was violated.
 I_CmsWidget getWidget(I_CmsXmlContentValue value)
          Returns the editor widget that should be used for the given XML content value.
protected  void init()
          Called when this content handler is initialized.
protected  void initDefaultValues(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the default values for this content handler.
 void initialize(org.dom4j.Element appInfoElement, CmsXmlContentDefinition contentDefinition)
          Initializes this content handler for the given XML content definition by analyzing the "appinfo" node.
protected  void initLayouts(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the layout for this content handler.
protected  void initMappings(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the element mappings for this content handler.
protected  void initModelFolder(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the folder containing the model file(s) for this content handler.
protected  void initPreview(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the preview location for this content handler.
protected  void initRelations(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the relation configuration for this content handler.
protected  void initResourceBundle(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the resource bundle to use for localized messages in this content handler.
protected  void initSearchSettings(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the search exclusions values for this content handler.
protected  void initTabs(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the tabs for this content handler.
protected  void initValidationRules(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the validation rules this content handler.
 void invalidateBrokenLinks(CmsObject cms, CmsXmlContent document)
          Performs a check of the given XML document.
protected  boolean isInvalidateParent(java.lang.String xpath)
          Returns the is-invalidate-parent flag for the given xpath.
 boolean isSearchable(I_CmsXmlContentValue value)
          Returns true in case the given value should be searchable with the integrated full text search.
protected  java.lang.String key(java.lang.String keyName, java.util.Locale locale)
          Returns the localized resource string for a given message key according to the configured resource bundle of this content handler.
 CmsXmlContent prepareForUse(CmsObject cms, CmsXmlContent content)
          Prepares the given XML content to be used after it was read from the OpenCms VFS.
 CmsFile prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file)
          Prepares the given XML content to be written to the OpenCms VFS.
protected  void removeEmptyMappings(CmsObject cms, CmsXmlContent content)
          Removes property values on resources for non-existing, optional elements.
 void resolveMapping(CmsObject cms, CmsXmlContent content, I_CmsXmlContentValue value)
          Resolves the value mappings of the given XML content value, according to the rules of this XML content handler.
 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 validateAppinfoElement(org.dom4j.Element appinfoElement)
          Validates if the given appinfo element node from the XML content definition schema is valid according the the capabilities of this content handler.
protected  CmsXmlContentErrorHandler validateCategories(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler)
          The errorHandler parameter is optional, if null is given a new error handler instance must be created.
protected  boolean validateLink(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler)
          Validates the given rules against the given value.
protected  CmsXmlContentErrorHandler validateValue(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler, java.util.Map<java.lang.String,java.lang.String> rules, boolean isWarning)
          Validates the given rules against the given value.
protected  CmsXmlContentErrorHandler validateValue(CmsObject cms, I_CmsXmlContentValue value, java.lang.String valueStr, CmsXmlContentErrorHandler errorHandler, boolean isWarning)
          Checks the default XML schema validation rules.
protected  CmsFile writeCategories(CmsObject cms, CmsFile file, CmsXmlContent content)
          Writes the categories if a category widget is present.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPINFO_APPINFO

public static final java.lang.String APPINFO_APPINFO
Constant for the "appinfo" element name itself.

See Also:
Constant Field Values

APPINFO_ATTR_COLLAPSE

public static final java.lang.String APPINFO_ATTR_COLLAPSE
Constant for the "collapse" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_CONFIGURATION

public static final java.lang.String APPINFO_ATTR_CONFIGURATION
Constant for the "configuration" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_ELEMENT

public static final java.lang.String APPINFO_ATTR_ELEMENT
Constant for the "element" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_INVALIDATE

public static final java.lang.String APPINFO_ATTR_INVALIDATE
Constant for the "invalidate" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_MAPTO

public static final java.lang.String APPINFO_ATTR_MAPTO
Constant for the "mapto" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_MESSAGE

public static final java.lang.String APPINFO_ATTR_MESSAGE
Constant for the "message" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_NAME

public static final java.lang.String APPINFO_ATTR_NAME
Constant for the "name" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_REGEX

public static final java.lang.String APPINFO_ATTR_REGEX
Constant for the "regex" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_SEARCHCONTENT

public static final java.lang.String APPINFO_ATTR_SEARCHCONTENT
Constant for the "searchcontent" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_TYPE

public static final java.lang.String APPINFO_ATTR_TYPE
Constant for the "type" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_TYPE_NODE

public static final java.lang.String APPINFO_ATTR_TYPE_NODE
Constant for the "node" appinfo attribute value.

See Also:
Constant Field Values

APPINFO_ATTR_TYPE_PARENT

public static final java.lang.String APPINFO_ATTR_TYPE_PARENT
Constant for the "parent" appinfo attribute value.

See Also:
Constant Field Values

APPINFO_ATTR_TYPE_WARNING

public static final java.lang.String APPINFO_ATTR_TYPE_WARNING
Constant for the "warning" appinfo attribute value.

See Also:
Constant Field Values

APPINFO_ATTR_URI

public static final java.lang.String APPINFO_ATTR_URI
Constant for the "uri" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_USEALL

public static final java.lang.String APPINFO_ATTR_USEALL
Constant for the "useall" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_VALUE

public static final java.lang.String APPINFO_ATTR_VALUE
Constant for the "value" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_WIDGET

public static final java.lang.String APPINFO_ATTR_WIDGET
Constant for the "widget" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_DEFAULT

public static final java.lang.String APPINFO_DEFAULT
Constant for the "default" appinfo element name.

See Also:
Constant Field Values

APPINFO_DEFAULTS

public static final java.lang.String APPINFO_DEFAULTS
Constant for the "defaults" appinfo element name.

See Also:
Constant Field Values

APPINFO_LAYOUT

public static final java.lang.String APPINFO_LAYOUT
Constant for the "layout" appinfo element name.

See Also:
Constant Field Values

APPINFO_LAYOUTS

public static final java.lang.String APPINFO_LAYOUTS
Constant for the "layouts" appinfo element name.

See Also:
Constant Field Values

APPINFO_MAPPING

public static final java.lang.String APPINFO_MAPPING
Constant for the "mapping" appinfo element name.

See Also:
Constant Field Values

APPINFO_MAPPINGS

public static final java.lang.String APPINFO_MAPPINGS
Constant for the "mappings" appinfo element name.

See Also:
Constant Field Values

APPINFO_MODELFOLDER

public static final java.lang.String APPINFO_MODELFOLDER
Constant for the "modelfolder" appinfo element name.

See Also:
Constant Field Values

APPINFO_PREVIEW

public static final java.lang.String APPINFO_PREVIEW
Constant for the "preview" appinfo element name.

See Also:
Constant Field Values

APPINFO_RELATION

public static final java.lang.String APPINFO_RELATION
Constant for the "relation" appinfo element name.

See Also:
Constant Field Values

APPINFO_RELATIONS

public static final java.lang.String APPINFO_RELATIONS
Constant for the "relations" appinfo element name.

See Also:
Constant Field Values

APPINFO_RESOURCEBUNDLE

public static final java.lang.String APPINFO_RESOURCEBUNDLE
Constant for the "resourcebundle" appinfo element name.

See Also:
Constant Field Values

APPINFO_RULE

public static final java.lang.String APPINFO_RULE
Constant for the "rule" appinfo element name.

See Also:
Constant Field Values

APPINFO_SCHEMA_FILE

public static final java.lang.String APPINFO_SCHEMA_FILE
The file where the default appinfo schema is located.

See Also:
Constant Field Values

APPINFO_SCHEMA_FILE_TYPES

public static final java.lang.String APPINFO_SCHEMA_FILE_TYPES
The file where the default appinfo schema types are located.

See Also:
Constant Field Values

APPINFO_SCHEMA_SYSTEM_ID

public static final java.lang.String APPINFO_SCHEMA_SYSTEM_ID
The XML system id for the default appinfo schema types.

See Also:
Constant Field Values

APPINFO_SCHEMA_TYPES_SYSTEM_ID

public static final java.lang.String APPINFO_SCHEMA_TYPES_SYSTEM_ID
The XML system id for the default appinfo schema types.

See Also:
Constant Field Values

APPINFO_SEARCHSETTING

public static final java.lang.String APPINFO_SEARCHSETTING
Constant for the "searchsetting" appinfo element name.

See Also:
Constant Field Values

APPINFO_SEARCHSETTINGS

public static final java.lang.String APPINFO_SEARCHSETTINGS
Constant for the "searchsettings" appinfo element name.

See Also:
Constant Field Values

APPINFO_TAB

public static final java.lang.String APPINFO_TAB
Constant for the "tab" appinfo element name.

See Also:
Constant Field Values

APPINFO_TABS

public static final java.lang.String APPINFO_TABS
Constant for the "tabs" appinfo element name.

See Also:
Constant Field Values

APPINFO_VALIDATIONRULE

public static final java.lang.String APPINFO_VALIDATIONRULE
Constant for the "validationrule" appinfo element name.

See Also:
Constant Field Values

APPINFO_VALIDATIONRULES

public static final java.lang.String APPINFO_VALIDATIONRULES
Constant for the "validationrules" appinfo element name.

See Also:
Constant Field Values

MACRO_PREVIEW_TEMPFILE

public static final java.lang.String MACRO_PREVIEW_TEMPFILE
Macro for resolving the preview URI.

See Also:
Constant Field Values

MESSAGE_VALIDATION_DEFAULT_ERROR

protected static final java.lang.String MESSAGE_VALIDATION_DEFAULT_ERROR
Default message for validation errors.

See Also:
Constant Field Values

MESSAGE_VALIDATION_DEFAULT_WARNING

protected static final java.lang.String MESSAGE_VALIDATION_DEFAULT_WARNING
Default message for validation warnings.

See Also:
Constant Field Values

m_configurationValues

protected java.util.Map<java.lang.String,java.lang.String> m_configurationValues
The configuration values for the element widgets (as defined in the annotations).


m_defaultValues

protected java.util.Map<java.lang.String,java.lang.String> m_defaultValues
The default values for the elements (as defined in the annotations).


m_elementMappings

protected java.util.Map<java.lang.String,java.lang.String[]> m_elementMappings
The element mappings (as defined in the annotations).


m_elementWidgets

protected java.util.Map<java.lang.String,I_CmsWidget> m_elementWidgets
The widgets used for the elements (as defined in the annotations).


m_messageBundleName

protected java.lang.String m_messageBundleName
The resource bundle name to be used for localization of this content handler.


m_modelFolder

protected java.lang.String m_modelFolder
The folder containing the model file(s) for the content.


m_previewLocation

protected java.lang.String m_previewLocation
The preview location (as defined in the annotations).


m_relations

protected java.util.Map<java.lang.String,CmsRelationType> m_relations
The relation check rules.


m_relationChecks

protected java.util.Map<java.lang.String,java.lang.Boolean> m_relationChecks
The relation check rules.


m_searchSettings

protected java.util.Map<java.lang.String,java.lang.Boolean> m_searchSettings
The search settings.


m_tabs

protected java.util.List<CmsXmlContentTab> m_tabs
The configured tabs.


m_validationErrorMessages

protected java.util.Map<java.lang.String,java.lang.String> m_validationErrorMessages
The messages for the error validation rules.


m_validationErrorRules

protected java.util.Map<java.lang.String,java.lang.String> m_validationErrorRules
The validation rules that cause an error (as defined in the annotations).


m_validationWarningMessages

protected java.util.Map<java.lang.String,java.lang.String> m_validationWarningMessages
The messages for the warning validation rules.


m_validationWarningRules

protected java.util.Map<java.lang.String,java.lang.String> m_validationWarningRules
The validation rules that cause a warning (as defined in the annotations).

Constructor Detail

CmsDefaultXmlContentHandler

public CmsDefaultXmlContentHandler()
Creates a new instance of the default XML content handler.

Method Detail

getConfiguration

public java.lang.String getConfiguration(I_CmsXmlSchemaType type)
Description copied from interface: I_CmsXmlContentHandler
Returns the configuration String value for the widget used to edit the given XML content schema type.

If no configuration value is available, this method must return null.

Specified by:
getConfiguration in interface I_CmsXmlContentHandler
Parameters:
type - the value to get the widget configuration for
Returns:
the configuration String value for the widget used to edit the given XML content schema type
See Also:
I_CmsXmlContentHandler.getConfiguration(org.opencms.xml.types.I_CmsXmlSchemaType)

getDefault

public java.lang.String getDefault(CmsObject cms,
                                   I_CmsXmlContentValue value,
                                   java.util.Locale locale)
Description copied from interface: I_CmsXmlContentHandler
Returns the default String value for the given XML content schema type object in the given XML content.

If a schema type does not have a default value, this method must return null.

Specified by:
getDefault in interface I_CmsXmlContentHandler
Parameters:
cms - the current users OpenCms context
value - the value to get the default for
locale - the currently selected locale for the value
Returns:
the default String value for the given XML content value object
See Also:
I_CmsXmlContentHandler.getDefault(org.opencms.file.CmsObject, I_CmsXmlContentValue, java.util.Locale)

getMapping

public java.lang.String getMapping(java.lang.String elementName)
Deprecated. use getMappings(String) instead to recieve all mappings

Returns the first mapping defined for the given element xpath.

Since OpenCms version 7.0.2, multiple mappings for an element are possible, so use getMapping(String) instead.

Parameters:
elementName - the element xpath to look up the mapping for
Returns:
the mapping defined for the given element xpath

getMappings

public java.lang.String[] getMappings(java.lang.String elementName)
Returns the all mappings defined for the given element xpath.

Parameters:
elementName - the element xpath to look up the mapping for
Returns:
the mapping defined for the given element xpath
Since:
7.0.2

getMessages

public CmsMessages getMessages(java.util.Locale locale)
Description copied from interface: I_CmsXmlContentHandler
Returns the CmsMessages that are used to resolve localized keys for the given locale in this content handler.

If no localized messages are configured for this content handler, this method returns null.

Specified by:
getMessages in interface I_CmsXmlContentHandler
Parameters:
locale - the locale to get the messages for
Returns:
the CmsMessages that are used to resolve localized keys for the given locale in this content handler
See Also:
I_CmsXmlContentHandler.getMessages(java.util.Locale)

getModelFolder

public java.lang.String getModelFolder(CmsObject cms,
                                       java.lang.String currentFolder)
Description copied from interface: I_CmsXmlContentHandler
Returns the folder that contains eventual XML content model files to use for this resource type.

Specified by:
getModelFolder in interface I_CmsXmlContentHandler
Parameters:
cms - the current OpenCms user context
currentFolder - the folder the user is currently working in
Returns:
the folder containing eventual XML content master files
See Also:
I_CmsXmlContentHandler.getModelFolder(org.opencms.file.CmsObject, java.lang.String)

getPreview

public java.lang.String getPreview(CmsObject cms,
                                   CmsXmlContent content,
                                   java.lang.String resourcename)
Description copied from interface: I_CmsXmlContentHandler
Returns the preview URI for the given XML content value object to be displayed in the editor.

If null is returned, no preview is possible for contents using this handler.

Specified by:
getPreview in interface I_CmsXmlContentHandler
Parameters:
cms - the current OpenCms user context
content - the XML content to display the preview URI for
resourcename - the name in the VFS of the resource that is currently edited
Returns:
the preview URI for the given XML content value object to be displayed in the editor
See Also:
I_CmsXmlContentHandler.getPreview(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, java.lang.String)

getRelationType

public CmsRelationType getRelationType(I_CmsXmlContentValue value)
Description copied from interface: I_CmsXmlContentHandler
Returns the relation type for the given value.

Specified by:
getRelationType in interface I_CmsXmlContentHandler
Parameters:
value - the value to get the relation type for
Returns:
the relation type for the given value
See Also:
I_CmsXmlContentHandler.getRelationType(I_CmsXmlContentValue)

getWidget

public I_CmsWidget getWidget(I_CmsXmlContentValue value)
Description copied from interface: I_CmsXmlContentHandler
Returns the editor widget that should be used for the given XML content value.

The handler implementations should use the "appinfo" node of the XML content definition schema to define the mappings of elements to widgets.

Specified by:
getWidget in interface I_CmsXmlContentHandler
Parameters:
value - the XML content value to get the widget for
Returns:
the editor widget that should be used for the given XML content value
See Also:
I_CmsXmlContentHandler.getWidget(org.opencms.xml.types.I_CmsXmlContentValue)

initialize

public void initialize(org.dom4j.Element appInfoElement,
                       CmsXmlContentDefinition contentDefinition)
                throws CmsXmlException
Description copied from interface: I_CmsXmlContentHandler
Initializes this content handler for the given XML content definition by analyzing the "appinfo" node.

Specified by:
initialize in interface I_CmsXmlContentHandler
Parameters:
appInfoElement - the "appinfo" element root node to analyze
contentDefinition - the XML content definition that XML content handler belongs to
Throws:
CmsXmlException - if something goes wrong
See Also:
I_CmsXmlContentHandler.initialize(org.dom4j.Element, org.opencms.xml.CmsXmlContentDefinition)

invalidateBrokenLinks

public void invalidateBrokenLinks(CmsObject cms,
                                  CmsXmlContent document)
Description copied from interface: I_CmsXmlContentHandler
Performs a check of the given XML document.

The main difference to the I_CmsXmlContentHandler.resolveValidation(CmsObject, I_CmsXmlContentValue, CmsXmlContentErrorHandler) method is that this method may silently remove some values, for instance, for broken links.

Specified by:
invalidateBrokenLinks in interface I_CmsXmlContentHandler
Parameters:
cms - the current OpenCms user context
document - the document to resolve the check rules for
See Also:
I_CmsXmlContentHandler.invalidateBrokenLinks(CmsObject, CmsXmlContent)

isSearchable

public boolean isSearchable(I_CmsXmlContentValue value)
Description copied from interface: I_CmsXmlContentHandler
Returns true in case the given value should be searchable with the integrated full text search.

For the full text search, the value of all elements in one locale of the XML content are combined to one big text, which is referred to as the "content" in the context of the full text search. With this option, it is possible to hide certain elements from this "content" that does not make sense to include in the full text search.

Specified by:
isSearchable in interface I_CmsXmlContentHandler
Parameters:
value - the XML content value to check
Returns:
true in case the given value should be searchable
See Also:
I_CmsXmlContentHandler.isSearchable(org.opencms.xml.types.I_CmsXmlContentValue)

prepareForUse

public CmsXmlContent prepareForUse(CmsObject cms,
                                   CmsXmlContent content)
Description copied from interface: I_CmsXmlContentHandler
Prepares the given XML content to be used after it was read from the OpenCms VFS.

This method is always called after any content is unmarshalled. It can be used to perform customized actions on the given XML content.

Specified by:
prepareForUse in interface I_CmsXmlContentHandler
Parameters:
cms - the current OpenCms user context
content - the XML content to be used as read from the VFS
Returns:
the prepared content to be used
See Also:
I_CmsXmlContentHandler.prepareForUse(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent)

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
Parameters:
cms - the current OpenCms user context
content - the XML content to be written
file - the resource the XML content in it's current state was unmarshalled from
Returns:
the file to write to the OpenCms VFS, this will be an updated version of the parameter file
Throws:
CmsException - in case something goes wrong
See Also:
I_CmsXmlContentHandler.prepareForWrite(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.file.CmsFile)

resolveMapping

public void resolveMapping(CmsObject cms,
                           CmsXmlContent content,
                           I_CmsXmlContentValue value)
                    throws CmsException
Description copied from interface: I_CmsXmlContentHandler
Resolves the value mappings of the given XML content value, according to the rules of this XML content handler.

Specified by:
resolveMapping in interface I_CmsXmlContentHandler
Parameters:
cms - the current OpenCms user context
content - the XML content to resolve the mappings for
value - the value to resolve the mappings for
Throws:
CmsException - if something goes wrong
See Also:
I_CmsXmlContentHandler.resolveMapping(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.xml.types.I_CmsXmlContentValue)

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
Parameters:
cms - the current OpenCms user context
value - the value to resolve the validation rules for
errorHandler - (optional) an error handler instance that contains previous error or warnings
Returns:
an error handler that contains all errors and warnings currently found
See Also:
I_CmsXmlContentHandler.resolveValidation(org.opencms.file.CmsObject, org.opencms.xml.types.I_CmsXmlContentValue, org.opencms.xml.content.CmsXmlContentErrorHandler)

addCheckRule

protected void addCheckRule(CmsXmlContentDefinition contentDefinition,
                            java.lang.String elementName,
                            java.lang.String invalidate,
                            java.lang.String type)
                     throws CmsXmlException
Adds a check rule for a specified element.

Parameters:
contentDefinition - the XML content definition this XML content handler belongs to
elementName - the element name to add the rule to
invalidate - false, to disable link check / true or node, to invalidate just the single node if the link is broken / parent, if this rule will invalidate the whole parent node in nested content
type - the relation type
Throws:
CmsXmlException - in case an unknown element name is used

addConfiguration

protected void addConfiguration(CmsXmlContentDefinition contentDefinition,
                                java.lang.String elementName,
                                java.lang.String configurationValue)
                         throws CmsXmlException
Adds a configuration value for an element widget.

Parameters:
contentDefinition - the XML content definition this XML content handler belongs to
elementName - the element name to map
configurationValue - the configuration value to use
Throws:
CmsXmlException - in case an unknown element name is used

addDefault

protected void addDefault(CmsXmlContentDefinition contentDefinition,
                          java.lang.String elementName,
                          java.lang.String defaultValue)
                   throws CmsXmlException
Adds a default value for an element.

Parameters:
contentDefinition - the XML content definition this XML content handler belongs to
elementName - the element name to map
defaultValue - the default value to use
Throws:
CmsXmlException - in case an unknown element name is used

addDefaultCheckRules

protected void addDefaultCheckRules(CmsXmlContentDefinition rootContentDefinition,
                                    I_CmsXmlSchemaType schemaType,
                                    java.lang.String elementPath)
                             throws CmsXmlException
Adds all needed default check rules recursively for the given schema type.

Parameters:
rootContentDefinition - the root content definition
schemaType - the schema type to check
elementPath - the current element path
Throws:
CmsXmlException - if something goes wrong

addMapping

protected void addMapping(CmsXmlContentDefinition contentDefinition,
                          java.lang.String elementName,
                          java.lang.String mapping)
                   throws CmsXmlException
Adds an element mapping.

Parameters:
contentDefinition - the XML content definition this XML content handler belongs to
elementName - the element name to map
mapping - the mapping to use
Throws:
CmsXmlException - in case an unknown element name is used

addSearchSetting

protected void addSearchSetting(CmsXmlContentDefinition contentDefinition,
                                java.lang.String elementName,
                                java.lang.Boolean value)
                         throws CmsXmlException
Adds a search setting for an element.

Parameters:
contentDefinition - the XML content definition this XML content handler belongs to
elementName - the element name to map
value - the search setting value to store
Throws:
CmsXmlException - in case an unknown element name is used

addValidationRule

protected void addValidationRule(CmsXmlContentDefinition contentDefinition,
                                 java.lang.String elementName,
                                 java.lang.String regex,
                                 java.lang.String message,
                                 boolean isWarning)
                          throws CmsXmlException
Adds a validation rule for a specified element.

Parameters:
contentDefinition - the XML content definition this XML content handler belongs to
elementName - the element name to add the rule to
regex - the validation rule regular expression
message - the message in case validation fails (may be null)
isWarning - if true, this rule is used for warnings, otherwise it's an error
Throws:
CmsXmlException - in case an unknown element name is used

addWidget

protected void addWidget(CmsXmlContentDefinition contentDefinition,
                         java.lang.String elementName,
                         java.lang.String widgetClassOrAlias)
                  throws CmsXmlException
Adds a GUI widget for a specified element.

Parameters:
contentDefinition - the XML content definition this XML content handler belongs to
elementName - the element name to map
widgetClassOrAlias - the widget to use as GUI for the element (registered alias or class name)
Throws:
CmsXmlException - in case an unknown element name is used

getLocaleForResource

protected java.util.Locale getLocaleForResource(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

getReferencePath

protected java.lang.String getReferencePath(CmsObject cms,
                                            I_CmsXmlContentValue value)
Returns the category reference path for the given value.

Parameters:
cms - the cms context
value - the xml content value
Returns:
the category reference path for the given value

getValidationMessage

protected java.lang.String getValidationMessage(CmsObject cms,
                                                I_CmsXmlContentValue value,
                                                java.lang.String regex,
                                                java.lang.String valueStr,
                                                boolean matchResult,
                                                boolean isWarning)
Returns the validation message to be displayed if a certain rule was violated.

Parameters:
cms - the current users OpenCms context
value - the value to validate
regex - the rule that was violated
valueStr - the string value of the given value
matchResult - if false, the rule was negated
isWarning - if true, this validation indicate a warning, otherwise an error
Returns:
the validation message to be displayed

init

protected void init()
Called when this content handler is initialized.


initDefaultValues

protected void initDefaultValues(org.dom4j.Element root,
                                 CmsXmlContentDefinition contentDefinition)
                          throws CmsXmlException
Initializes the default values for this content handler.

Using the default values from the appinfo node, it's possible to have more sophisticated logic for generating the defaults then just using the XML schema "default" attribute.

Parameters:
root - the "defaults" element from the appinfo node of the XML content definition
contentDefinition - the content definition the default values belong to
Throws:
CmsXmlException - if something goes wrong

initLayouts

protected void initLayouts(org.dom4j.Element root,
                           CmsXmlContentDefinition contentDefinition)
                    throws CmsXmlException
Initializes the layout for this content handler.

Unless otherwise instructed, the editor uses one specific GUI widget for each XML value schema type. For example, for a CmsXmlStringValue the default widget is the CmsInputWidget. However, certain values can also use more then one widget, for example you may also use a CmsCheckboxWidget for a String value, and as a result the Strings possible values would be eithe "false" or "true", but nevertheless be a String.

The widget to use can further be controlled using the widget attribute. You can specify either a valid widget alias such as StringWidget, or the name of a Java class that implements I_CmsWidget.

Configuration options to the widget can be passed using the configuration attribute. You can specify any String as configuration. This String is then passed to the widget during initialization. It's up to the individual widget implementation to interpret this configuration String.

Parameters:
root - the "layouts" element from the appinfo node of the XML content definition
contentDefinition - the content definition the layout belongs to
Throws:
CmsXmlException - if something goes wrong

initMappings

protected void initMappings(org.dom4j.Element root,
                            CmsXmlContentDefinition contentDefinition)
                     throws CmsXmlException
Initializes the element mappings for this content handler.

Element mappings allow storing values from the XML content in other locations. For example, if you have an element called "Title", it's likely a good idea to store the value of this element also in the "Title" property of a XML content resource.

Parameters:
root - the "mappings" element from the appinfo node of the XML content definition
contentDefinition - the content definition the mappings belong to
Throws:
CmsXmlException - if something goes wrong

initModelFolder

protected void initModelFolder(org.dom4j.Element root,
                               CmsXmlContentDefinition contentDefinition)
                        throws CmsXmlException
Initializes the folder containing the model file(s) for this content handler.

Parameters:
root - the "modelfolder" element from the appinfo node of the XML content definition
contentDefinition - the content definition the model folder belongs to
Throws:
CmsXmlException - if something goes wrong

initPreview

protected void initPreview(org.dom4j.Element root,
                           CmsXmlContentDefinition contentDefinition)
                    throws CmsXmlException
Initializes the preview location for this content handler.

Parameters:
root - the "preview" element from the appinfo node of the XML content definition
contentDefinition - the content definition the validation rules belong to
Throws:
CmsXmlException - if something goes wrong

initRelations

protected void initRelations(org.dom4j.Element root,
                             CmsXmlContentDefinition contentDefinition)
                      throws CmsXmlException
Initializes the relation configuration for this content handler.

OpenCms performs link checks for all OPTIONAL links defined in XML content values of type OpenCmsVfsFile. However, for most projects in the real world a more fine-grained control over the link check process is required. For these cases, individual relation behavior can be defined for the appinfo node.

Additional here can be defined an optional type for the relations, for instance.

Parameters:
root - the "relations" element from the appinfo node of the XML content definition
contentDefinition - the content definition the check rules belong to
Throws:
CmsXmlException - if something goes wrong

initResourceBundle

protected void initResourceBundle(org.dom4j.Element root,
                                  CmsXmlContentDefinition contentDefinition)
                           throws CmsXmlException
Initializes the resource bundle to use for localized messages in this content handler.

Parameters:
root - the "resourcebundle" element from the appinfo node of the XML content definition
contentDefinition - the content definition the validation rules belong to
Throws:
CmsXmlException - if something goes wrong

initSearchSettings

protected void initSearchSettings(org.dom4j.Element root,
                                  CmsXmlContentDefinition contentDefinition)
                           throws CmsXmlException
Initializes the search exclusions values for this content handler.

For the full text search, the value of all elements in one locale of the XML content are combined to one big text, which is referred to as the "content" in the context of the full text search. With this option, it is possible to hide certain elements from this "content" that does not make sense to include in the full text search.

Parameters:
root - the "searchsettings" element from the appinfo node of the XML content definition
contentDefinition - the content definition the default values belong to
Throws:
CmsXmlException - if something goes wrong

initTabs

protected void initTabs(org.dom4j.Element root,
                        CmsXmlContentDefinition contentDefinition)
Initializes the tabs for this content handler.

.

Parameters:
root - the "tabs" element from the appinfo node of the XML content definition
contentDefinition - the content definition the tabs belong to

getTabs

public java.util.List<CmsXmlContentTab> getTabs()
Description copied from interface: I_CmsXmlContentHandler
Returns the tabs to be displayed in the editor.

Specified by:
getTabs in interface I_CmsXmlContentHandler
Returns:
the tabs to be displayed in the editor
See Also:
I_CmsXmlContentHandler.getTabs()

initValidationRules

protected void initValidationRules(org.dom4j.Element root,
                                   CmsXmlContentDefinition contentDefinition)
                            throws CmsXmlException
Initializes the validation rules this content handler.

OpenCms always performs XML schema validation for all XML contents. However, for most projects in the real world a more fine-grained control over the validation process is required. For these cases, individual validation rules can be defined for the appinfo node.

Parameters:
root - the "validationrules" element from the appinfo node of the XML content definition
contentDefinition - the content definition the validation rules belong to
Throws:
CmsXmlException - if something goes wrong

isInvalidateParent

protected boolean isInvalidateParent(java.lang.String xpath)
Returns the is-invalidate-parent flag for the given xpath.

Parameters:
xpath - the path to get the check rule for
Returns:
the configured is-invalidate-parent flag for the given xpath

key

protected java.lang.String key(java.lang.String keyName,
                               java.util.Locale locale)
Returns the localized resource string for a given message key according to the configured resource bundle of this content handler.

If the key was not found in the configured bundle, or no bundle is configured for this content handler, the return value is "??? " + keyName + " ???".

Parameters:
keyName - the key for the desired string
locale - the locale to get the key from
Returns:
the resource string for the given key
See Also:
CmsMessages.formatUnknownKey(String), CmsMessages.isUnknownKey(String)

removeEmptyMappings

protected void removeEmptyMappings(CmsObject cms,
                                   CmsXmlContent content)
                            throws CmsException
Removes property values on resources for non-existing, optional elements.

Parameters:
cms - the current users OpenCms context
content - the XML content to remove the property values for
Throws:
CmsException - in case of read/write errors accessing the OpenCms VFS

validateAppinfoElement

protected void validateAppinfoElement(org.dom4j.Element appinfoElement)
                               throws CmsXmlException
Validates if the given appinfo element node from the XML content definition schema is valid according the the capabilities of this content handler.

Parameters:
appinfoElement - the appinfo element node to validate
Throws:
CmsXmlException - in case the element validation fails

validateCategories

protected CmsXmlContentErrorHandler validateCategories(CmsObject cms,
                                                       I_CmsXmlContentValue value,
                                                       CmsXmlContentErrorHandler errorHandler)
The errorHandler parameter is optional, if null is given a new error handler instance must be created.

Parameters:
cms - the current OpenCms user context
value - the value to resolve the validation rules for
errorHandler - (optional) an error handler instance that contains previous error or warnings
Returns:
an error handler that contains all errors and warnings currently found

validateLink

protected boolean validateLink(CmsObject cms,
                               I_CmsXmlContentValue value,
                               CmsXmlContentErrorHandler errorHandler)
Validates the given rules against the given value.

Parameters:
cms - the current users OpenCms context
value - the value to validate
errorHandler - the error handler to use in case errors or warnings are detected
Returns:
if a broken link has been found

validateValue

protected CmsXmlContentErrorHandler validateValue(CmsObject cms,
                                                  I_CmsXmlContentValue value,
                                                  CmsXmlContentErrorHandler errorHandler,
                                                  java.util.Map<java.lang.String,java.lang.String> rules,
                                                  boolean isWarning)
Validates the given rules against the given value.

Parameters:
cms - the current users OpenCms context
value - the value to validate
errorHandler - the error handler to use in case errors or warnings are detected
rules - the rules to validate the value against
isWarning - if true, this validation should be stored as a warning, otherwise as an error
Returns:
the updated error handler

validateValue

protected CmsXmlContentErrorHandler validateValue(CmsObject cms,
                                                  I_CmsXmlContentValue value,
                                                  java.lang.String valueStr,
                                                  CmsXmlContentErrorHandler errorHandler,
                                                  boolean isWarning)
Checks the default XML schema validation rules.

These rules should only be tested if this is not a test for warnings.

Parameters:
cms - the current users OpenCms context
value - the value to validate
valueStr - the string value of the given value
errorHandler - the error handler to use in case errors or warnings are detected
isWarning - if true, this validation should be stored as a warning, otherwise as an error
Returns:
the updated error handler

writeCategories

protected CmsFile writeCategories(CmsObject cms,
                                  CmsFile file,
                                  CmsXmlContent content)
                           throws CmsException
Writes the categories if a category widget is present.

Parameters:
cms - the cms context
file - the file
content - the xml content to set the categories for
Returns:
the perhaps modified file
Throws:
CmsException - if something goes wrong