org.dspace.core
Class ConfigurationManager

java.lang.Object
  extended by org.dspace.core.ConfigurationManager

public class ConfigurationManager
extends Object

Class for reading the DSpace system configuration. The main configuration is read in as properties from a standard properties file. Email templates and configuration files for other tools are also be accessed via this class.

The main configuration is by default read from the resource /dspace.cfg. To specify a different configuration, the system property dspace.configuration should be set to the filename of the configuration file.

Other configuration files are read from the config directory of the DSpace installation directory (specified as the property dspace.dir in the main configuration file.)

Version:
$Revision: 4243 $
Author:
Robert Tansley, Larry Stone - Interpolated values., Mark Diggory - General Improvements to detection, logging and loading.

Constructor Summary
ConfigurationManager()
           
 
Method Summary
static boolean getBooleanProperty(String property)
          Get a configuration property as a boolean.
static boolean getBooleanProperty(String property, boolean defaultValue)
          Get a configuration property as a boolean, with default.
protected static File getConfigurationFile()
          Deprecated. Please remove all direct usage of the configuration file.
static String getDefaultSubmissionLicense()
          Get the site-wide default license that submitters need to grant
static Email getEmail(String emailFile)
          Get the template for an email message.
static int getIntProperty(String property)
          Get a configuration property as an integer
static int getIntProperty(String property, int defaultValue)
          Get a configuration property as an integer, with default
static String getLicenseText(String licenseFile)
          Get the License
static long getLongProperty(String property)
          Get a configuration property as a long
static long getLongProperty(String property, int defaultValue)
          Get a configuration property as an long, with default
static String getNewsFilePath()
          Get the path for the news files.
static Properties getProperties()
           
static String getProperty(String property)
          Get a configuration property
static boolean isConfigured()
          Identify if DSpace is properly configured
static void loadConfig(String configFile)
          Load the DSpace configuration properties.
static void main(String[] argv)
          Command-line interface for running configuration tasks.
static Enumeration propertyNames()
          Returns an enumeration of all the keys in the DSpace configuration
static String readNewsFile(String newsFile)
          Reads news from a text file.
static void writeLicenseFile(String licenseFile, String newLicense)
          Writes license to a text file.
static String writeNewsFile(String newsFile, String news)
          Writes news to a text file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationManager

public ConfigurationManager()
Method Detail

isConfigured

public static boolean isConfigured()
Identify if DSpace is properly configured

Returns:
boolean true if configured, false otherwise

getProperties

public static Properties getProperties()

getProperty

public static String getProperty(String property)
Get a configuration property

Parameters:
property - the name of the property
Returns:
the value of the property, or null if the property does not exist.

getIntProperty

public static int getIntProperty(String property)
Get a configuration property as an integer

Parameters:
property - the name of the property
Returns:
the value of the property. 0 is returned if the property does not exist. To differentiate between this case and when the property actually is zero, use getProperty.

getIntProperty

public static int getIntProperty(String property,
                                 int defaultValue)
Get a configuration property as an integer, with default

Parameters:
property - the name of the property
defaultValue - value to return if property is not found or is not an Integer.
Returns:
the value of the property. default is returned if the property does not exist or is not an Integer. To differentiate between this case and when the property actually is false, use getProperty.

getLongProperty

public static long getLongProperty(String property)
Get a configuration property as a long

Parameters:
property - the name of the property
Returns:
the value of the property. 0 is returned if the property does not exist. To differentiate between this case and when the property actually is zero, use getProperty.

getLongProperty

public static long getLongProperty(String property,
                                   int defaultValue)
Get a configuration property as an long, with default

Parameters:
property - the name of the property
defaultValue - value to return if property is not found or is not a Long.
Returns:
the value of the property. default is returned if the property does not exist or is not an Integer. To differentiate between this case and when the property actually is false, use getProperty.

getLicenseText

public static String getLicenseText(String licenseFile)
Get the License

Parameters:
license - file name
Returns:
license text

getBooleanProperty

public static boolean getBooleanProperty(String property)
Get a configuration property as a boolean. True is indicated if the value of the property is TRUE or YES (case insensitive.)

Parameters:
property - the name of the property
Returns:
the value of the property. false is returned if the property does not exist. To differentiate between this case and when the property actually is false, use getProperty.

getBooleanProperty

public static boolean getBooleanProperty(String property,
                                         boolean defaultValue)
Get a configuration property as a boolean, with default. True is indicated if the value of the property is TRUE or YES (case insensitive.)

Parameters:
property - the name of the property
defaultValue - value to return if property is not found.
Returns:
the value of the property. default is returned if the property does not exist. To differentiate between this case and when the property actually is false, use getProperty.

propertyNames

public static Enumeration propertyNames()
Returns an enumeration of all the keys in the DSpace configuration

Returns:
an enumeration of all the keys in the DSpace configuration

getEmail

public static Email getEmail(String emailFile)
                      throws IOException
Get the template for an email message. The message is suitable for inserting values using java.text.MessageFormat.

Parameters:
emailFile - full name for the email template, for example "/dspace/config/emails/register".
Returns:
the email object, with the content and subject filled out from the template
Throws:
IOException - if the template couldn't be found, or there was some other error reading the template

getDefaultSubmissionLicense

public static String getDefaultSubmissionLicense()
Get the site-wide default license that submitters need to grant

Returns:
the default license

getNewsFilePath

public static String getNewsFilePath()
Get the path for the news files.


readNewsFile

public static String readNewsFile(String newsFile)
Reads news from a text file.

Parameters:
position - a constant indicating which file (top or side) should be read in.

writeNewsFile

public static String writeNewsFile(String newsFile,
                                   String news)
Writes news to a text file.

Parameters:
position - a constant indicating which file (top or side) should be written to.
news - the text to be written to the file.

writeLicenseFile

public static void writeLicenseFile(String licenseFile,
                                    String newLicense)
Writes license to a text file.

Parameters:
news - the text to be written to the file.

getConfigurationFile

protected static File getConfigurationFile()
Deprecated. Please remove all direct usage of the configuration file.

Return the file that configuration was actually loaded from. Only returns a valid File after configuration has been loaded.

Returns:
File naming configuration data file, or null if not loaded yet.

loadConfig

public static void loadConfig(String configFile)
Load the DSpace configuration properties. Only does anything if properties are not already loaded. Properties are loaded in from the specified file, or default locations.

Parameters:
configFile - The dspace.cfg configuration file to use, or null to try default locations

main

public static void main(String[] argv)
Command-line interface for running configuration tasks. Possible arguments:

Parameters:
argv - command-line arguments


Copyright © 2010 DuraSpace. All Rights Reserved.