org.opencms.ade.configuration
Class CmsADEConfigData

java.lang.Object
  extended by org.opencms.ade.configuration.CmsADEConfigData
Direct Known Subclasses:
CmsTestConfigData

public class CmsADEConfigData
extends Object

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


Field Summary
static String CONTENT_FOLDER_NAME
          The content folder name.
protected  boolean m_createContentsLocally
          The "create contents locally" flag.
protected  boolean m_discardInheritedModelPages
          Should inherited model pages be discarded?
protected  boolean m_discardInheritedProperties
          Should inherited properties be discard?
protected  boolean m_discardInheritedTypes
          Should inherited types be discarded?
 
Constructor Summary
CmsADEConfigData()
          Default constructor to create an empty configuration.
CmsADEConfigData(String basePath)
          Creates an empty configuration data object with a given base path.
CmsADEConfigData(String basePath, List<CmsResourceTypeConfig> resourceTypeConfig, boolean discardInheritedTypes, List<CmsPropertyConfig> propertyConfig, boolean discardInheritedProperties, List<CmsDetailPageInfo> detailPageInfos, List<CmsModelPageConfig> modelPages, List<CmsFunctionReference> functionReferences, boolean discardInheritedModelPages, boolean createContentsLocally)
          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>>
List<C>
combineConfigurationElements(List<C> parentConfigs, 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(String basePath)
          Creates an empty configuration for a given base path.
 List<CmsDetailPageInfo> getAllDetailPages()
          Gets the list of all detail pages.
 List<CmsDetailPageInfo> getAllDetailPages(boolean update)
          Gets a list of all detail pages.
 String getBasePath()
          Gets the configuration base path.
protected  CmsObject getCmsObject()
          Gets the CMS object used for VFS operations.
 String getContentFolderPath()
          Gets the content folder path.
 List<CmsResourceTypeConfig> getCreatableTypes(CmsObject cms)
          Returns a list of the creatable resource types.
 CmsModelPageConfig getDefaultModelPage()
          Returns the default model page.
 List<CmsDetailPageInfo> getDetailPagesForType(String type)
          Gets the detail pages for a specific type.
protected  Map<String,List<CmsDetailPageInfo>> getDetailPagesMap(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  Map<String,String> getFolderTypes()
          Collects the folder types in a map.
 CmsFormatterConfiguration getFormatters(CmsObject cms, CmsResource res)
          Gets the formatter configuration for a resource.
protected  CmsFormatterConfiguration getFormatters(String type)
          Gets the formatter configuration for a given type.
protected  CmsFormatterConfiguration getFormattersFromSchema(CmsObject cms, CmsResource res)
          Gets the formatters from the schema.
 CmsFunctionReference getFunctionReference(String name)
          Gets a named function reference.
 List<CmsFunctionReference> getFunctionReferences()
          Gets the list of configured function references.
 CmsDetailPageInfo getMainDetailPage(String type)
          Gets the main detail page for a specific type.
 List<CmsModelPageConfig> getModelPages()
          Gets the list of available model pages.
 List<CmsPropertyConfig> getPropertyConfiguration()
          Gets the configuration for the available properties.
 Map<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(String typeName)
          Returns the configuration for a specific resource type.
 List<CmsResourceTypeConfig> getResourceTypes()
          Gets a list of all available resource type configurations.
 Collection<CmsResourceTypeConfig> getSearchableTypes(CmsObject cms)
          Gets the searchable resource type configurations.
 void initialize(CmsObject cms)
          Initializes the configuration object.
protected  List<CmsFunctionReference> internalGetFunctionReferences()
          Internal method for getting the function references.
protected  List<CmsResourceTypeConfig> internalGetResourceTypes()
          Helper method for getting the list of resource types.
 boolean isCreateContentsLocally()
          Returns the value of the "create contents locally" flag.
 boolean isDiscardInheritedModelPages()
          Returns the value of the "discard inherited model pages" flag.
 boolean isDiscardInheritedProperties()
          Returns the value of the "discard inherited properties" flag.
 boolean isDiscardInheritedTypes()
          Returns the value of the "discard inherited types" flag.
 boolean isModuleConfiguration()
          Returns true if this is a module configuration instead of a normal sitemap configuration.
protected  List<CmsDetailPageInfo> mergeDetailPages(List<CmsDetailPageInfo> parentDetailPages, 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.
protected  void processModuleOrdering()
          Handle the ordering from the module configurations.
 void setIsModuleConfig(boolean isModuleConfig)
          Sets the "module configuration" flag.
 void setResource(CmsResource resource)
          Sets the configuration file resource.
protected  List<CmsDetailPageInfo> updateUris(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 String CONTENT_FOLDER_NAME
The content folder name.

See Also:
Constant Field Values

m_createContentsLocally

protected boolean m_createContentsLocally
The "create contents locally" flag.


m_discardInheritedModelPages

protected boolean m_discardInheritedModelPages
Should inherited model pages be discarded?


m_discardInheritedProperties

protected boolean m_discardInheritedProperties
Should inherited properties be discard?


m_discardInheritedTypes

protected boolean m_discardInheritedTypes
Should inherited types be discarded?

Constructor Detail

CmsADEConfigData

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


CmsADEConfigData

public CmsADEConfigData(String basePath)
Creates an empty configuration data object with a given base path.

Parameters:
basePath - the base path

CmsADEConfigData

public CmsADEConfigData(String basePath,
                        List<CmsResourceTypeConfig> resourceTypeConfig,
                        boolean discardInheritedTypes,
                        List<CmsPropertyConfig> propertyConfig,
                        boolean discardInheritedProperties,
                        List<CmsDetailPageInfo> detailPageInfos,
                        List<CmsModelPageConfig> modelPages,
                        List<CmsFunctionReference> functionReferences,
                        boolean discardInheritedModelPages,
                        boolean createContentsLocally)
Creates a new configuration data instance.

Parameters:
basePath - the base path
resourceTypeConfig - the resource type configuration
discardInheritedTypes - the "discard inherited types" flag
propertyConfig - the property configuration
discardInheritedProperties - the "discard inherited properties" flag
detailPageInfos - the detail page configuration
modelPages - the model page configuration
functionReferences - the function reference configuration
discardInheritedModelPages - the "discard inherited model pages" flag
createContentsLocally - the "create contents locally" flag
Method Detail

emptyConfiguration

public static CmsADEConfigData emptyConfiguration(String basePath)
Creates an empty configuration for a given base path.

Parameters:
basePath - the base path
Returns:
the empty configuration object

combineConfigurationElements

protected static <C extends I_CmsConfigurationObject<C>> List<C> combineConfigurationElements(List<C> parentConfigs,
                                                                                              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 List<CmsDetailPageInfo> getAllDetailPages()
Gets the list of all detail pages.

Returns:
the list of all detail pages

getAllDetailPages

public 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 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 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 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 List<CmsDetailPageInfo> getDetailPagesForType(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(CmsObject cms,
                                               CmsResource res)
Gets the formatter configuration for a resource.

Parameters:
cms - the current CMS context
res - the resource for which the formatter configuration should be retrieved
Returns:
the configuration of formatters for the resource

getFunctionReference

public CmsFunctionReference getFunctionReference(String name)
Gets a named function reference.

Parameters:
name - the name of the function reference
Returns:
the function reference for the given name

getFunctionReferences

public List<CmsFunctionReference> getFunctionReferences()
Gets the list of configured function references.

Returns:
the list of configured function references

getMainDetailPage

public CmsDetailPageInfo getMainDetailPage(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 List<CmsModelPageConfig> getModelPages()
Gets the list of available model pages.

Returns:
the list of available model pages

getPropertyConfiguration

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

Returns:
the configuration for the available properties

getPropertyConfigurationAsMap

public Map<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(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 List<CmsResourceTypeConfig> getResourceTypes()
Gets a list of all available resource type configurations.

Returns:
the available resource type configurations

getSearchableTypes

public 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

isCreateContentsLocally

public boolean isCreateContentsLocally()
Returns the value of the "create contents locally" flag.

If this flag is set, contents of types configured in a super-sitemap will be created in the sub-sitemap (if the user creates them from the sub-sitemap).

Returns:
the "create contents locally" flag

isDiscardInheritedModelPages

public boolean isDiscardInheritedModelPages()
Returns the value of the "discard inherited model pages" flag.

If this flag is set, inherited model pages will be discarded for this sitemap.

Returns:
the "discard inherited model pages" flag

isDiscardInheritedProperties

public boolean isDiscardInheritedProperties()
Returns the value of the "discard inherited properties" flag.

If this is flag is set, inherited property definitions will be discarded for this sitemap.

Returns:
the "discard inherited properties" flag.


isDiscardInheritedTypes

public boolean isDiscardInheritedTypes()
Returns the value of the "discard inherited types" flag.

If this flag is set, inherited resource types from a super-sitemap will be discarded for this sitemap.

Returns:
the "discard inherited types" flag

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 Map<String,List<CmsDetailPageInfo>> getDetailPagesMap(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 Map<String,String> getFolderTypes()
                                     throws CmsException
Collects the folder types in a map.

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

getFormatters

protected CmsFormatterConfiguration getFormatters(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

getFormattersFromSchema

protected CmsFormatterConfiguration getFormattersFromSchema(CmsObject cms,
                                                            CmsResource res)
Gets the formatters from the schema.

Parameters:
cms - the current CMS context
res - the resource for which the formatters should be retrieved
Returns:
the formatters from the schema

internalGetFunctionReferences

protected List<CmsFunctionReference> internalGetFunctionReferences()
Internal method for getting the function references.

Returns:
the function references

internalGetResourceTypes

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

Returns:
the list of resource types

mergeDetailPages

protected List<CmsDetailPageInfo> mergeDetailPages(List<CmsDetailPageInfo> parentDetailPages,
                                                   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

processModuleOrdering

protected void processModuleOrdering()
Handle the ordering from the module configurations.


updateUris

protected List<CmsDetailPageInfo> updateUris(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