org.opencms.configuration
Class CmsConfigurationManager

java.lang.Object
  extended by org.opencms.configuration.CmsConfigurationManager
All Implemented Interfaces:
I_CmsConfigurationParameterHandler, I_CmsXmlConfiguration

public class CmsConfigurationManager
extends java.lang.Object
implements I_CmsXmlConfiguration

Configuration manager for digesting the OpenCms XML configuration.

Reads the individual configuration class nodes first and creaes new instances of the "base" configuration classes.

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

Field Summary
static java.lang.String DEFAULT_DTD_LOCATION
          The location of the OpenCms configuration DTD if the default prefix is the system ID.
static java.lang.String DEFAULT_DTD_PREFIX
          The default prefix for the OpenCms configuration DTD.
static java.lang.String DEFAULT_XML_FILE_NAME
          The name of the default XML file for this configuration.
static java.lang.String DTD_FILE_NAME
          The name of the DTD file for this configuration.
protected static java.lang.String N_CONFIG
          The config node.
protected static java.lang.String N_CONFIGURATION
          The configurations node.
static java.lang.String N_ROOT
          The "opencms" root node of the XML configuration.
static java.lang.String POSTFIX_ORI
          Postfix for original configuration files.
 
Fields inherited from interface org.opencms.configuration.I_CmsXmlConfiguration
A_ALIAS, A_CLASS, A_COUNT, A_DEFAULT, A_DESTINATION, A_ENABLED, A_FROM, A_HANDLER, A_ICON, A_ID, A_KEY, A_NAME, A_ORDER, A_PASSWORD, A_PORT, A_PROTOCOL, A_SUFFIX, A_TO, A_TYPE, A_URI, A_USER, A_VALUE, N_EXPORTPOINT, N_EXPORTPOINTS, N_NAME, N_PARAM, N_PROPERTY, N_RESOURCE, N_SITE, N_VALUE
 
Fields inherited from interface org.opencms.configuration.I_CmsConfigurationParameterHandler
ADD_PARAMETER_METHOD, INIT_CONFIGURATION_METHOD
 
Constructor Summary
CmsConfigurationManager(java.lang.String baseFolder)
          Creates a new OpenCms configuration manager.
 
Method Summary
 void addConfiguration(I_CmsXmlConfiguration configuration)
          Adds a configuration object to the configuration manager.
 void addConfigurationParameter(java.lang.String paramName, java.lang.String paramValue)
          Adds a configuration parameter to this parameter configurable class instance.
 void addXmlDigesterRules(org.apache.commons.digester.Digester digester)
          Digests an XML node and creates an instance of this configurable class.
 org.dom4j.Element generateXml(org.dom4j.Element parent)
          Generates the XML element for this configurable class.
 org.dom4j.Document generateXml(I_CmsXmlConfiguration configuration)
          Creates the XML document build from the provided configuration.
 java.io.File getBackupFolder()
          Returns the backup folder.
 java.util.Map getConfiguration()
          Returns the properties read from opencms.properties.
 I_CmsXmlConfiguration getConfiguration(java.lang.Class clazz)
          Returns a specific configuration from the list of initialized configurations.
 java.util.List getConfigurations()
          Returns the list of all initialized configurations.
 java.lang.String getDtdFilename()
          Returns the name of the DTD file for this XML configuration, e.g.
 java.lang.String getDtdSystemLocation()
          Returns the internal system location of the DTD file for this XML configuration, e.g.
 java.lang.String getDtdUrlPrefix()
          Returns the external system id prefix of the DTD file for this XML configuration, e.g.
 java.lang.String getXmlFileName()
          Returns the name of the XML input file for this configuration, e.g.
 void initConfiguration()
          Initializes a configuration after all parameters have been added.
 void loadXmlConfiguration()
          Loads the OpenCms configuration from the given XML file.
 void setConfiguration(org.apache.commons.collections.ExtendedProperties propertyConfiguration)
          Sets the configuration read from the opencms.properties.
 void writeConfiguration(java.lang.Class clazz)
          Writes the XML configuration for the provided configuration instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DTD_LOCATION

public static final java.lang.String DEFAULT_DTD_LOCATION
The location of the OpenCms configuration DTD if the default prefix is the system ID.

See Also:
Constant Field Values

DEFAULT_DTD_PREFIX

public static final java.lang.String DEFAULT_DTD_PREFIX
The default prefix for the OpenCms configuration DTD.

See Also:
Constant Field Values

DEFAULT_XML_FILE_NAME

public static final java.lang.String DEFAULT_XML_FILE_NAME
The name of the default XML file for this configuration.

See Also:
Constant Field Values

DTD_FILE_NAME

public static final java.lang.String DTD_FILE_NAME
The name of the DTD file for this configuration.

See Also:
Constant Field Values

N_ROOT

public static final java.lang.String N_ROOT
The "opencms" root node of the XML configuration.

See Also:
Constant Field Values

POSTFIX_ORI

public static final java.lang.String POSTFIX_ORI
Postfix for original configuration files.

See Also:
Constant Field Values

N_CONFIG

protected static final java.lang.String N_CONFIG
The config node.

See Also:
Constant Field Values

N_CONFIGURATION

protected static final java.lang.String N_CONFIGURATION
The configurations node.

See Also:
Constant Field Values
Constructor Detail

CmsConfigurationManager

public CmsConfigurationManager(java.lang.String baseFolder)
Creates a new OpenCms configuration manager.

Parameters:
baseFolder - base folder where XML configurations to load are located
Method Detail

addConfiguration

public void addConfiguration(I_CmsXmlConfiguration configuration)
Adds a configuration object to the configuration manager.

Parameters:
configuration - the configuration to add

addConfigurationParameter

public void addConfigurationParameter(java.lang.String paramName,
                                      java.lang.String paramValue)
Description copied from interface: I_CmsConfigurationParameterHandler
Adds a configuration parameter to this parameter configurable class instance.

Specified by:
addConfigurationParameter in interface I_CmsConfigurationParameterHandler
Parameters:
paramName - the name of the parameter
paramValue - the value for the parameter
See Also:
I_CmsConfigurationParameterHandler.addConfigurationParameter(java.lang.String, java.lang.String)

addXmlDigesterRules

public void addXmlDigesterRules(org.apache.commons.digester.Digester digester)
Description copied from interface: I_CmsXmlConfiguration
Digests an XML node and creates an instance of this configurable class.

Specified by:
addXmlDigesterRules in interface I_CmsXmlConfiguration
Parameters:
digester - the digester to use
See Also:
I_CmsXmlConfiguration.addXmlDigesterRules(org.apache.commons.digester.Digester)

generateXml

public org.dom4j.Element generateXml(org.dom4j.Element parent)
Description copied from interface: I_CmsXmlConfiguration
Generates the XML element for this configurable class.

Specified by:
generateXml in interface I_CmsXmlConfiguration
Parameters:
parent - the parent element in the XML tree
Returns:
the XML element for this configurable class
See Also:
I_CmsXmlConfiguration.generateXml(org.dom4j.Element)

generateXml

public org.dom4j.Document generateXml(I_CmsXmlConfiguration configuration)
Creates the XML document build from the provided configuration.

Parameters:
configuration - the configuration to build the XML for
Returns:
the XML document build from the provided configuration

getBackupFolder

public java.io.File getBackupFolder()
Returns the backup folder.

Returns:
the backup folder

getConfiguration

public java.util.Map getConfiguration()
Returns the properties read from opencms.properties.

This is assured to be an instance of ExtendedProperties.

Specified by:
getConfiguration in interface I_CmsConfigurationParameterHandler
Returns:
the configuration of this resource loader, or null
See Also:
setConfiguration(ExtendedProperties), I_CmsConfigurationParameterHandler.getConfiguration()

getConfiguration

public I_CmsXmlConfiguration getConfiguration(java.lang.Class clazz)
Returns a specific configuration from the list of initialized configurations.

Parameters:
clazz - the configuration class that should be returned
Returns:
the initialized configuration class instance, or null if this is not found

getConfigurations

public java.util.List getConfigurations()
Returns the list of all initialized configurations.

Returns:
the list of all initialized configurations

getDtdFilename

public java.lang.String getDtdFilename()
Description copied from interface: I_CmsXmlConfiguration
Returns the name of the DTD file for this XML configuration, e.g. opencms-configuration.dtd.

Specified by:
getDtdFilename in interface I_CmsXmlConfiguration
Returns:
the name of the DTD file for this XML configuration
See Also:
I_CmsXmlConfiguration.getDtdFilename()

getDtdSystemLocation

public java.lang.String getDtdSystemLocation()
Description copied from interface: I_CmsXmlConfiguration
Returns the internal system location of the DTD file for this XML configuration, e.g. org/opencms/configuration/.

If this is not null, then the DTD is not read through the web URL, but an internal name resolution is added that resolves the system id of the DTD to I_CmsXmlConfiguration.getDtdSystemLocation() + I_CmsXmlConfiguration.getDtdUrlPrefix().

Specified by:
getDtdSystemLocation in interface I_CmsXmlConfiguration
Returns:
the system location of the DTD file for this XML configuration
See Also:
I_CmsXmlConfiguration.getDtdSystemLocation()

getDtdUrlPrefix

public java.lang.String getDtdUrlPrefix()
Description copied from interface: I_CmsXmlConfiguration
Returns the external system id prefix of the DTD file for this XML configuration, e.g. http://www.opencms.org/dtd/6.0/.

The full system id for the DTD is calculated like this: I_CmsXmlConfiguration.getDtdSystemLocation() + I_CmsXmlConfiguration.getDtdUrlPrefix().

Specified by:
getDtdUrlPrefix in interface I_CmsXmlConfiguration
Returns:
the system id prefix of the DTD file for this XML configuration
See Also:
I_CmsXmlConfiguration.getDtdUrlPrefix()

getXmlFileName

public java.lang.String getXmlFileName()
Description copied from interface: I_CmsXmlConfiguration
Returns the name of the XML input file for this configuration, e.g. opencms.xml.

Specified by:
getXmlFileName in interface I_CmsXmlConfiguration
Returns:
the name of the XML input file for this configuration
See Also:
I_CmsXmlConfiguration.getXmlFileName()

initConfiguration

public void initConfiguration()
Description copied from interface: I_CmsConfigurationParameterHandler
Initializes a configuration after all parameters have been added.

Specified by:
initConfiguration in interface I_CmsConfigurationParameterHandler
See Also:
I_CmsConfigurationParameterHandler.initConfiguration()

loadXmlConfiguration

public void loadXmlConfiguration()
                          throws org.xml.sax.SAXException,
                                 java.io.IOException
Loads the OpenCms configuration from the given XML file.

Throws:
org.xml.sax.SAXException - in case of XML parse errors
java.io.IOException - in case of file IO errors

setConfiguration

public void setConfiguration(org.apache.commons.collections.ExtendedProperties propertyConfiguration)
Sets the configuration read from the opencms.properties.

Parameters:
propertyConfiguration - the configuration read from the opencms.properties
See Also:
getConfiguration()

writeConfiguration

public void writeConfiguration(java.lang.Class clazz)
                        throws java.io.IOException,
                               CmsConfigurationException
Writes the XML configuration for the provided configuration instance.

Parameters:
clazz - the configuration class to write the XML for
Throws:
java.io.IOException - in case of I/O errors while writing
CmsConfigurationException - if the given class is not a valid configuration class