|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.opencms.xml.content.CmsDefaultXmlContentHandler
public class CmsDefaultXmlContentHandler
Default implementation for the XML content handler, will be used by all XML contents that do not provide their own handler.
Field Summary | |
---|---|
static java.lang.String |
APPINFO_APPINFO
Constant for the "appinfo" element name itself. |
static java.lang.String |
APPINFO_ATTR_COLLAPSE
Constant for the "collapse" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_CONFIGURATION
Constant for the "configuration" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_ELEMENT
Constant for the "element" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_INVALIDATE
Constant for the "invalidate" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_MAPTO
Constant for the "mapto" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_MESSAGE
Constant for the "message" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_NAME
Constant for the "name" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_REGEX
Constant for the "regex" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_SEARCHCONTENT
Constant for the "searchcontent" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_TYPE
Constant for the "type" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_TYPE_NODE
Constant for the "node" appinfo attribute value. |
static java.lang.String |
APPINFO_ATTR_TYPE_PARENT
Constant for the "parent" appinfo attribute value. |
static java.lang.String |
APPINFO_ATTR_TYPE_WARNING
Constant for the "warning" appinfo attribute value. |
static java.lang.String |
APPINFO_ATTR_URI
Constant for the "uri" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_USEALL
Constant for the "useall" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_VALUE
Constant for the "value" appinfo attribute name. |
static java.lang.String |
APPINFO_ATTR_WIDGET
Constant for the "widget" appinfo attribute name. |
static java.lang.String |
APPINFO_DEFAULT
Constant for the "default" appinfo element name. |
static java.lang.String |
APPINFO_DEFAULTS
Constant for the "defaults" appinfo element name. |
static java.lang.String |
APPINFO_LAYOUT
Constant for the "layout" appinfo element name. |
static java.lang.String |
APPINFO_LAYOUTS
Constant for the "layouts" appinfo element name. |
static java.lang.String |
APPINFO_MAPPING
Constant for the "mapping" appinfo element name. |
static java.lang.String |
APPINFO_MAPPINGS
Constant for the "mappings" appinfo element name. |
static java.lang.String |
APPINFO_MODELFOLDER
Constant for the "modelfolder" appinfo element name. |
static java.lang.String |
APPINFO_PREVIEW
Constant for the "preview" appinfo element name. |
static java.lang.String |
APPINFO_RELATION
Constant for the "relation" appinfo element name. |
static java.lang.String |
APPINFO_RELATIONS
Constant for the "relations" appinfo element name. |
static java.lang.String |
APPINFO_RESOURCEBUNDLE
Constant for the "resourcebundle" appinfo element name. |
static java.lang.String |
APPINFO_RULE
Constant for the "rule" appinfo element name. |
static java.lang.String |
APPINFO_SCHEMA_FILE
The file where the default appinfo schema is located. |
static java.lang.String |
APPINFO_SCHEMA_FILE_TYPES
The file where the default appinfo schema types are located. |
static java.lang.String |
APPINFO_SCHEMA_SYSTEM_ID
The XML system id for the default appinfo schema types. |
static java.lang.String |
APPINFO_SCHEMA_TYPES_SYSTEM_ID
The XML system id for the default appinfo schema types. |
static java.lang.String |
APPINFO_SEARCHSETTING
Constant for the "searchsetting" appinfo element name. |
static java.lang.String |
APPINFO_SEARCHSETTINGS
Constant for the "searchsettings" appinfo element name. |
static java.lang.String |
APPINFO_TAB
Constant for the "tab" appinfo element name. |
static java.lang.String |
APPINFO_TABS
Constant for the "tabs" appinfo element name. |
static java.lang.String |
APPINFO_VALIDATIONRULE
Constant for the "validationrule" appinfo element name. |
static java.lang.String |
APPINFO_VALIDATIONRULES
Constant for the "validationrules" appinfo element name. |
protected java.util.Map<java.lang.String,java.lang.String> |
m_configurationValues
The configuration values for the element widgets (as defined in the annotations). |
protected java.util.Map<java.lang.String,java.lang.String> |
m_defaultValues
The default values for the elements (as defined in the annotations). |
protected java.util.Map<java.lang.String,java.lang.String[]> |
m_elementMappings
The element mappings (as defined in the annotations). |
protected java.util.Map<java.lang.String,I_CmsWidget> |
m_elementWidgets
The widgets used for the elements (as defined in the annotations). |
protected java.lang.String |
m_messageBundleName
The resource bundle name to be used for localization of this content handler. |
protected java.lang.String |
m_modelFolder
The folder containing the model file(s) for the content. |
protected java.lang.String |
m_previewLocation
The preview location (as defined in the annotations). |
protected java.util.Map<java.lang.String,java.lang.Boolean> |
m_relationChecks
The relation check rules. |
protected java.util.Map<java.lang.String,CmsRelationType> |
m_relations
The relation check rules. |
protected java.util.Map<java.lang.String,java.lang.Boolean> |
m_searchSettings
The search settings. |
protected java.util.List<CmsXmlContentTab> |
m_tabs
The configured tabs. |
protected java.util.Map<java.lang.String,java.lang.String> |
m_validationErrorMessages
The messages for the error validation rules. |
protected java.util.Map<java.lang.String,java.lang.String> |
m_validationErrorRules
The validation rules that cause an error (as defined in the annotations). |
protected java.util.Map<java.lang.String,java.lang.String> |
m_validationWarningMessages
The messages for the warning validation rules. |
protected java.util.Map<java.lang.String,java.lang.String> |
m_validationWarningRules
The validation rules that cause a warning (as defined in the annotations). |
static java.lang.String |
MACRO_PREVIEW_TEMPFILE
Macro for resolving the preview URI. |
protected static java.lang.String |
MESSAGE_VALIDATION_DEFAULT_ERROR
Default message for validation errors. |
protected static java.lang.String |
MESSAGE_VALIDATION_DEFAULT_WARNING
Default message for validation warnings. |
Fields inherited from interface org.opencms.xml.content.I_CmsXmlContentHandler |
---|
ATTRIBUTES, MAPTO_ATTRIBUTE, MAPTO_PROPERTY, MAPTO_PROPERTY_INDIVIDUAL, MAPTO_PROPERTY_LIST, MAPTO_PROPERTY_LIST_INDIVIDUAL, MAPTO_PROPERTY_LIST_SHARED, MAPTO_PROPERTY_SHARED |
Constructor Summary | |
---|---|
CmsDefaultXmlContentHandler()
Creates a new instance of the default XML content handler. |
Method Summary | |
---|---|
protected void |
addCheckRule(CmsXmlContentDefinition contentDefinition,
java.lang.String elementName,
java.lang.String invalidate,
java.lang.String type)
Adds a check rule for a specified element. |
protected void |
addConfiguration(CmsXmlContentDefinition contentDefinition,
java.lang.String elementName,
java.lang.String configurationValue)
Adds a configuration value for an element widget. |
protected void |
addDefault(CmsXmlContentDefinition contentDefinition,
java.lang.String elementName,
java.lang.String defaultValue)
Adds a default value for an element. |
protected void |
addDefaultCheckRules(CmsXmlContentDefinition rootContentDefinition,
I_CmsXmlSchemaType schemaType,
java.lang.String elementPath)
Adds all needed default check rules recursively for the given schema type. |
protected void |
addMapping(CmsXmlContentDefinition contentDefinition,
java.lang.String elementName,
java.lang.String mapping)
Adds an element mapping. |
protected void |
addSearchSetting(CmsXmlContentDefinition contentDefinition,
java.lang.String elementName,
java.lang.Boolean value)
Adds a search setting for an element. |
protected void |
addValidationRule(CmsXmlContentDefinition contentDefinition,
java.lang.String elementName,
java.lang.String regex,
java.lang.String message,
boolean isWarning)
Adds a validation rule for a specified element. |
protected void |
addWidget(CmsXmlContentDefinition contentDefinition,
java.lang.String elementName,
java.lang.String widgetClassOrAlias)
Adds a GUI widget for a specified element. |
java.lang.String |
getConfiguration(I_CmsXmlSchemaType type)
Returns the configuration String value for the widget used to edit the given XML content schema type. |
java.lang.String |
getDefault(CmsObject cms,
I_CmsXmlContentValue value,
java.util.Locale locale)
Returns the default String value for the given XML content schema type object in the given XML content. |
protected java.util.Locale |
getLocaleForResource(CmsObject cms,
java.lang.String resource)
Returns the default locale in the content of the given resource. |
java.lang.String |
getMapping(java.lang.String elementName)
Deprecated. use getMappings(String) instead to recieve all mappings |
java.lang.String[] |
getMappings(java.lang.String elementName)
Returns the all mappings defined for the given element xpath. |
CmsMessages |
getMessages(java.util.Locale locale)
Returns the CmsMessages that are used to resolve localized keys
for the given locale in this content handler. |
java.lang.String |
getModelFolder(CmsObject cms,
java.lang.String currentFolder)
Returns the folder that contains eventual XML content model files to use for this resource type. |
java.lang.String |
getPreview(CmsObject cms,
CmsXmlContent content,
java.lang.String resourcename)
Returns the preview URI for the given XML content value object to be displayed in the editor. |
protected java.lang.String |
getReferencePath(CmsObject cms,
I_CmsXmlContentValue value)
Returns the category reference path for the given value. |
CmsRelationType |
getRelationType(I_CmsXmlContentValue value)
Returns the relation type for the given value. |
java.util.List<CmsXmlContentTab> |
getTabs()
Returns the tabs to be displayed in the editor. |
protected java.lang.String |
getValidationMessage(CmsObject cms,
I_CmsXmlContentValue value,
java.lang.String regex,
java.lang.String valueStr,
boolean matchResult,
boolean isWarning)
Returns the validation message to be displayed if a certain rule was violated. |
I_CmsWidget |
getWidget(I_CmsXmlContentValue value)
Returns the editor widget that should be used for the given XML content value. |
protected void |
init()
Called when this content handler is initialized. |
protected void |
initDefaultValues(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the default values for this content handler. |
void |
initialize(org.dom4j.Element appInfoElement,
CmsXmlContentDefinition contentDefinition)
Initializes this content handler for the given XML content definition by analyzing the "appinfo" node. |
protected void |
initLayouts(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the layout for this content handler. |
protected void |
initMappings(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the element mappings for this content handler. |
protected void |
initModelFolder(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the folder containing the model file(s) for this content handler. |
protected void |
initPreview(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the preview location for this content handler. |
protected void |
initRelations(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the relation configuration for this content handler. |
protected void |
initResourceBundle(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the resource bundle to use for localized messages in this content handler. |
protected void |
initSearchSettings(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the search exclusions values for this content handler. |
protected void |
initTabs(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the tabs for this content handler. |
protected void |
initValidationRules(org.dom4j.Element root,
CmsXmlContentDefinition contentDefinition)
Initializes the validation rules this content handler. |
void |
invalidateBrokenLinks(CmsObject cms,
CmsXmlContent document)
Performs a check of the given XML document. |
protected boolean |
isInvalidateParent(java.lang.String xpath)
Returns the is-invalidate-parent flag for the given xpath. |
boolean |
isSearchable(I_CmsXmlContentValue value)
Returns true in case the given value should be searchable with
the integrated full text search. |
protected java.lang.String |
key(java.lang.String keyName,
java.util.Locale locale)
Returns the localized resource string for a given message key according to the configured resource bundle of this content handler. |
CmsXmlContent |
prepareForUse(CmsObject cms,
CmsXmlContent content)
Prepares the given XML content to be used after it was read from the OpenCms VFS. |
CmsFile |
prepareForWrite(CmsObject cms,
CmsXmlContent content,
CmsFile file)
Prepares the given XML content to be written to the OpenCms VFS. |
protected void |
removeEmptyMappings(CmsObject cms,
CmsXmlContent content)
Removes property values on resources for non-existing, optional elements. |
void |
resolveMapping(CmsObject cms,
CmsXmlContent content,
I_CmsXmlContentValue value)
Resolves the value mappings of the given XML content value, according to the rules of this XML content handler. |
CmsXmlContentErrorHandler |
resolveValidation(CmsObject cms,
I_CmsXmlContentValue value,
CmsXmlContentErrorHandler errorHandler)
Performs a validation of the given XML content value, and saves all errors or warnings found in the provided XML content error handler. |
protected void |
validateAppinfoElement(org.dom4j.Element appinfoElement)
Validates if the given appinfo element node from the XML content definition schema
is valid according the the capabilities of this content handler. |
protected CmsXmlContentErrorHandler |
validateCategories(CmsObject cms,
I_CmsXmlContentValue value,
CmsXmlContentErrorHandler errorHandler)
The errorHandler parameter is optional, if null is given a new error handler
instance must be created. |
protected boolean |
validateLink(CmsObject cms,
I_CmsXmlContentValue value,
CmsXmlContentErrorHandler errorHandler)
Validates the given rules against the given value. |
protected CmsXmlContentErrorHandler |
validateValue(CmsObject cms,
I_CmsXmlContentValue value,
CmsXmlContentErrorHandler errorHandler,
java.util.Map<java.lang.String,java.lang.String> rules,
boolean isWarning)
Validates the given rules against the given value. |
protected CmsXmlContentErrorHandler |
validateValue(CmsObject cms,
I_CmsXmlContentValue value,
java.lang.String valueStr,
CmsXmlContentErrorHandler errorHandler,
boolean isWarning)
Checks the default XML schema validation rules. |
protected CmsFile |
writeCategories(CmsObject cms,
CmsFile file,
CmsXmlContent content)
Writes the categories if a category widget is present. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String APPINFO_APPINFO
public static final java.lang.String APPINFO_ATTR_COLLAPSE
public static final java.lang.String APPINFO_ATTR_CONFIGURATION
public static final java.lang.String APPINFO_ATTR_ELEMENT
public static final java.lang.String APPINFO_ATTR_INVALIDATE
public static final java.lang.String APPINFO_ATTR_MAPTO
public static final java.lang.String APPINFO_ATTR_MESSAGE
public static final java.lang.String APPINFO_ATTR_NAME
public static final java.lang.String APPINFO_ATTR_REGEX
public static final java.lang.String APPINFO_ATTR_SEARCHCONTENT
public static final java.lang.String APPINFO_ATTR_TYPE
public static final java.lang.String APPINFO_ATTR_TYPE_NODE
public static final java.lang.String APPINFO_ATTR_TYPE_PARENT
public static final java.lang.String APPINFO_ATTR_TYPE_WARNING
public static final java.lang.String APPINFO_ATTR_URI
public static final java.lang.String APPINFO_ATTR_USEALL
public static final java.lang.String APPINFO_ATTR_VALUE
public static final java.lang.String APPINFO_ATTR_WIDGET
public static final java.lang.String APPINFO_DEFAULT
public static final java.lang.String APPINFO_DEFAULTS
public static final java.lang.String APPINFO_LAYOUT
public static final java.lang.String APPINFO_LAYOUTS
public static final java.lang.String APPINFO_MAPPING
public static final java.lang.String APPINFO_MAPPINGS
public static final java.lang.String APPINFO_MODELFOLDER
public static final java.lang.String APPINFO_PREVIEW
public static final java.lang.String APPINFO_RELATION
public static final java.lang.String APPINFO_RELATIONS
public static final java.lang.String APPINFO_RESOURCEBUNDLE
public static final java.lang.String APPINFO_RULE
public static final java.lang.String APPINFO_SCHEMA_FILE
public static final java.lang.String APPINFO_SCHEMA_FILE_TYPES
public static final java.lang.String APPINFO_SCHEMA_SYSTEM_ID
public static final java.lang.String APPINFO_SCHEMA_TYPES_SYSTEM_ID
public static final java.lang.String APPINFO_SEARCHSETTING
public static final java.lang.String APPINFO_SEARCHSETTINGS
public static final java.lang.String APPINFO_TAB
public static final java.lang.String APPINFO_TABS
public static final java.lang.String APPINFO_VALIDATIONRULE
public static final java.lang.String APPINFO_VALIDATIONRULES
public static final java.lang.String MACRO_PREVIEW_TEMPFILE
protected static final java.lang.String MESSAGE_VALIDATION_DEFAULT_ERROR
protected static final java.lang.String MESSAGE_VALIDATION_DEFAULT_WARNING
protected java.util.Map<java.lang.String,java.lang.String> m_configurationValues
protected java.util.Map<java.lang.String,java.lang.String> m_defaultValues
protected java.util.Map<java.lang.String,java.lang.String[]> m_elementMappings
protected java.util.Map<java.lang.String,I_CmsWidget> m_elementWidgets
protected java.lang.String m_messageBundleName
protected java.lang.String m_modelFolder
protected java.lang.String m_previewLocation
protected java.util.Map<java.lang.String,CmsRelationType> m_relations
protected java.util.Map<java.lang.String,java.lang.Boolean> m_relationChecks
protected java.util.Map<java.lang.String,java.lang.Boolean> m_searchSettings
protected java.util.List<CmsXmlContentTab> m_tabs
protected java.util.Map<java.lang.String,java.lang.String> m_validationErrorMessages
protected java.util.Map<java.lang.String,java.lang.String> m_validationErrorRules
protected java.util.Map<java.lang.String,java.lang.String> m_validationWarningMessages
protected java.util.Map<java.lang.String,java.lang.String> m_validationWarningRules
Constructor Detail |
---|
public CmsDefaultXmlContentHandler()
Method Detail |
---|
public java.lang.String getConfiguration(I_CmsXmlSchemaType type)
I_CmsXmlContentHandler
If no configuration value is available, this method must return null
.
getConfiguration
in interface I_CmsXmlContentHandler
type
- the value to get the widget configuration for
I_CmsXmlContentHandler.getConfiguration(org.opencms.xml.types.I_CmsXmlSchemaType)
public java.lang.String getDefault(CmsObject cms, I_CmsXmlContentValue value, java.util.Locale locale)
I_CmsXmlContentHandler
If a schema type does not have a default value, this method must return null
.
getDefault
in interface I_CmsXmlContentHandler
cms
- the current users OpenCms contextvalue
- the value to get the default forlocale
- the currently selected locale for the value
I_CmsXmlContentHandler.getDefault(org.opencms.file.CmsObject, I_CmsXmlContentValue, java.util.Locale)
public java.lang.String getMapping(java.lang.String elementName)
getMappings(String)
instead to recieve all mappings
Since OpenCms version 7.0.2, multiple mappings for an element are possible, so
use getMapping(String)
instead.
elementName
- the element xpath to look up the mapping for
public java.lang.String[] getMappings(java.lang.String elementName)
elementName
- the element xpath to look up the mapping for
public CmsMessages getMessages(java.util.Locale locale)
I_CmsXmlContentHandler
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
.
getMessages
in interface I_CmsXmlContentHandler
locale
- the locale to get the messages for
CmsMessages
that are used to resolve localized keys
for the given locale in this content handlerI_CmsXmlContentHandler.getMessages(java.util.Locale)
public java.lang.String getModelFolder(CmsObject cms, java.lang.String currentFolder)
I_CmsXmlContentHandler
getModelFolder
in interface I_CmsXmlContentHandler
cms
- the current OpenCms user contextcurrentFolder
- the folder the user is currently working in
I_CmsXmlContentHandler.getModelFolder(org.opencms.file.CmsObject, java.lang.String)
public java.lang.String getPreview(CmsObject cms, CmsXmlContent content, java.lang.String resourcename)
I_CmsXmlContentHandler
If null
is returned, no preview is possible for contents using this handler.
getPreview
in interface I_CmsXmlContentHandler
cms
- the current OpenCms user contextcontent
- the XML content to display the preview URI forresourcename
- the name in the VFS of the resource that is currently edited
I_CmsXmlContentHandler.getPreview(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, java.lang.String)
public CmsRelationType getRelationType(I_CmsXmlContentValue value)
I_CmsXmlContentHandler
getRelationType
in interface I_CmsXmlContentHandler
value
- the value to get the relation type for
I_CmsXmlContentHandler.getRelationType(I_CmsXmlContentValue)
public I_CmsWidget getWidget(I_CmsXmlContentValue value)
I_CmsXmlContentHandler
The handler implementations should use the "appinfo" node of the XML content definition schema to define the mappings of elements to widgets.
getWidget
in interface I_CmsXmlContentHandler
value
- the XML content value to get the widget for
I_CmsXmlContentHandler.getWidget(org.opencms.xml.types.I_CmsXmlContentValue)
public void initialize(org.dom4j.Element appInfoElement, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
I_CmsXmlContentHandler
initialize
in interface I_CmsXmlContentHandler
appInfoElement
- the "appinfo" element root node to analyzecontentDefinition
- the XML content definition that XML content handler belongs to
CmsXmlException
- if something goes wrongI_CmsXmlContentHandler.initialize(org.dom4j.Element, org.opencms.xml.CmsXmlContentDefinition)
public void invalidateBrokenLinks(CmsObject cms, CmsXmlContent document)
I_CmsXmlContentHandler
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.
invalidateBrokenLinks
in interface I_CmsXmlContentHandler
cms
- the current OpenCms user contextdocument
- the document to resolve the check rules forI_CmsXmlContentHandler.invalidateBrokenLinks(CmsObject, CmsXmlContent)
public boolean isSearchable(I_CmsXmlContentValue value)
I_CmsXmlContentHandler
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.
isSearchable
in interface I_CmsXmlContentHandler
value
- the XML content value to check
true
in case the given value should be searchableI_CmsXmlContentHandler.isSearchable(org.opencms.xml.types.I_CmsXmlContentValue)
public CmsXmlContent prepareForUse(CmsObject cms, CmsXmlContent content)
I_CmsXmlContentHandler
This method is always called after any content is unmarshalled. It can be used to perform customized actions on the given XML content.
prepareForUse
in interface I_CmsXmlContentHandler
cms
- the current OpenCms user contextcontent
- the XML content to be used as read from the VFS
I_CmsXmlContentHandler.prepareForUse(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent)
public CmsFile prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file) throws CmsException
I_CmsXmlContentHandler
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.
prepareForWrite
in interface I_CmsXmlContentHandler
cms
- the current OpenCms user contextcontent
- the XML content to be writtenfile
- the resource the XML content in it's current state was unmarshalled from
CmsException
- in case something goes wrongI_CmsXmlContentHandler.prepareForWrite(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.file.CmsFile)
public void resolveMapping(CmsObject cms, CmsXmlContent content, I_CmsXmlContentValue value) throws CmsException
I_CmsXmlContentHandler
resolveMapping
in interface I_CmsXmlContentHandler
cms
- the current OpenCms user contextcontent
- the XML content to resolve the mappings forvalue
- the value to resolve the mappings for
CmsException
- if something goes wrongI_CmsXmlContentHandler.resolveMapping(org.opencms.file.CmsObject, org.opencms.xml.content.CmsXmlContent, org.opencms.xml.types.I_CmsXmlContentValue)
public CmsXmlContentErrorHandler resolveValidation(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler)
I_CmsXmlContentHandler
The errorHandler parameter is optional, if null
is given a new error handler
instance must be created.
resolveValidation
in interface I_CmsXmlContentHandler
cms
- the current OpenCms user contextvalue
- the value to resolve the validation rules forerrorHandler
- (optional) an error handler instance that contains previous error or warnings
I_CmsXmlContentHandler.resolveValidation(org.opencms.file.CmsObject, org.opencms.xml.types.I_CmsXmlContentValue, org.opencms.xml.content.CmsXmlContentErrorHandler)
protected void addCheckRule(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String invalidate, java.lang.String type) throws CmsXmlException
contentDefinition
- the XML content definition this XML content handler belongs toelementName
- the element name to add the rule toinvalidate
- 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 contenttype
- the relation type
CmsXmlException
- in case an unknown element name is usedprotected void addConfiguration(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String configurationValue) throws CmsXmlException
contentDefinition
- the XML content definition this XML content handler belongs toelementName
- the element name to mapconfigurationValue
- the configuration value to use
CmsXmlException
- in case an unknown element name is usedprotected void addDefault(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String defaultValue) throws CmsXmlException
contentDefinition
- the XML content definition this XML content handler belongs toelementName
- the element name to mapdefaultValue
- the default value to use
CmsXmlException
- in case an unknown element name is usedprotected void addDefaultCheckRules(CmsXmlContentDefinition rootContentDefinition, I_CmsXmlSchemaType schemaType, java.lang.String elementPath) throws CmsXmlException
rootContentDefinition
- the root content definitionschemaType
- the schema type to checkelementPath
- the current element path
CmsXmlException
- if something goes wrongprotected void addMapping(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String mapping) throws CmsXmlException
contentDefinition
- the XML content definition this XML content handler belongs toelementName
- the element name to mapmapping
- the mapping to use
CmsXmlException
- in case an unknown element name is usedprotected void addSearchSetting(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.Boolean value) throws CmsXmlException
contentDefinition
- the XML content definition this XML content handler belongs toelementName
- the element name to mapvalue
- the search setting value to store
CmsXmlException
- in case an unknown element name is usedprotected void addValidationRule(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String regex, java.lang.String message, boolean isWarning) throws CmsXmlException
contentDefinition
- the XML content definition this XML content handler belongs toelementName
- the element name to add the rule toregex
- the validation rule regular expressionmessage
- the message in case validation fails (may be null)isWarning
- if true, this rule is used for warnings, otherwise it's an error
CmsXmlException
- in case an unknown element name is usedprotected void addWidget(CmsXmlContentDefinition contentDefinition, java.lang.String elementName, java.lang.String widgetClassOrAlias) throws CmsXmlException
contentDefinition
- the XML content definition this XML content handler belongs toelementName
- the element name to mapwidgetClassOrAlias
- the widget to use as GUI for the element (registered alias or class name)
CmsXmlException
- in case an unknown element name is usedprotected java.util.Locale getLocaleForResource(CmsObject cms, java.lang.String resource)
cms
- the cms contextresource
- the resource path to get the default locale for
protected java.lang.String getReferencePath(CmsObject cms, I_CmsXmlContentValue value)
cms
- the cms contextvalue
- the xml content value
protected java.lang.String getValidationMessage(CmsObject cms, I_CmsXmlContentValue value, java.lang.String regex, java.lang.String valueStr, boolean matchResult, boolean isWarning)
cms
- the current users OpenCms contextvalue
- the value to validateregex
- the rule that was violatedvalueStr
- the string value of the given valuematchResult
- if false, the rule was negatedisWarning
- if true, this validation indicate a warning, otherwise an error
protected void init()
protected void initDefaultValues(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
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.
root
- the "defaults" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the default values belong to
CmsXmlException
- if something goes wrongprotected void initLayouts(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
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.
root
- the "layouts" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the layout belongs to
CmsXmlException
- if something goes wrongprotected void initMappings(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
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.
root
- the "mappings" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the mappings belong to
CmsXmlException
- if something goes wrongprotected void initModelFolder(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
root
- the "modelfolder" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the model folder belongs to
CmsXmlException
- if something goes wrongprotected void initPreview(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
root
- the "preview" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the validation rules belong to
CmsXmlException
- if something goes wrongprotected void initRelations(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
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.
root
- the "relations" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the check rules belong to
CmsXmlException
- if something goes wrongprotected void initResourceBundle(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
root
- the "resourcebundle" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the validation rules belong to
CmsXmlException
- if something goes wrongprotected void initSearchSettings(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
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.
root
- the "searchsettings" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the default values belong to
CmsXmlException
- if something goes wrongprotected void initTabs(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition)
.
root
- the "tabs" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the tabs belong topublic java.util.List<CmsXmlContentTab> getTabs()
I_CmsXmlContentHandler
getTabs
in interface I_CmsXmlContentHandler
I_CmsXmlContentHandler.getTabs()
protected void initValidationRules(org.dom4j.Element root, CmsXmlContentDefinition contentDefinition) throws CmsXmlException
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.
root
- the "validationrules" element from the appinfo node of the XML content definitioncontentDefinition
- the content definition the validation rules belong to
CmsXmlException
- if something goes wrongprotected boolean isInvalidateParent(java.lang.String xpath)
xpath
- the path to get the check rule for
protected java.lang.String key(java.lang.String keyName, java.util.Locale locale)
If the key was not found in the configured bundle, or no bundle is configured for this
content handler, the return value is
"??? " + keyName + " ???"
.
keyName
- the key for the desired stringlocale
- the locale to get the key from
CmsMessages.formatUnknownKey(String)
,
CmsMessages.isUnknownKey(String)
protected void removeEmptyMappings(CmsObject cms, CmsXmlContent content) throws CmsException
cms
- the current users OpenCms contextcontent
- the XML content to remove the property values for
CmsException
- in case of read/write errors accessing the OpenCms VFSprotected void validateAppinfoElement(org.dom4j.Element appinfoElement) throws CmsXmlException
appinfo
element node from the XML content definition schema
is valid according the the capabilities of this content handler.
appinfoElement
- the appinfo
element node to validate
CmsXmlException
- in case the element validation failsprotected CmsXmlContentErrorHandler validateCategories(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler)
null
is given a new error handler
instance must be created.
cms
- the current OpenCms user contextvalue
- the value to resolve the validation rules forerrorHandler
- (optional) an error handler instance that contains previous error or warnings
protected boolean validateLink(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler)
cms
- the current users OpenCms contextvalue
- the value to validateerrorHandler
- the error handler to use in case errors or warnings are detected
protected CmsXmlContentErrorHandler validateValue(CmsObject cms, I_CmsXmlContentValue value, CmsXmlContentErrorHandler errorHandler, java.util.Map<java.lang.String,java.lang.String> rules, boolean isWarning)
cms
- the current users OpenCms contextvalue
- the value to validateerrorHandler
- the error handler to use in case errors or warnings are detectedrules
- the rules to validate the value againstisWarning
- if true, this validation should be stored as a warning, otherwise as an error
protected CmsXmlContentErrorHandler validateValue(CmsObject cms, I_CmsXmlContentValue value, java.lang.String valueStr, CmsXmlContentErrorHandler errorHandler, boolean isWarning)
These rules should only be tested if this is not a test for warnings.
cms
- the current users OpenCms contextvalue
- the value to validatevalueStr
- the string value of the given valueerrorHandler
- the error handler to use in case errors or warnings are detectedisWarning
- if true, this validation should be stored as a warning, otherwise as an error
protected CmsFile writeCategories(CmsObject cms, CmsFile file, CmsXmlContent content) throws CmsException
cms
- the cms contextfile
- the filecontent
- the xml content to set the categories for
CmsException
- if something goes wrong
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |