| java.lang.Object org.opencms.xml.content.CmsDefaultXmlContentHandler
All known Subclasses: com.alkacon.opencms.registration.CmsProfileXmlContentHandler, com.alkacon.opencms.registration.CmsRegistrationXmlContentHandler, com.alkacon.opencms.newsletter.CmsNewsletterXmlContentHandler, com.alkacon.opencms.feeder.CmsFeedXmlContentHandler, org.opencms.frontend.templateone.modules.CmsLayoutXmlContentHandler,
CmsDefaultXmlContentHandler | public class CmsDefaultXmlContentHandler implements I_CmsXmlContentHandler(Code) | | Default implementation for the XML content handler, will be used by all XML contents that do not
provide their own handler.
author: Alexander Kandzior author: Michael Moossen version: $Revision: 1.58 $ since: 6.0.0 |
Method Summary | |
protected void | addCheckRule(CmsXmlContentDefinition contentDefinition, String elementName, String invalidate, String type) | protected void | addConfiguration(CmsXmlContentDefinition contentDefinition, String elementName, String configurationValue) | protected void | addDefault(CmsXmlContentDefinition contentDefinition, String elementName, String defaultValue) | protected void | addDefaultCheckRules(CmsXmlContentDefinition rootContentDefinition, I_CmsXmlSchemaType schemaType, String elementPath) | protected void | addMapping(CmsXmlContentDefinition contentDefinition, String elementName, String mapping) | protected void | addSearchSetting(CmsXmlContentDefinition contentDefinition, String elementName, Boolean value) | protected void | addValidationRule(CmsXmlContentDefinition contentDefinition, String elementName, String regex, String message, boolean isWarning) | protected void | addWidget(CmsXmlContentDefinition contentDefinition, String elementName, String widgetClassOrAlias) | public String | getConfiguration(I_CmsXmlSchemaType type) | public String | getDefault(CmsObject cms, I_CmsXmlContentValue value, Locale locale) | public String | getMapping(String elementName) | public String[] | getMappings(String elementName) | public CmsMessages | getMessages(Locale locale) | public String | getModelFolder(CmsObject cms, String currentFolder) | public String | getPreview(CmsObject cms, CmsXmlContent content, String resourcename) | public CmsRelationType | getRelationType(I_CmsXmlContentValue value) | protected String | getValidationMessage(CmsObject cms, I_CmsXmlContentValue value, String regex, String valueStr, boolean matchResult, boolean isWarning) | public I_CmsWidget | getWidget(I_CmsXmlContentValue value) | protected void | init() | protected void | initDefaultValues(Element root, CmsXmlContentDefinition contentDefinition) | protected void | initLayouts(Element root, CmsXmlContentDefinition contentDefinition) Initializes the layout for this content handler.
Unless otherwise instructed, the editor uses one specific GUI widget for each
XML value schema type. | protected void | initMappings(Element root, CmsXmlContentDefinition contentDefinition) Initializes the element mappings for this content handler.
Element mappings allow storing values from the XML content in other locations. | protected void | initModelFolder(Element root, CmsXmlContentDefinition contentDefinition) | protected void | initPreview(Element root, CmsXmlContentDefinition contentDefinition) | protected void | initRelations(Element root, CmsXmlContentDefinition contentDefinition) Initializes the relation configuration for this content handler.
OpenCms performs link checks for all OPTIONAL links defined in XML content values of type
OpenCmsVfsFile. | protected void | initResourceBundle(Element root, CmsXmlContentDefinition contentDefinition) | protected void | initSearchSettings(Element root, CmsXmlContentDefinition contentDefinition) 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. | protected void | initValidationRules(Element root, CmsXmlContentDefinition contentDefinition) Initializes the validation rules this content handler.
OpenCms always performs XML schema validation for all XML contents. | public synchronized void | initialize(Element appInfoElement, CmsXmlContentDefinition contentDefinition) | public void | invalidateBrokenLinks(CmsObject cms, CmsXmlContent document) | protected boolean | isInvalidateParent(String xpath) | public boolean | isSearchable(I_CmsXmlContentValue value) | protected String | key(String keyName, Locale locale) | public CmsXmlContent | prepareForUse(CmsObject cms, CmsXmlContent content) | public CmsFile | prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file) | protected void | removeEmptyMappings(CmsObject cms, CmsXmlContent content) | public void | resolveMapping(CmsObject cms, CmsXmlContent content, I_CmsXmlContentValue value) | public CmsXmlContentErrorHandler | resolveValidation(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler) | protected void | validateAppinfoElement(Element appinfoElement) | protected boolean | validateLink(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler) | protected CmsXmlContentErrorHandler | validateValue(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler, Map rules, boolean isWarning) | protected CmsXmlContentErrorHandler | validateValue(CmsObject cms, I_CmsXmlContentValue value, String valueStr, CmsXmlContentErrorHandler errorHandler, boolean isWarning) |
APPINFO_APPINFO | final public static String APPINFO_APPINFO(Code) | | Constant for the "appinfo" element name itself.
|
APPINFO_ATTR_CONFIGURATION | final public static String APPINFO_ATTR_CONFIGURATION(Code) | | Constant for the "configuration" appinfo attribute name.
|
APPINFO_ATTR_ELEMENT | final public static String APPINFO_ATTR_ELEMENT(Code) | | Constant for the "element" appinfo attribute name.
|
APPINFO_ATTR_INVALIDATE | final public static String APPINFO_ATTR_INVALIDATE(Code) | | Constant for the "invalidate" appinfo attribute name.
|
APPINFO_ATTR_MAPTO | final public static String APPINFO_ATTR_MAPTO(Code) | | Constant for the "mapto" appinfo attribute name.
|
APPINFO_ATTR_MESSAGE | final public static String APPINFO_ATTR_MESSAGE(Code) | | Constant for the "message" appinfo attribute name.
|
APPINFO_ATTR_NAME | final public static String APPINFO_ATTR_NAME(Code) | | Constant for the "name" appinfo attribute name.
|
APPINFO_ATTR_REGEX | final public static String APPINFO_ATTR_REGEX(Code) | | Constant for the "regex" appinfo attribute name.
|
APPINFO_ATTR_SEARCHCONTENT | final public static String APPINFO_ATTR_SEARCHCONTENT(Code) | | Constant for the "searchcontent" appinfo attribute name.
|
APPINFO_ATTR_TYPE | final public static String APPINFO_ATTR_TYPE(Code) | | Constant for the "type" appinfo attribute name.
|
APPINFO_ATTR_TYPE_NODE | final public static String APPINFO_ATTR_TYPE_NODE(Code) | | Constant for the "node" appinfo attribute value.
|
APPINFO_ATTR_TYPE_PARENT | final public static String APPINFO_ATTR_TYPE_PARENT(Code) | | Constant for the "parent" appinfo attribute value.
|
APPINFO_ATTR_TYPE_WARNING | final public static String APPINFO_ATTR_TYPE_WARNING(Code) | | Constant for the "warning" appinfo attribute value.
|
APPINFO_ATTR_URI | final public static String APPINFO_ATTR_URI(Code) | | Constant for the "uri" appinfo attribute name.
|
APPINFO_ATTR_VALUE | final public static String APPINFO_ATTR_VALUE(Code) | | Constant for the "value" appinfo attribute name.
|
APPINFO_ATTR_WIDGET | final public static String APPINFO_ATTR_WIDGET(Code) | | Constant for the "widget" appinfo attribute name.
|
APPINFO_DEFAULT | final public static String APPINFO_DEFAULT(Code) | | Constant for the "default" appinfo element name.
|
APPINFO_DEFAULTS | final public static String APPINFO_DEFAULTS(Code) | | Constant for the "defaults" appinfo element name.
|
APPINFO_LAYOUT | final public static String APPINFO_LAYOUT(Code) | | Constant for the "layout" appinfo element name.
|
APPINFO_LAYOUTS | final public static String APPINFO_LAYOUTS(Code) | | Constant for the "layouts" appinfo element name.
|
APPINFO_MAPPING | final public static String APPINFO_MAPPING(Code) | | Constant for the "mapping" appinfo element name.
|
APPINFO_MAPPINGS | final public static String APPINFO_MAPPINGS(Code) | | Constant for the "mappings" appinfo element name.
|
APPINFO_MODELFOLDER | final public static String APPINFO_MODELFOLDER(Code) | | Constant for the "modelfolder" appinfo element name.
|
APPINFO_PREVIEW | final public static String APPINFO_PREVIEW(Code) | | Constant for the "preview" appinfo element name.
|
APPINFO_RELATION | final public static String APPINFO_RELATION(Code) | | Constant for the "relation" appinfo element name.
|
APPINFO_RELATIONS | final public static String APPINFO_RELATIONS(Code) | | Constant for the "relations" appinfo element name.
|
APPINFO_RESOURCEBUNDLE | final public static String APPINFO_RESOURCEBUNDLE(Code) | | Constant for the "searchexclusions" appinfo element name.
|
APPINFO_RULE | final public static String APPINFO_RULE(Code) | | Constant for the "rule" appinfo element name.
|
APPINFO_SCHEMA_FILE | final public static String APPINFO_SCHEMA_FILE(Code) | | The file where the default appinfo schema is located.
|
APPINFO_SCHEMA_FILE_TYPES | final public static String APPINFO_SCHEMA_FILE_TYPES(Code) | | The file where the default appinfo schema types are located.
|
APPINFO_SCHEMA_SYSTEM_ID | final public static String APPINFO_SCHEMA_SYSTEM_ID(Code) | | The XML system id for the default appinfo schema types.
|
APPINFO_SCHEMA_TYPES_SYSTEM_ID | final public static String APPINFO_SCHEMA_TYPES_SYSTEM_ID(Code) | | The XML system id for the default appinfo schema types.
|
APPINFO_SEARCHSETTING | final public static String APPINFO_SEARCHSETTING(Code) | | Constant for the "searchsetting" appinfo element name.
|
APPINFO_SEARCHSETTINGS | final public static String APPINFO_SEARCHSETTINGS(Code) | | Constant for the "searchsettings" appinfo element name.
|
APPINFO_VALIDATIONRULE | final public static String APPINFO_VALIDATIONRULE(Code) | | Constant for the "validationrule" appinfo element name.
|
APPINFO_VALIDATIONRULES | final public static String APPINFO_VALIDATIONRULES(Code) | | Constant for the "validationrules" appinfo element name.
|
MACRO_PREVIEW_TEMPFILE | final public static String MACRO_PREVIEW_TEMPFILE(Code) | | Macro for resolving the preview URI.
|
MESSAGE_VALIDATION_DEFAULT_ERROR | final protected static String MESSAGE_VALIDATION_DEFAULT_ERROR(Code) | | Default message for validation errors.
|
MESSAGE_VALIDATION_DEFAULT_WARNING | final protected static String MESSAGE_VALIDATION_DEFAULT_WARNING(Code) | | Default message for validation warnings.
|
m_configurationValues | protected Map m_configurationValues(Code) | | The configuration values for the element widgets (as defined in the annotations).
|
m_defaultValues | protected Map m_defaultValues(Code) | | The default values for the elements (as defined in the annotations).
|
m_elementMappings | protected Map m_elementMappings(Code) | | The element mappings (as defined in the annotations).
|
m_elementWidgets | protected Map m_elementWidgets(Code) | | The widgets used for the elements (as defined in the annotations).
|
m_messageBundleName | protected String m_messageBundleName(Code) | | The resource bundle name to be used for localization of this content handler.
|
m_modelFolder | protected String m_modelFolder(Code) | | The folder containing the model file(s) for the content.
|
m_previewLocation | protected String m_previewLocation(Code) | | The preview location (as defined in the annotations).
|
m_relations | protected Map m_relations(Code) | | The relation check rules.
|
m_searchSettings | protected Map m_searchSettings(Code) | | The search settings.
|
m_validationErrorMessages | protected Map m_validationErrorMessages(Code) | | The messages for the error validation rules.
|
m_validationErrorRules | protected Map m_validationErrorRules(Code) | | The validation rules that cause an error (as defined in the annotations).
|
m_validationWarningMessages | protected Map m_validationWarningMessages(Code) | | The messages for the warning validation rules.
|
m_validationWarningRules | protected Map m_validationWarningRules(Code) | | The validation rules that cause a warning (as defined in the annotations).
|
CmsDefaultXmlContentHandler | public CmsDefaultXmlContentHandler()(Code) | | Creates a new instance of the default XML content handler.
|
addCheckRule | protected void addCheckRule(CmsXmlContentDefinition contentDefinition, String elementName, String invalidate, String type) throws CmsXmlException(Code) | | Adds a check rule for a specified element.
Parameters: contentDefinition - the XML content definition this XML content handler belongs to Parameters: elementName - the element name to add the rule to Parameters: invalidate - false , to disable link checktrue 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 Parameters: 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(Code) | | Adds a configuration value for an element widget.
Parameters: contentDefinition - the XML content definition this XML content handler belongs to Parameters: elementName - the element name to map Parameters: 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(Code) | | Adds a default value for an element.
Parameters: contentDefinition - the XML content definition this XML content handler belongs to Parameters: elementName - the element name to map Parameters: 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(Code) | | Adds all needed default check rules recursively for the given schema type.
Parameters: rootContentDefinition - the root content definition Parameters: schemaType - the schema type to check Parameters: elementPath - the current element path throws: CmsXmlException - if something goes wrong |
addMapping | protected void addMapping(CmsXmlContentDefinition contentDefinition, String elementName, String mapping) throws CmsXmlException(Code) | | Adds an element mapping.
Parameters: contentDefinition - the XML content definition this XML content handler belongs to Parameters: elementName - the element name to map Parameters: 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(Code) | | Adds a search setting for an element.
Parameters: contentDefinition - the XML content definition this XML content handler belongs to Parameters: elementName - the element name to map Parameters: 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(Code) | | Adds a validation rule for a specified element.
Parameters: contentDefinition - the XML content definition this XML content handler belongs to Parameters: elementName - the element name to add the rule to Parameters: regex - the validation rule regular expression Parameters: message - the message in case validation fails (may be null) Parameters: 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(Code) | | Adds a GUI widget for a specified element.
Parameters: contentDefinition - the XML content definition this XML content handler belongs to Parameters: elementName - the element name to map Parameters: 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 |
getMappings | public String[] getMappings(String elementName)(Code) | | Returns the all mappings defined for the given element xpath.
since: 7.0.2 Parameters: elementName - the element xpath to look up the mapping for the mapping defined for the given element xpath |
getValidationMessage | protected String getValidationMessage(CmsObject cms, I_CmsXmlContentValue value, String regex, String valueStr, boolean matchResult, boolean isWarning)(Code) | | Returns the validation message to be displayed if a certain rule was violated.
Parameters: cms - the current users OpenCms context Parameters: value - the value to validate Parameters: regex - the rule that was violated Parameters: valueStr - the string value of the given value Parameters: matchResult - if false, the rule was negated Parameters: isWarning - if true, this validation indicate a warning, otherwise an error the validation message to be displayed |
init | protected void init()(Code) | | Called when this content handler is initialized.
|
initDefaultValues | protected void initDefaultValues(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException(Code) | | 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 Parameters: contentDefinition - the content definition the default values belong to throws: CmsXmlException - if something goes wrong |
initLayouts | protected void initLayouts(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException(Code) | | 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
org.opencms.xml.types.CmsXmlStringValue
the default widget is the
org.opencms.widgets.CmsInputWidget .
However, certain values can also use more then one widget, for example you may
also use a
org.opencms.widgets.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 Parameters: contentDefinition - the content definition the layout belongs to throws: CmsXmlException - if something goes wrong |
initMappings | protected void initMappings(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException(Code) | | 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 Parameters: contentDefinition - the content definition the mappings belong to throws: CmsXmlException - if something goes wrong |
initModelFolder | protected void initModelFolder(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException(Code) | | 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 Parameters: 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(Code) | | Initializes the preview location for this content handler.
Parameters: root - the "preview" element from the appinfo node of the XML content definition Parameters: 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(Code) | | 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 Parameters: contentDefinition - the content definition the check rules belong to throws: CmsXmlException - if something goes wrong |
initResourceBundle | protected void initResourceBundle(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException(Code) | | 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 Parameters: contentDefinition - the content definition the validation rules belong to throws: CmsXmlException - if something goes wrong |
initSearchSettings | protected void initSearchSettings(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException(Code) | | 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 Parameters: contentDefinition - the content definition the default values belong to throws: CmsXmlException - if something goes wrong |
initValidationRules | protected void initValidationRules(Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException(Code) | | 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 Parameters: contentDefinition - the content definition the validation rules belong to throws: CmsXmlException - if something goes wrong |
isInvalidateParent | protected boolean isInvalidateParent(String xpath)(Code) | | Returns the is-invalidate-parent flag for the given xpath.
Parameters: xpath - the path to get the check rule for the configured is-invalidate-parent flag for the given xpath |
key | protected String key(String keyName, Locale locale)(Code) | | 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 Parameters: locale - the locale to get the key from the resource string for the given key See Also: CmsMessages.formatUnknownKey(String) See Also: CmsMessages.isUnknownKey(String) |
removeEmptyMappings | protected void removeEmptyMappings(CmsObject cms, CmsXmlContent content) throws CmsException(Code) | | Removes property values on resources for non-existing, optional elements.
Parameters: cms - the current users OpenCms context Parameters: 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(Code) | | 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 |
validateLink | protected boolean validateLink(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler)(Code) | | Validates the given rules against the given value.
Parameters: cms - the current users OpenCms context Parameters: value - the value to validate Parameters: errorHandler - the error handler to use in case errors or warnings are detected if a broken link has been found |
validateValue | protected CmsXmlContentErrorHandler validateValue(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler, Map rules, boolean isWarning)(Code) | | Validates the given rules against the given value.
Parameters: cms - the current users OpenCms context Parameters: value - the value to validate Parameters: errorHandler - the error handler to use in case errors or warnings are detected Parameters: rules - the rules to validate the value against Parameters: isWarning - if true, this validation should be stored as a warning, otherwise as an error the updated error handler |
validateValue | protected CmsXmlContentErrorHandler validateValue(CmsObject cms, I_CmsXmlContentValue value, String valueStr, CmsXmlContentErrorHandler errorHandler, boolean isWarning)(Code) | | 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 Parameters: value - the value to validate Parameters: valueStr - the string value of the given value Parameters: errorHandler - the error handler to use in case errors or warnings are detected Parameters: isWarning - if true, this validation should be stored as a warning, otherwise as an error the updated error handler |
|
|