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, CmsXmlContainerPageHandler, CmsXmlDynamicFunctionHandler, CmsXmlGroupContainerHandler, TestXmlContentHandler

public class CmsDefaultXmlContentHandler
extends 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

Field Summary
static String APPINFO_APPINFO
          Constant for the "appinfo" element name itself.
static String APPINFO_ATTR_COLLAPSE
          Constant for the "collapse" appinfo attribute name.
static String APPINFO_ATTR_CONFIGURATION
          Constant for the "configuration" appinfo attribute name.
static String APPINFO_ATTR_DEFAULT
          Constant for the "default" appinfo attribute name.
static String APPINFO_ATTR_DESCRIPTION
          Constant for the "description" appinfo attribute name.
static String APPINFO_ATTR_ELEMENT
          Constant for the "element" appinfo attribute name.
static String APPINFO_ATTR_ERROR
          Constant for the "error" appinfo attribute name.
static String APPINFO_ATTR_INVALIDATE
          Constant for the "invalidate" appinfo attribute name.
static String APPINFO_ATTR_KEY
          Constant for the "key" appinfo attribute name.
static String APPINFO_ATTR_LOCALE
          Constant for the "locale" appinfo attribute name.
static String APPINFO_ATTR_MAPTO
          Constant for the "mapto" appinfo attribute name.
static String APPINFO_ATTR_MAXWIDTH
          Constant for the "maxwidth" appinfo attribute name.
static String APPINFO_ATTR_MESSAGE
          Constant for the "message" appinfo attribute name.
static String APPINFO_ATTR_MINWIDTH
          Constant for the "minwidth" appinfo attribute name.
static String APPINFO_ATTR_NAME
          Constant for the "name" appinfo attribute name.
static String APPINFO_ATTR_NICE_NAME
          Constant for the "nice-name" appinfo attribute name.
static String APPINFO_ATTR_PREVIEW
          Constant for the "preview" appinfo attribute name.
static String APPINFO_ATTR_REGEX
          Constant for the "regex" appinfo attribute name.
static String APPINFO_ATTR_RULE_REGEX
          Constant for the "rule-regex" appinfo attribute name.
static String APPINFO_ATTR_RULE_TYPE
          Constant for the "rule-type" appinfo attribute name.
static String APPINFO_ATTR_SEARCHCONTENT
          Constant for the "searchcontent" appinfo attribute name.
static String APPINFO_ATTR_SELECT_INHERIT
          Constant for the "select-inherit" appinfo attribute name.
static String APPINFO_ATTR_TYPE
          Constant for the "type" appinfo attribute name.
static String APPINFO_ATTR_TYPE_NODE
          Constant for the "node" appinfo attribute value.
static String APPINFO_ATTR_TYPE_PARENT
          Constant for the "parent" appinfo attribute value.
static String APPINFO_ATTR_TYPE_WARNING
          Constant for the "warning" appinfo attribute value.
static String APPINFO_ATTR_URI
          Constant for the "uri" appinfo attribute name.
static String APPINFO_ATTR_USEALL
          Constant for the "useall" appinfo attribute name.
static String APPINFO_ATTR_VALUE
          Constant for the "value" appinfo attribute name.
static String APPINFO_ATTR_WIDGET
          Constant for the "widget" appinfo attribute name.
static String APPINFO_ATTR_WIDGET_CONFIG
          Constant for the "widget-config" appinfo attribute name.
static String APPINFO_ATTRIBUTE_TYPE_CSS
          Constant for formatter include resource type 'CSS'.
static String APPINFO_ATTRIBUTE_TYPE_JAVASCRIPT
          Constant for formatter include resource type 'JAVASCRIPT'.
static String APPINFO_BUNDLE
          Constant for the "bundle" appinfo element name.
static String APPINFO_DEFAULT
          Constant for the "default" appinfo element name.
static String APPINFO_DEFAULTS
          Constant for the "defaults" appinfo element name.
static String APPINFO_FORMATTER
          Constant for the "formatter" appinfo element name.
static String APPINFO_FORMATTERS
          Constant for the "formatters" appinfo element name.
static String APPINFO_HEAD_INCLUDE
          Constant for the "headinclude" appinfo element name.
static String APPINFO_HEAD_INCLUDES
          Constant for the "headincludes" appinfo element name.
static String APPINFO_LAYOUT
          Constant for the "layout" appinfo element name.
static String APPINFO_LAYOUTS
          Constant for the "layouts" appinfo element name.
static String APPINFO_MAPPING
          Constant for the "mapping" appinfo element name.
static String APPINFO_MAPPINGS
          Constant for the "mappings" appinfo element name.
static String APPINFO_MODELFOLDER
          Constant for the "modelfolder" appinfo element name.
static String APPINFO_PREVIEW
          Constant for the "preview" appinfo element name.
static String APPINFO_PROPERTYBUNDLE
          Constant for the "propertybundle" appinfo element name.
static String APPINFO_RELATION
          Constant for the "relation" appinfo element name.
static String APPINFO_RELATIONS
          Constant for the "relations" appinfo element name.
static String APPINFO_RESOURCE
          Constant for the "resource" appinfo element name.
static String APPINFO_RESOURCEBUNDLE
          Constant for the "resourcebundle" appinfo element name.
static String APPINFO_RESOURCEBUNDLES
          Constant for the "resourcebundles" appinfo element name.
static String APPINFO_RULE
          Constant for the "rule" appinfo element name.
static String APPINFO_SCHEMA_FILE
          The file where the default appinfo schema is located.
static String APPINFO_SCHEMA_FILE_TYPES
          The file where the default appinfo schema types are located.
static String APPINFO_SCHEMA_SYSTEM_ID
          The XML system id for the default appinfo schema types.
static String APPINFO_SCHEMA_TYPES_SYSTEM_ID
          The XML system id for the default appinfo schema types.
static String APPINFO_SEARCHSETTING
          Constant for the "searchsetting" appinfo element name.
static String APPINFO_SEARCHSETTINGS
          Constant for the "searchsettings" appinfo element name.
static String APPINFO_SETTING
          Constant for the "setting" appinfo element name.
static String APPINFO_SETTINGS
          Constant for the "settings" appinfo element name.
static String APPINFO_TAB
          Constant for the "tab" appinfo element name.
static String APPINFO_TABS
          Constant for the "tabs" appinfo element name.
static String APPINFO_VALIDATIONRULE
          Constant for the "validationrule" appinfo element name.
static String APPINFO_VALIDATIONRULES
          Constant for the "validationrules" appinfo element name.
static String APPINFO_XMLBUNDLE
          Constant for the "xmlbundle" appinfo element name.
static String ATTRIBUTE_INCLUDE_TYPE_CSS
          Constant for head include type attribute: CSS.
static String ATTRIBUTE_INCLUDE_TYPE_JAVASCRIPT
          Constant for head include type attribute: java-script.
protected  Map<String,String> m_configurationValues
          The configuration values for the element widgets (as defined in the annotations).
protected  Set<String> m_cssHeadIncludes
          The CSS resources to include into the html-page head.
protected  Map<String,String> m_defaultValues
          The default values for the elements (as defined in the annotations).
protected  Map<String,List<String>> m_elementMappings
          The element mappings (as defined in the annotations).
protected  Map<String,I_CmsWidget> m_elementWidgets
          The widgets used for the elements (as defined in the annotations).
protected  CmsFormatterConfiguration m_formatterConfiguration
          The formatter configuration.
protected  List<CmsFormatterBean> m_formatters
          The list of formatters from the XSD.
protected  Set<String> m_jsHeadIncludes
          The java-script resources to include into the html-page head.
protected  List<String> m_messageBundleNames
          The resource bundle name to be used for localization of this content handler.
protected  String m_modelFolder
          The folder containing the model file(s) for the content.
protected  String m_previewLocation
          The preview location (as defined in the annotations).
protected  Map<String,Boolean> m_relationChecks
          The relation check rules.
protected  Map<String,CmsRelationType> m_relations
          The relation check rules.
protected  Map<String,Boolean> m_searchSettings
          The search settings.
protected  Map<String,CmsXmlContentProperty> m_settings
          The configured settings for the formatters (as defined in the annotations).
protected  List<CmsXmlContentTab> m_tabs
          The configured tabs.
protected  List<String> m_titleMappings
          The list of mappings to the "Title" property.
protected  Map<String,String> m_validationErrorMessages
          The messages for the error validation rules.
protected  Map<String,String> m_validationErrorRules
          The validation rules that cause an error (as defined in the annotations).
protected  Map<String,String> m_validationWarningMessages
          The messages for the warning validation rules.
protected  Map<String,String> m_validationWarningRules
          The validation rules that cause a warning (as defined in the annotations).
static String MACRO_PREVIEW_TEMPFILE
          Macro for resolving the preview URI.
protected static String MESSAGE_VALIDATION_DEFAULT_ERROR
          Default message for validation errors.
protected static String MESSAGE_VALIDATION_DEFAULT_WARNING
          Default message for validation warnings.
 
Fields inherited from interface org.opencms.xml.content.I_CmsXmlContentHandler
ATTRIBUTES, MAPTO_ATTRIBUTE, MAPTO_PERMISSION, MAPTO_PROPERTY, MAPTO_PROPERTY_INDIVIDUAL, MAPTO_PROPERTY_LIST, MAPTO_PROPERTY_LIST_INDIVIDUAL, MAPTO_PROPERTY_LIST_SHARED, MAPTO_PROPERTY_SHARED, MAPTO_URLNAME
 
Constructor Summary
CmsDefaultXmlContentHandler()
          Creates a new instance of the default XML content handler.
 
Method Summary
protected  void addCheckRule(CmsXmlContentDefinition contentDefinition, String elementName, String invalidate, String type)
          Adds a check rule for a specified element.
protected  void addConfiguration(CmsXmlContentDefinition contentDefinition, String elementName, String configurationValue)
          Adds a configuration value for an element widget.
protected  void addDefault(CmsXmlContentDefinition contentDefinition, String elementName, String defaultValue)
          Adds a default value for an element.
protected  void addDefaultCheckRules(CmsXmlContentDefinition rootContentDefinition, I_CmsXmlSchemaType schemaType, String elementPath)
          Adds all needed default check rules recursively for the given schema type.
protected  void addMapping(CmsXmlContentDefinition contentDefinition, String elementName, String mapping)
          Adds an element mapping.
protected  void addSearchSetting(CmsXmlContentDefinition contentDefinition, String elementName, Boolean value)
          Adds a search setting for an element.
protected  void addValidationRule(CmsXmlContentDefinition contentDefinition, String elementName, String regex, String message, boolean isWarning)
          Adds a validation rule for a specified element.
protected  void addWidget(CmsXmlContentDefinition contentDefinition, String elementName, String widgetClassOrAlias)
          Adds a GUI widget for a specified element.
 String getConfiguration(I_CmsXmlSchemaType type)
          Returns the configuration String value for the widget used to edit the given XML content schema type.
 Set<String> getCSSHeadIncludes()
          Returns the resource-independent CSS resources to include into the html-page head.
 Set<String> getCSSHeadIncludes(CmsObject cms, CmsResource resource)
          Returns all the CSS resources to include into the html-page head.
 String getDefault(CmsObject cms, I_CmsXmlContentValue value, Locale locale)
          Returns the default String value for the given XML content schema type object in the given XML content.
 CmsFormatterConfiguration getFormatterConfiguration(CmsObject cms, CmsResource resource)
          Returns the container page element formatter configuration for a given resource.
 Set<String> getJSHeadIncludes()
          Returns the resource-independent javascript resources to include into the html-page head.
 Set<String> getJSHeadIncludes(CmsObject cms, CmsResource resource)
          Returns all the javascript resources to include into the html-page head.
protected  Locale getLocaleForResource(CmsObject cms, String resource)
          Returns the default locale in the content of the given resource.
 List<String> getMappings(String elementName)
          Returns the all mappings defined for the given element xpath.
 CmsMessages getMessages(Locale locale)
          Returns the CmsMessages that are used to resolve localized keys for the given locale in this content handler.
 String getModelFolder()
          Returns the folder name that contains eventual XML content model files to use for this resource type.
 String getPreview(CmsObject cms, CmsXmlContent content, String resourcename)
          Returns the preview URI for the given XML content value object to be displayed in the editor.
protected  String getReferencePath(CmsObject cms, I_CmsXmlContentValue value)
          Returns the category reference path for the given value.
 CmsRelationType getRelationType(I_CmsXmlContentValue value)
          Deprecated. 
 CmsRelationType getRelationType(String xpath)
          Returns the relation type for the given path.
 Map<String,CmsXmlContentProperty> getSettings(CmsObject cms, CmsResource resource)
          Returns the element settings defined for the container page formatters.
 List<CmsXmlContentTab> getTabs()
          Returns the tabs to be displayed in the editor.
 String getTitleMapping(CmsObject cms, CmsXmlContent document, Locale locale)
          Returns the "Title" mapping set for the given XML content document in the given Locale.
protected  String getValidationMessage(CmsObject cms, I_CmsXmlContentValue value, String regex, 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(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the default values for this content handler.
protected  void initFormatters(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the formatters for this content handler.
protected  void initHeadIncludes(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the head includes for this content handler.
 void initialize(Element appInfoElement, CmsXmlContentDefinition contentDefinition)
          Initializes this content handler for the given XML content definition by analyzing the "appinfo" node.
protected  void initLayouts(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the layout for this content handler.
protected  void initMappings(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the element mappings for this content handler.
protected  void initModelFolder(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the folder containing the model file(s) for this content handler.
protected  void initPreview(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the preview location for this content handler.
protected  void initRelations(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the relation configuration for this content handler.
protected  void initResourceBundle(Element root, CmsXmlContentDefinition contentDefinition, boolean single)
          Initializes the resource bundle to use for localized messages in this content handler.
protected  void initSearchSettings(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the search exclusions values for this content handler.
protected  void initSettings(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the element settings for this content handler.
protected  void initTabs(Element root, CmsXmlContentDefinition contentDefinition)
          Initializes the tabs for this content handler.
protected  void initValidationRules(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(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  String key(String keyName, 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(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, Map<String,String> rules, boolean isWarning)
          Validates the given rules against the given value.
protected  CmsXmlContentErrorHandler validateValue(CmsObject cms, I_CmsXmlContentValue value, 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 String APPINFO_APPINFO
Constant for the "appinfo" element name itself.

See Also:
Constant Field Values

APPINFO_ATTR_COLLAPSE

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

See Also:
Constant Field Values

APPINFO_ATTR_CONFIGURATION

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

See Also:
Constant Field Values

APPINFO_ATTR_DEFAULT

public static final String APPINFO_ATTR_DEFAULT
Constant for the "default" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_DESCRIPTION

public static final String APPINFO_ATTR_DESCRIPTION
Constant for the "description" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_ELEMENT

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

See Also:
Constant Field Values

APPINFO_ATTR_ERROR

public static final String APPINFO_ATTR_ERROR
Constant for the "error" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_INVALIDATE

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

See Also:
Constant Field Values

APPINFO_ATTR_KEY

public static final String APPINFO_ATTR_KEY
Constant for the "key" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_LOCALE

public static final String APPINFO_ATTR_LOCALE
Constant for the "locale" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_MAPTO

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

See Also:
Constant Field Values

APPINFO_ATTR_MAXWIDTH

public static final String APPINFO_ATTR_MAXWIDTH
Constant for the "maxwidth" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_MESSAGE

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

See Also:
Constant Field Values

APPINFO_ATTR_MINWIDTH

public static final String APPINFO_ATTR_MINWIDTH
Constant for the "minwidth" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_NAME

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

See Also:
Constant Field Values

APPINFO_ATTR_NICE_NAME

public static final String APPINFO_ATTR_NICE_NAME
Constant for the "nice-name" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_PREVIEW

public static final String APPINFO_ATTR_PREVIEW
Constant for the "preview" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_REGEX

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

See Also:
Constant Field Values

APPINFO_ATTR_RULE_REGEX

public static final String APPINFO_ATTR_RULE_REGEX
Constant for the "rule-regex" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_RULE_TYPE

public static final String APPINFO_ATTR_RULE_TYPE
Constant for the "rule-type" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_SEARCHCONTENT

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

See Also:
Constant Field Values

APPINFO_ATTR_SELECT_INHERIT

public static final String APPINFO_ATTR_SELECT_INHERIT
Constant for the "select-inherit" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTR_TYPE

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

See Also:
Constant Field Values

APPINFO_ATTR_TYPE_NODE

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

See Also:
Constant Field Values

APPINFO_ATTR_TYPE_PARENT

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

See Also:
Constant Field Values

APPINFO_ATTR_TYPE_WARNING

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

See Also:
Constant Field Values

APPINFO_ATTR_URI

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

See Also:
Constant Field Values

APPINFO_ATTR_USEALL

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

See Also:
Constant Field Values

APPINFO_ATTR_VALUE

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

See Also:
Constant Field Values

APPINFO_ATTR_WIDGET

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

See Also:
Constant Field Values

APPINFO_ATTR_WIDGET_CONFIG

public static final String APPINFO_ATTR_WIDGET_CONFIG
Constant for the "widget-config" appinfo attribute name.

See Also:
Constant Field Values

APPINFO_ATTRIBUTE_TYPE_CSS

public static final String APPINFO_ATTRIBUTE_TYPE_CSS
Constant for formatter include resource type 'CSS'.

See Also:
Constant Field Values

APPINFO_ATTRIBUTE_TYPE_JAVASCRIPT

public static final String APPINFO_ATTRIBUTE_TYPE_JAVASCRIPT
Constant for formatter include resource type 'JAVASCRIPT'.

See Also:
Constant Field Values

APPINFO_BUNDLE

public static final String APPINFO_BUNDLE
Constant for the "bundle" appinfo element name.

See Also:
Constant Field Values

APPINFO_DEFAULT

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

See Also:
Constant Field Values

APPINFO_DEFAULTS

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

See Also:
Constant Field Values

APPINFO_FORMATTER

public static final String APPINFO_FORMATTER
Constant for the "formatter" appinfo element name.

See Also:
Constant Field Values

APPINFO_FORMATTERS

public static final String APPINFO_FORMATTERS
Constant for the "formatters" appinfo element name.

See Also:
Constant Field Values

APPINFO_HEAD_INCLUDE

public static final String APPINFO_HEAD_INCLUDE
Constant for the "headinclude" appinfo element name.

See Also:
Constant Field Values

APPINFO_HEAD_INCLUDES

public static final String APPINFO_HEAD_INCLUDES
Constant for the "headincludes" appinfo element name.

See Also:
Constant Field Values

APPINFO_LAYOUT

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

See Also:
Constant Field Values

APPINFO_LAYOUTS

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

See Also:
Constant Field Values

APPINFO_MAPPING

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

See Also:
Constant Field Values

APPINFO_MAPPINGS

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

See Also:
Constant Field Values

APPINFO_MODELFOLDER

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

See Also:
Constant Field Values

APPINFO_PREVIEW

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

See Also:
Constant Field Values

APPINFO_PROPERTYBUNDLE

public static final String APPINFO_PROPERTYBUNDLE
Constant for the "propertybundle" appinfo element name.

See Also:
Constant Field Values

APPINFO_RELATION

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

See Also:
Constant Field Values

APPINFO_RELATIONS

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

See Also:
Constant Field Values

APPINFO_RESOURCE

public static final String APPINFO_RESOURCE
Constant for the "resource" appinfo element name.

See Also:
Constant Field Values

APPINFO_RESOURCEBUNDLE

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

See Also:
Constant Field Values

APPINFO_RESOURCEBUNDLES

public static final String APPINFO_RESOURCEBUNDLES
Constant for the "resourcebundles" appinfo element name.

See Also:
Constant Field Values

APPINFO_RULE

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

See Also:
Constant Field Values

APPINFO_SCHEMA_FILE

public static final 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 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 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 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 String APPINFO_SEARCHSETTING
Constant for the "searchsetting" appinfo element name.

See Also:
Constant Field Values

APPINFO_SEARCHSETTINGS

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

See Also:
Constant Field Values

APPINFO_SETTING

public static final String APPINFO_SETTING
Constant for the "setting" appinfo element name.

See Also:
Constant Field Values

APPINFO_SETTINGS

public static final String APPINFO_SETTINGS
Constant for the "settings" appinfo element name.

See Also:
Constant Field Values

APPINFO_TAB

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

See Also:
Constant Field Values

APPINFO_TABS

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

See Also:
Constant Field Values

APPINFO_VALIDATIONRULE

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

See Also:
Constant Field Values

APPINFO_VALIDATIONRULES

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

See Also:
Constant Field Values

APPINFO_XMLBUNDLE

public static final String APPINFO_XMLBUNDLE
Constant for the "xmlbundle" appinfo element name.

See Also:
Constant Field Values

ATTRIBUTE_INCLUDE_TYPE_CSS

public static final String ATTRIBUTE_INCLUDE_TYPE_CSS
Constant for head include type attribute: CSS.

See Also:
Constant Field Values

ATTRIBUTE_INCLUDE_TYPE_JAVASCRIPT

public static final String ATTRIBUTE_INCLUDE_TYPE_JAVASCRIPT
Constant for head include type attribute: java-script.

See Also:
Constant Field Values

MACRO_PREVIEW_TEMPFILE

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

See Also:
Constant Field Values

MESSAGE_VALIDATION_DEFAULT_ERROR

protected static final String MESSAGE_VALIDATION_DEFAULT_ERROR
Default message for validation errors.

See Also:
Constant Field Values

MESSAGE_VALIDATION_DEFAULT_WARNING

protected static final String MESSAGE_VALIDATION_DEFAULT_WARNING
Default message for validation warnings.

See Also:
Constant Field Values

m_configurationValues

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


m_cssHeadIncludes

protected Set<String> m_cssHeadIncludes
The CSS resources to include into the html-page head.


m_defaultValues

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


m_elementMappings

protected Map<String,List<String>> m_elementMappings
The element mappings (as defined in the annotations).


m_elementWidgets

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


m_formatterConfiguration

protected CmsFormatterConfiguration m_formatterConfiguration
The formatter configuration.


m_formatters

protected List<CmsFormatterBean> m_formatters
The list of formatters from the XSD.


m_jsHeadIncludes

protected Set<String> m_jsHeadIncludes
The java-script resources to include into the html-page head.


m_messageBundleNames

protected List<String> m_messageBundleNames
The resource bundle name to be used for localization of this content handler.


m_modelFolder

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


m_previewLocation

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


m_relationChecks

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


m_relations

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


m_searchSettings

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


m_settings

protected Map<String,CmsXmlContentProperty> m_settings
The configured settings for the formatters (as defined in the annotations).


m_tabs

protected List<CmsXmlContentTab> m_tabs
The configured tabs.


m_titleMappings

protected List<String> m_titleMappings
The list of mappings to the "Title" property.


m_validationErrorMessages

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


m_validationErrorRules

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


m_validationWarningMessages

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


m_validationWarningRules

protected Map<String,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 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)

getCSSHeadIncludes

public Set<String> getCSSHeadIncludes()
Description copied from interface: I_CmsXmlContentHandler
Returns the resource-independent CSS resources to include into the html-page head.

Specified by:
getCSSHeadIncludes in interface I_CmsXmlContentHandler
Returns:
the CSS resources to include into the html-page head
See Also:
I_CmsXmlContentHandler.getCSSHeadIncludes()

getCSSHeadIncludes

public Set<String> getCSSHeadIncludes(CmsObject cms,
                                      CmsResource resource)
                               throws CmsException
Description copied from interface: I_CmsXmlContentHandler
Returns all the CSS resources to include into the html-page head.

Specified by:
getCSSHeadIncludes in interface I_CmsXmlContentHandler
Parameters:
cms - the current CMS context
resource - the resource from which to get the head includes
Returns:
the CSS resources to include into the html-page head
Throws:
CmsException - if something goes wrong
See Also:
I_CmsXmlContentHandler.getCSSHeadIncludes(org.opencms.file.CmsObject, org.opencms.file.CmsResource)

getDefault

public String getDefault(CmsObject cms,
                         I_CmsXmlContentValue value,
                         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)

getFormatterConfiguration

public CmsFormatterConfiguration getFormatterConfiguration(CmsObject cms,
                                                           CmsResource resource)
Description copied from interface: I_CmsXmlContentHandler
Returns the container page element formatter configuration for a given resource.

Specified by:
getFormatterConfiguration in interface I_CmsXmlContentHandler
Parameters:
cms - the current users OpenCms context, used for selecting the right project
resource - the resource for which the formatter configuration should be retrieved
Returns:
the container page element formatter configuration for this handler
See Also:
I_CmsXmlContentHandler.getFormatterConfiguration(org.opencms.file.CmsObject, org.opencms.file.CmsResource)

getJSHeadIncludes

public Set<String> getJSHeadIncludes()
Description copied from interface: I_CmsXmlContentHandler
Returns the resource-independent javascript resources to include into the html-page head.

Specified by:
getJSHeadIncludes in interface I_CmsXmlContentHandler
Returns:
the javascript resources to include into the html-page head
See Also:
I_CmsXmlContentHandler.getJSHeadIncludes()

getJSHeadIncludes

public Set<String> getJSHeadIncludes(CmsObject cms,
                                     CmsResource resource)
                              throws CmsException
Description copied from interface: I_CmsXmlContentHandler
Returns all the javascript resources to include into the html-page head.

Specified by:
getJSHeadIncludes in interface I_CmsXmlContentHandler
Parameters:
cms - the current CMS context
resource - the resource for which the head includes should be retrieved
Returns:
the javascript resources to include into the html-page head
Throws:
CmsException - if something goes wrong
See Also:
I_CmsXmlContentHandler.getJSHeadIncludes(org.opencms.file.CmsObject, org.opencms.file.CmsResource)

getMappings

public List<String> getMappings(String elementName)
Returns the all mappings defined for the given element xpath.

Specified by:
getMappings in interface I_CmsXmlContentHandler
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(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 String getModelFolder()
Description copied from interface: I_CmsXmlContentHandler
Returns the folder name that contains eventual XML content model files to use for this resource type.

Specified by:
getModelFolder in interface I_CmsXmlContentHandler
Returns:
the folder name containing eventual XML content master files
See Also:
I_CmsXmlContentHandler.getModelFolder()

getPreview

public String getPreview(CmsObject cms,
                         CmsXmlContent content,
                         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

@Deprecated
public CmsRelationType getRelationType(I_CmsXmlContentValue value)
Deprecated. 

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)

getRelationType

public CmsRelationType getRelationType(String xpath)
Description copied from interface: I_CmsXmlContentHandler
Returns the relation type for the given path.

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

getSettings

public Map<String,CmsXmlContentProperty> getSettings(CmsObject cms,
                                                     CmsResource resource)
Description copied from interface: I_CmsXmlContentHandler
Returns the element settings defined for the container page formatters.

Specified by:
getSettings in interface I_CmsXmlContentHandler
Parameters:
cms - the current CMS context
resource - the resource for which to get the setting definitions
Returns:
the element settings defined for the container page formatters
See Also:
I_CmsXmlContentHandler.getSettings(org.opencms.file.CmsObject, org.opencms.file.CmsResource)

getTabs

public 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()

getTitleMapping

public String getTitleMapping(CmsObject cms,
                              CmsXmlContent document,
                              Locale locale)
Description copied from interface: I_CmsXmlContentHandler
Returns the "Title" mapping set for the given XML content document in the given Locale.

Specified by:
getTitleMapping in interface I_CmsXmlContentHandler
Parameters:
cms - the current OpenCms user context
document - the XML content to get the title mapping for (this must be of a type that uses this handler)
locale - the locale to get the title mapping for
Returns:
the "Title" mapping set for the given XML content document in the given Locale
See Also:
I_CmsXmlContentHandler.getTitleMapping(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, java.util.Locale)

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(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,
                            String elementName,
                            String invalidate,
                            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,
                                String elementName,
                                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,
                          String elementName,
                          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,
                                    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,
                          String elementName,
                          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,
                                String elementName,
                                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,
                                 String elementName,
                                 String regex,
                                 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,
                         String elementName,
                         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 Locale getLocaleForResource(CmsObject cms,
                                      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 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 String getValidationMessage(CmsObject cms,
                                      I_CmsXmlContentValue value,
                                      String regex,
                                      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(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

initFormatters

protected void initFormatters(Element root,
                              CmsXmlContentDefinition contentDefinition)
Initializes the formatters for this content handler.

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

initHeadIncludes

protected void initHeadIncludes(Element root,
                                CmsXmlContentDefinition contentDefinition)
Initializes the head includes for this content handler.

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

initLayouts

protected void initLayouts(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(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(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(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(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(Element root,
                                  CmsXmlContentDefinition contentDefinition,
                                  boolean single)
                           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
single - if true we process the classic sinle line entry, otherwise it's the multiple line setting
Throws:
CmsXmlException - if something goes wrong

initSearchSettings

protected void initSearchSettings(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

initSettings

protected void initSettings(Element root,
                            CmsXmlContentDefinition contentDefinition)
Initializes the element settings for this content handler.

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

initTabs

protected void initTabs(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

initValidationRules

protected void initValidationRules(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(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 String key(String keyName,
                     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(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,
                                                  Map<String,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,
                                                  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