org.liquidsite.app.servlet
Class Configuration

java.lang.Object
  extended byorg.liquidsite.app.servlet.Configuration

public class Configuration
extends java.lang.Object

The application configuration. This class contains support for reading and writing the configuration, as well as retrieving the individual properties. The configuration is divided into a configuration file containing the database properties, and a configuration table containing the rest of the configuration properties.


Field Summary
static java.lang.String DATABASE_HOSTNAME
          The database host name key.
static java.lang.String DATABASE_NAME
          The database name key.
static java.lang.String DATABASE_PASSWORD
          The database password key.
static java.lang.String DATABASE_POOL_SIZE
          The database pool size key.
static java.lang.String DATABASE_USER
          The database user name key.
static java.lang.String FILE_DIRECTORY
          The file data directory key.
static java.lang.String MAIL_FOOTER
          The mail footer text key.
static java.lang.String MAIL_FROM
          The mail from address key.
static java.lang.String MAIL_HEADER
          The mail header text key.
static java.lang.String MAIL_HOST
          The mail server host name key.
static java.lang.String MAIL_USER
          The mail user name key.
static java.lang.String STATS_DIRECTORY
          The statistics data directory key.
static java.lang.String UPLOAD_DIRECTORY
          The temporary file upload directory key.
static java.lang.String UPLOAD_MAX_SIZE
          The file upload maximum size key.
static java.lang.String VERSION
          The version number key.
 
Constructor Summary
Configuration()
          Creates a new read-only configuration.
Configuration(java.io.File file)
          Creates a new configuration.
 
Method Summary
 java.lang.String get(java.lang.String key, java.lang.String defaultValue)
          Returns a configuration property string value.
 int getInt(java.lang.String key, int defaultValue)
          Returns a configuration property integer value.
 boolean isInitialized()
          Checks if this configuration has been properly initialized.
 void read(DatabaseConnector db)
          Reads the configuration.
 void set(java.lang.String key, int value)
          Sets a configuration property value.
 void set(java.lang.String key, java.lang.String value)
          Sets a configuration property value.
 void setAll(Configuration config)
          Sets all configuration properties from a set.
 void write(DatabaseConnector db)
          Writes the configuration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
The version number key.

See Also:
Constant Field Values

DATABASE_HOSTNAME

public static final java.lang.String DATABASE_HOSTNAME
The database host name key.

See Also:
Constant Field Values

DATABASE_NAME

public static final java.lang.String DATABASE_NAME
The database name key.

See Also:
Constant Field Values

DATABASE_USER

public static final java.lang.String DATABASE_USER
The database user name key.

See Also:
Constant Field Values

DATABASE_PASSWORD

public static final java.lang.String DATABASE_PASSWORD
The database password key.

See Also:
Constant Field Values

DATABASE_POOL_SIZE

public static final java.lang.String DATABASE_POOL_SIZE
The database pool size key.

See Also:
Constant Field Values

MAIL_HOST

public static final java.lang.String MAIL_HOST
The mail server host name key.

See Also:
Constant Field Values

MAIL_USER

public static final java.lang.String MAIL_USER
The mail user name key.

See Also:
Constant Field Values

MAIL_FROM

public static final java.lang.String MAIL_FROM
The mail from address key.

See Also:
Constant Field Values

MAIL_HEADER

public static final java.lang.String MAIL_HEADER
The mail header text key.

See Also:
Constant Field Values

MAIL_FOOTER

public static final java.lang.String MAIL_FOOTER
The mail footer text key.

See Also:
Constant Field Values

FILE_DIRECTORY

public static final java.lang.String FILE_DIRECTORY
The file data directory key.

See Also:
Constant Field Values

STATS_DIRECTORY

public static final java.lang.String STATS_DIRECTORY
The statistics data directory key.

See Also:
Constant Field Values

UPLOAD_DIRECTORY

public static final java.lang.String UPLOAD_DIRECTORY
The temporary file upload directory key.

See Also:
Constant Field Values

UPLOAD_MAX_SIZE

public static final java.lang.String UPLOAD_MAX_SIZE
The file upload maximum size key.

See Also:
Constant Field Values
Constructor Detail

Configuration

public Configuration()
Creates a new read-only configuration. This constructor is only used for accessing configuration data in databases during the installation.


Configuration

public Configuration(java.io.File file)
Creates a new configuration.

Parameters:
file - the configuration file to use
Method Detail

isInitialized

public boolean isInitialized()
Checks if this configuration has been properly initialized. The configuration is considered initialized if the config file could be read properly.

Returns:
true if this configuration was properly initialized, or false otherwise

get

public java.lang.String get(java.lang.String key,
                            java.lang.String defaultValue)
Returns a configuration property string value.

Parameters:
key - the configuration property key
defaultValue - the value to use if not set
Returns:
the configuration property string value, or the default value if undefined

getInt

public int getInt(java.lang.String key,
                  int defaultValue)
Returns a configuration property integer value.

Parameters:
key - the configuration property key
defaultValue - the value to use if not set
Returns:
the configuration property integer value, or the default value if undefined

set

public void set(java.lang.String key,
                java.lang.String value)
Sets a configuration property value.

Parameters:
key - the configuration property key
value - the configuration property value

set

public void set(java.lang.String key,
                int value)
Sets a configuration property value.

Parameters:
key - the configuration property key
value - the configuration property value

setAll

public void setAll(Configuration config)
Sets all configuration properties from a set. Any existing configuration properties with identical names will be overwritten.

Parameters:
config - the configuration properties

read

public void read(DatabaseConnector db)
          throws ConfigurationException
Reads the configuration. The configuration is read from both file and database.

Parameters:
db - the database connector to use
Throws:
ConfigurationException - if the configuration couldn't be read properly

write

public void write(DatabaseConnector db)
           throws ConfigurationException
Writes the configuration. The configuration is written to both file and database.

Parameters:
db - the database connector to use
Throws:
ConfigurationException - if the configuration couldn't be written properly