Package org.opencms.xml
Class CmsXmlContentTypeManager
- java.lang.Object
-
- org.opencms.xml.CmsXmlContentTypeManager
-
public class CmsXmlContentTypeManager extends java.lang.Object
Manager class for registered OpenCms XML content types and content collectors.- Since:
- 6.0.0
-
-
Constructor Summary
Constructors Constructor Description CmsXmlContentTypeManager()
Creates a new content type manager.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description I_CmsXmlSchemaType
addContentType(java.lang.Class<?> clazz)
Adds a XML content schema type class to the registered XML content types.void
addSchemaType(java.lang.String className, java.lang.String defaultWidget)
Adds a new XML content type schema class and XML widget to the manager by class names.void
addWidget(java.lang.String className, java.util.List<java.lang.String> aliases, java.lang.String defaultConfiguration)
Adds a XML content editor widget class, making this widget available for the XML content editor.static CmsXmlContentTypeManager
createTypeManagerForTestCases()
Returns a statically initialized instance of an XML content type manager (for test cases only).I_CmsXmlContentHandler
getContentHandler(java.lang.String className, java.lang.String schemaLocation)
Returns the XML content handler instance class for the specified class name.I_CmsXmlSchemaType
getContentType(java.lang.String typeName)
Returns the content type registered with the given name, ornull
.I_CmsXmlSchemaType
getContentType(org.dom4j.Element typeElement, java.util.Set<CmsXmlContentDefinition> nestedDefinitions)
Generates an initialized instance of a XML content type definition from the given XML schema element.I_CmsXmlContentHandler
getFreshContentHandler(java.lang.String className)
Returns a fresh XML content handler instance for the specified class name.java.util.List<I_CmsXmlSchemaType>
getRegisteredSchemaTypes()
Returns an alphabetically sorted list of all configured XML content schema types.java.util.List<java.lang.String>
getRegisteredWidgetAliases(java.lang.String className)
Returns the alias for the given Widget class name, may benull
if no alias is defined for the class.java.util.List<java.lang.String>
getRegisteredWidgetNames()
Returns an alphabetically sorted list of the class names of all configured XML widgets.I_CmsWidget
getWidget(java.lang.String name)
Returns an initialized widget class by it's class name or by it's alias.I_CmsWidget
getWidgetDefault(java.lang.String typeName)
Returns the editor widget for the specified XML content type.java.lang.String
getWidgetDefaultConfiguration(java.lang.String name)
Returns the default widget configuration set inopencms-vfs.xml
ornull
if nothing is found.java.lang.String
getWidgetDefaultConfiguration(I_CmsWidget widget)
Returns the default widget configuration set inopencms-vfs.xml
ornull
if nothing is found.void
initialize(CmsObject cms)
Initializes XML content types managed in this XML content type manager.
-
-
-
Constructor Detail
-
CmsXmlContentTypeManager
public CmsXmlContentTypeManager()
Creates a new content type manager.
-
-
Method Detail
-
createTypeManagerForTestCases
public static CmsXmlContentTypeManager createTypeManagerForTestCases()
Returns a statically initialized instance of an XML content type manager (for test cases only).- Returns:
- a statically initialized instance of an XML content type manager
-
addContentType
public I_CmsXmlSchemaType addContentType(java.lang.Class<?> clazz) throws CmsXmlException
Adds a XML content schema type class to the registered XML content types.- Parameters:
clazz
- the XML content schema type class to add- Returns:
- the created instance of the XML content schema type
- Throws:
CmsXmlException
- in case the class is not an instance ofI_CmsXmlSchemaType
-
addSchemaType
public void addSchemaType(java.lang.String className, java.lang.String defaultWidget)
Adds a new XML content type schema class and XML widget to the manager by class names.- Parameters:
className
- class name of the XML content schema type class to adddefaultWidget
- class name of the default XML widget class for the added XML content type
-
addWidget
public void addWidget(java.lang.String className, java.util.List<java.lang.String> aliases, java.lang.String defaultConfiguration)
Adds a XML content editor widget class, making this widget available for the XML content editor.- Parameters:
className
- the widget class to addaliases
- the (optional) alias names to use for the widget classdefaultConfiguration
- the default configuration of the widget
-
getContentHandler
public I_CmsXmlContentHandler getContentHandler(java.lang.String className, java.lang.String schemaLocation) throws CmsXmlException
Returns the XML content handler instance class for the specified class name.Only one instance of an XML content handler class per content definition name will be generated, and that instance will be cached and re-used for all operations.
- Parameters:
className
- the name of the XML content handler to returnschemaLocation
- the schema location of the XML content definition that handler belongs to- Returns:
- the XML content handler class
- Throws:
CmsXmlException
- if something goes wrong
-
getContentType
public I_CmsXmlSchemaType getContentType(org.dom4j.Element typeElement, java.util.Set<CmsXmlContentDefinition> nestedDefinitions) throws CmsXmlException
Generates an initialized instance of a XML content type definition from the given XML schema element.- Parameters:
typeElement
- the element to generate the XML content type definition fromnestedDefinitions
- the nested (included) XML content sub-definitions- Returns:
- an initialized instance of a XML content type definition
- Throws:
CmsXmlException
- in case the element does not describe a valid XML content type definition
-
getContentType
public I_CmsXmlSchemaType getContentType(java.lang.String typeName)
Returns the content type registered with the given name, ornull
.- Parameters:
typeName
- the name to look up the content type for- Returns:
- the content type registered with the given name, or
null
-
getFreshContentHandler
public I_CmsXmlContentHandler getFreshContentHandler(java.lang.String className) throws CmsXmlException
Returns a fresh XML content handler instance for the specified class name.- Parameters:
className
- the name of the XML content handler to return- Returns:
- the XML content handler class
- Throws:
CmsXmlException
- if something goes wrong
-
getRegisteredSchemaTypes
public java.util.List<I_CmsXmlSchemaType> getRegisteredSchemaTypes()
Returns an alphabetically sorted list of all configured XML content schema types.- Returns:
- an alphabetically sorted list of all configured XML content schema types
-
getRegisteredWidgetAliases
public java.util.List<java.lang.String> getRegisteredWidgetAliases(java.lang.String className)
Returns the alias for the given Widget class name, may benull
if no alias is defined for the class.- Parameters:
className
- the name of the widget- Returns:
- the alias for the given Widget class name, may be
null
if no alias is defined for the class
-
getRegisteredWidgetNames
public java.util.List<java.lang.String> getRegisteredWidgetNames()
Returns an alphabetically sorted list of the class names of all configured XML widgets.- Returns:
- an alphabetically sorted list of the class names of all configured XML widgets
-
getWidget
public I_CmsWidget getWidget(java.lang.String name)
Returns an initialized widget class by it's class name or by it's alias.- Parameters:
name
- the class name or alias name to get the widget for- Returns:
- the widget instance for the class name
-
getWidgetDefault
public I_CmsWidget getWidgetDefault(java.lang.String typeName)
Returns the editor widget for the specified XML content type.This will always return a fresh instance if it doesn't return null.
- Parameters:
typeName
- the name of the XML content type to get the widget for- Returns:
- the editor widget for the specified XML content type
-
getWidgetDefaultConfiguration
public java.lang.String getWidgetDefaultConfiguration(I_CmsWidget widget)
Returns the default widget configuration set inopencms-vfs.xml
ornull
if nothing is found.- Parameters:
widget
- the widget instance to get the default configuration for- Returns:
- the default widget configuration
-
getWidgetDefaultConfiguration
public java.lang.String getWidgetDefaultConfiguration(java.lang.String name)
Returns the default widget configuration set inopencms-vfs.xml
ornull
if nothing is found.- Parameters:
name
- the class name or alias name to get the default configuration for- Returns:
- the default widget configuration
-
initialize
public void initialize(CmsObject cms) throws CmsRoleViolationException
Initializes XML content types managed in this XML content type manager.- Parameters:
cms
- an initialized OpenCms user context with "Administrator" role permissions- Throws:
CmsRoleViolationException
- in case the provided OpenCms user context doea not have "Administrator" role permissions
-
-