org.opencms.xml.content
Interface I_CmsXmlContentHandler

All Known Implementing Classes:
CmsDefaultXmlContentHandler

public interface I_CmsXmlContentHandler

Handles special XML content livetime events, and also provides XML content editor rendering hints.

Since:
6.0.0
Version:
$Revision: 1.24 $
Author:
Alexander Kandzior

Field Summary
static java.lang.String[] ATTRIBUTE_ARRAY
          Array of all allowed attribute mapping names.
static java.util.List ATTRIBUTES
          List of all allowed attribute mapping names, for fast lookup.
static java.lang.String MAPTO_ATTRIBUTE
          Prefix for attribute mappings.
static java.lang.String MAPTO_PROPERTY
          Prefix for property mappings.
static java.lang.String MAPTO_PROPERTY_INDIVIDUAL
          Prefix for property mappings.
static java.lang.String MAPTO_PROPERTY_LIST
          Prefix for property list mappings.
static java.lang.String MAPTO_PROPERTY_LIST_INDIVIDUAL
          Prefix for property list mappings.
static java.lang.String MAPTO_PROPERTY_LIST_SHARED
          Prefix for property list mappings.
static java.lang.String MAPTO_PROPERTY_SHARED
          Prefix for property mappings.
 
Method Summary
 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.
 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 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.
 I_CmsWidget getWidget(I_CmsXmlContentValue value)
          Returns the editor widget that should be used for the given XML content value.
 void initialize(org.dom4j.Element appInfoElement, CmsXmlContentDefinition contentDefinition)
          Initializes this content handler for the given XML content definition by analyzing the "appinfo" node.
 CmsFile prepareForWrite(CmsObject cms, CmsXmlContent content, CmsFile file)
          Prepares the given XML content to be written to the OpenCms VFS.
 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.
 

Field Detail

ATTRIBUTE_ARRAY

public static final java.lang.String[] ATTRIBUTE_ARRAY
Array of all allowed attribute mapping names.


ATTRIBUTES

public static final java.util.List ATTRIBUTES
List of all allowed attribute mapping names, for fast lookup.


MAPTO_ATTRIBUTE

public static final java.lang.String MAPTO_ATTRIBUTE
Prefix for attribute mappings.

See Also:
Constant Field Values

MAPTO_PROPERTY

public static final java.lang.String MAPTO_PROPERTY
Prefix for property mappings.

See Also:
Constant Field Values

MAPTO_PROPERTY_INDIVIDUAL

public static final java.lang.String MAPTO_PROPERTY_INDIVIDUAL
Prefix for property mappings.

See Also:
Constant Field Values

MAPTO_PROPERTY_LIST

public static final java.lang.String MAPTO_PROPERTY_LIST
Prefix for property list mappings.

See Also:
Constant Field Values

MAPTO_PROPERTY_LIST_INDIVIDUAL

public static final java.lang.String MAPTO_PROPERTY_LIST_INDIVIDUAL
Prefix for property list mappings.

See Also:
Constant Field Values

MAPTO_PROPERTY_LIST_SHARED

public static final java.lang.String MAPTO_PROPERTY_LIST_SHARED
Prefix for property list mappings.

See Also:
Constant Field Values

MAPTO_PROPERTY_SHARED

public static final java.lang.String MAPTO_PROPERTY_SHARED
Prefix for property mappings.

See Also:
Constant Field Values
Method Detail

getConfiguration

public java.lang.String getConfiguration(I_CmsXmlSchemaType type)
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.

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

getDefault

public 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.

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

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_CmsXmlSchemaType.getDefault(Locale)

getMessages

public CmsMessages getMessages(java.util.Locale locale)
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.

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

getPreview

public 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.

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

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

getWidget

public I_CmsWidget getWidget(I_CmsXmlContentValue value)
                      throws CmsXmlException
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.

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
Throws:
CmsXmlException - if something goes wrong

initialize

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

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

prepareForWrite

public CmsFile prepareForWrite(CmsObject cms,
                               CmsXmlContent content,
                               CmsFile file)
                        throws CmsException
Prepares the given XML content to be written to the OpenCms VFS.

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

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 vresion of the parameter file
Throws:
CmsException - in case something goes wrong

resolveMapping

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

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

resolveValidation

public 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.

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