org.opencms.ade.configuration
Class CmsADEConfigData

java.lang.Object
  extended by org.opencms.ade.configuration.CmsADEConfigData

public class CmsADEConfigData
extends java.lang.Object

A class which represents the accessible configuration data at a given point in a sitemap.


Field Summary
static java.lang.String CONTENT_FOLDER_NAME
          The content folder name.
 
Constructor Summary
CmsADEConfigData()
          Default constructor to create an empty configuration.
CmsADEConfigData(java.lang.String basePath, java.util.List<CmsResourceTypeConfig> resourceTypeConfig, java.util.List<CmsPropertyConfig> propertyConfig, java.util.List<CmsDetailPageInfo> detailPageInfos, java.util.List<CmsModelPageConfig> modelPages)
          Creates a new configuration data instance.
 
Method Summary
protected  void checkInitialized()
          Checks whether the configuration is initialized and throws an error otherwise.
protected  void checkNotInitialized()
          Checks whether the configuration is *NOT* initialized and throws an error otherwise.
protected static
<C extends I_CmsConfigurationObject<C>>
java.util.List<C>
combineConfigurationElements(java.util.List<C> parentConfigs, java.util.List<C> childConfigs)
          Generic method to merge lists of named configuration objects.
protected  void createContentDirectory()
          Creates the content directory for this configuration node if possible.
static CmsADEConfigData emptyConfiguration()
          Creates an empty configuration object.
 java.util.List<CmsDetailPageInfo> getAllDetailPages()
          Gets the list of all detail pages.
 java.util.List<CmsDetailPageInfo> getAllDetailPages(boolean update)
          Gets a list of all detail pages.
 java.lang.String getBasePath()
          Gets the configuration base path.
protected  CmsObject getCmsObject()
          Gets the CMS object used for VFS operations.
 java.lang.String getContentFolderPath()
          Gets the content folder path.
 java.util.List<CmsResourceTypeConfig> getCreatableTypes(CmsObject cms)
          Returns a list of the creatable resource types.
 CmsModelPageConfig getDefaultModelPage()
          Returns the default model page.
 java.util.List<CmsDetailPageInfo> getDetailPagesForType(java.lang.String type)
          Gets the detail pages for a specific type.
protected  java.util.Map<java.lang.String,java.util.List<CmsDetailPageInfo>> getDetailPagesMap(java.util.List<CmsDetailPageInfo> detailPages)
          Helper method to converts a list of detail pages to a map from type names to lists of detail pages for each type.
protected  java.util.Map<java.lang.String,java.lang.String> getFolderTypes()
          Collects the folder types in a map.
 CmsFormatterConfiguration getFormatters(CmsResource resource)
          Gets the formatters for a given resource.
 CmsFormatterConfiguration getFormatters(java.lang.String type)
          Gets the formatter configuration for a given type.
 CmsDetailPageInfo getMainDetailPage(java.lang.String type)
          Gets the main detail page for a specific type.
 java.util.List<CmsModelPageConfig> getModelPages()
          Gets the list of available model pages.
 java.util.List<CmsPropertyConfig> getPropertyConfiguration()
          Gets the configuration for the available properties.
 java.util.Map<java.lang.String,CmsXmlContentProperty> getPropertyConfigurationAsMap()
          Gets the property configuration as a map of CmsXmlContentProperty instances.
 CmsResource getResource()
          Returns the resource from which this configuration was read.
 CmsResourceTypeConfig getResourceType(java.lang.String typeName)
          Returns the configuration for a specific resource type.
 java.util.List<CmsResourceTypeConfig> getResourceTypes()
          Gets a list of all available resource type configurations.
 java.util.Collection<CmsResourceTypeConfig> getSearchableTypes(CmsObject cms)
          Gets the searchable resource type configurations.
 void initialize(CmsObject cms)
          Initializes the configuration object.
protected  java.util.List<CmsResourceTypeConfig> internalGetResourceTypes()
          Helper method for getting the list of resource types.
 boolean isModuleConfiguration()
          Returns true if this is a module configuration instead of a normal sitemap configuration.
protected  java.util.List<CmsDetailPageInfo> mergeDetailPages(java.util.List<CmsDetailPageInfo> parentDetailPages, java.util.List<CmsDetailPageInfo> ownDetailPages)
          Merges two lists of detail pages, one from a parent configuration and one from a child configuration.
protected  void mergeParent(CmsADEConfigData parent)
          Merges the parent's data into this object.
 CmsADEConfigData parent()
          Fetches the parent configuration of this configuration.
 void setIsModuleConfig(boolean isModuleConfig)
          Sets the "module configuration" flag.
 void setResource(CmsResource resource)
          Sets the configuration file resource.
protected  java.util.List<CmsDetailPageInfo> updateUris(java.util.List<CmsDetailPageInfo> detailPages)
          Helper method to correct paths in detail page beans if the corresponding resources have been moved.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONTENT_FOLDER_NAME

public static final java.lang.String CONTENT_FOLDER_NAME
The content folder name.

See Also:
Constant Field Values
Constructor Detail

CmsADEConfigData

public CmsADEConfigData()
Default constructor to create an empty configuration.


CmsADEConfigData

public CmsADEConfigData(java.lang.String basePath,
                        java.util.List<CmsResourceTypeConfig> resourceTypeConfig,
                        java.util.List<CmsPropertyConfig> propertyConfig,
                        java.util.List<CmsDetailPageInfo> detailPageInfos,
                        java.util.List<CmsModelPageConfig> modelPages)
Creates a new configuration data instance.

Parameters:
basePath - the base path
resourceTypeConfig - the resource type configuration
propertyConfig - the property configuration
detailPageInfos - the detail page configuration
modelPages - the model page configuration
Method Detail

emptyConfiguration

public static CmsADEConfigData emptyConfiguration()
Creates an empty configuration object.

Returns:
an empty configuration object

combineConfigurationElements

protected static <C extends I_CmsConfigurationObject<C>> java.util.List<C> combineConfigurationElements(java.util.List<C> parentConfigs,
                                                                                                        java.util.List<C> childConfigs)
Generic method to merge lists of named configuration objects.

The lists are merged such that the configuration objects from the child list rise to the front of the result list, and two configuration objects will be merged themselves if they share the same name.

For example, if we have two lists of configuration objects:

parent: A1, B1, C1

child: D2, B2

then the resulting list will look like:

D2, B3, A1, C1

where B3 is the result of merging B1 and B2.

Type Parameters:
C - the type of configuration object
Parameters:
parentConfigs - the parent configurations
childConfigs - the child configurations
Returns:
the merged configuration object list

getAllDetailPages

public java.util.List<CmsDetailPageInfo> getAllDetailPages()
Gets the list of all detail pages.

Returns:
the list of all detail pages

getAllDetailPages

public java.util.List<CmsDetailPageInfo> getAllDetailPages(boolean update)
Gets a list of all detail pages.

Parameters:
update - if true, this method will try to correct the root paths in the returned objects if the corresponding resources have been moved
Returns:
the list of all detail pages

getBasePath

public java.lang.String getBasePath()
Gets the configuration base path.

For example, if the configuration file is located at /sites/default/.content/.config, the base path is /sites/default.

Returns:
the base path of the configuration

getContentFolderPath

public java.lang.String getContentFolderPath()
Gets the content folder path.

For example, if the configuration file is located at /sites/default/.content/.config, the content folder path is /sites/default/.content

Returns:
the content folder path

getCreatableTypes

public java.util.List<CmsResourceTypeConfig> getCreatableTypes(CmsObject cms)
                                                        throws CmsException
Returns a list of the creatable resource types.

Parameters:
cms - the CMS context used to check whether the resource types are creatable
Returns:
the list of creatable resource type
Throws:
CmsException - if something goes wrong

getDefaultModelPage

public CmsModelPageConfig getDefaultModelPage()
Returns the default model page.

Returns:
the default model page

getDetailPagesForType

public java.util.List<CmsDetailPageInfo> getDetailPagesForType(java.lang.String type)
Gets the detail pages for a specific type.

Parameters:
type - the type name
Returns:
the list of detail pages for that type

getFormatters

public CmsFormatterConfiguration getFormatters(CmsResource resource)
Gets the formatters for a given resource.

Parameters:
resource - a resource
Returns:
the formatter configuration for that resource

getFormatters

public CmsFormatterConfiguration getFormatters(java.lang.String type)
Gets the formatter configuration for a given type.

Parameters:
type - the type for which to get the formatters
Returns:
the formatter configuration for that type

getMainDetailPage

public CmsDetailPageInfo getMainDetailPage(java.lang.String type)
Gets the main detail page for a specific type.

Parameters:
type - the type name
Returns:
the main detail page for that type

getModelPages

public java.util.List<CmsModelPageConfig> getModelPages()
Gets the list of available model pages.

Returns:
the list of available model pages

getPropertyConfiguration

public java.util.List<CmsPropertyConfig> getPropertyConfiguration()
Gets the configuration for the available properties.

Returns:
the configuration for the available properties

getPropertyConfigurationAsMap

public java.util.Map<java.lang.String,CmsXmlContentProperty> getPropertyConfigurationAsMap()
Gets the property configuration as a map of CmsXmlContentProperty instances.

Returns:
the map of property configurations

getResource

public CmsResource getResource()
Returns the resource from which this configuration was read.

Returns:
the resource from which this configuration was read

getResourceType

public CmsResourceTypeConfig getResourceType(java.lang.String typeName)
Returns the configuration for a specific resource type.

Parameters:
typeName - the name of the type
Returns:
the resource type configuration for that type

getResourceTypes

public java.util.List<CmsResourceTypeConfig> getResourceTypes()
Gets a list of all available resource type configurations.

Returns:
the available resource type configurations

getSearchableTypes

public java.util.Collection<CmsResourceTypeConfig> getSearchableTypes(CmsObject cms)
Gets the searchable resource type configurations.

Parameters:
cms - the current CMS context
Returns:
the searchable resource type configurations

initialize

public void initialize(CmsObject cms)
Initializes the configuration object.

Parameters:
cms - the CMS context to be used for VFS operations

isModuleConfiguration

public boolean isModuleConfiguration()
Returns true if this is a module configuration instead of a normal sitemap configuration.

Returns:
true if this is a module configuration

parent

public CmsADEConfigData parent()
Fetches the parent configuration of this configuration.

If this configuration is a sitemap configuration with no direct parent configuration, the module configuration will be returned. If this configuration already is a module configuration, null will be returned.

Returns:
the parent configuration

setIsModuleConfig

public void setIsModuleConfig(boolean isModuleConfig)
Sets the "module configuration" flag.

Parameters:
isModuleConfig - true if this configuration should be marked as a module configuration

setResource

public void setResource(CmsResource resource)
Sets the configuration file resource.

Parameters:
resource - the configuration file resource

checkInitialized

protected void checkInitialized()
Checks whether the configuration is initialized and throws an error otherwise.


checkNotInitialized

protected void checkNotInitialized()
Checks whether the configuration is *NOT* initialized and throws an error otherwise.


createContentDirectory

protected void createContentDirectory()
                               throws CmsException
Creates the content directory for this configuration node if possible.

Throws:
CmsException - if something goes wrong

getCmsObject

protected CmsObject getCmsObject()
Gets the CMS object used for VFS operations.

Returns:
the CMS object

getDetailPagesMap

protected java.util.Map<java.lang.String,java.util.List<CmsDetailPageInfo>> getDetailPagesMap(java.util.List<CmsDetailPageInfo> detailPages)
Helper method to converts a list of detail pages to a map from type names to lists of detail pages for each type.

Parameters:
detailPages - the list of detail pages
Returns:
the map of detail pages

getFolderTypes

protected java.util.Map<java.lang.String,java.lang.String> getFolderTypes()
                                                                   throws CmsException
Collects the folder types in a map.

Returns:
the map of folder types
Throws:
CmsException - if something goes wrong

internalGetResourceTypes

protected java.util.List<CmsResourceTypeConfig> internalGetResourceTypes()
Helper method for getting the list of resource types.

Returns:
the list of resource types

mergeDetailPages

protected java.util.List<CmsDetailPageInfo> mergeDetailPages(java.util.List<CmsDetailPageInfo> parentDetailPages,
                                                             java.util.List<CmsDetailPageInfo> ownDetailPages)
Merges two lists of detail pages, one from a parent configuration and one from a child configuration.

Parameters:
parentDetailPages - the parent's detail pages
ownDetailPages - the child's detail pages
Returns:
the merged detail pages

mergeParent

protected void mergeParent(CmsADEConfigData parent)
Merges the parent's data into this object.

Parameters:
parent - the parent configuration data

updateUris

protected java.util.List<CmsDetailPageInfo> updateUris(java.util.List<CmsDetailPageInfo> detailPages)
Helper method to correct paths in detail page beans if the corresponding resources have been moved.

Parameters:
detailPages - the original list of detail pages
Returns:
the corrected list of detail pages