com.senn.magic.dctm
Class DfcProperties

java.lang.Object
  extended by com.senn.magic.dctm.DfcProperties

public class DfcProperties
extends Object

Allows to create a dfc.properties with on the fly values when the application is already running.
Only one dfc.properties per application should be created!

Since:
3.3
Author:
Bart Thierens
Last modification: 11/06/2010

Nested Class Summary
protected static class DfcProperties.DfcPropertiesException
          Internal Exception class that extends DfException for when things go wrong when creating a dfc.properties file.
 
Field Summary
protected static boolean created
           
protected static String DFC_PROPERTIES
          name of the dfc.properties file
protected static String GLOBAL_REG_PASS_KEY
          key for the global registry password
protected static String GLOBAL_REG_REPO_KEY
          key for the global registry repository
protected static String GLOBAL_REG_USER_KEY
          key for the global registry user
protected  String globalRegistryPassword
           
protected  String globalRegistryRepository
           
protected  String globalRegistryUser
           
protected  String host
           
protected static String HOST_KEY
          key for the host's name
protected  String location
           
protected  Map<String,String> optionalParams
           
protected  int port
           
protected static String PORT_KEY
          key for the host's port
 
Constructor Summary
DfcProperties()
          Constructs a DfcProperties object with default values for: host: localhost port: 1489 location: {current_directory}/config The values can afterwards be changed...
DfcProperties(String host, int port)
          Constructs a DfcProperties object with default value for: location: {current_directory}/config The value can afterwards be changed...
DfcProperties(String host, int port, String globalRegistryRepository, String globalRegistryUser, String globalRegistryPassword, boolean isPasswordEncrypted)
          Constructs a DfcProperties object with default value for: location: {current_directory}/config The values can afterwards be changed...
DfcProperties(String host, int port, String globalRegistryRepository, String globalRegistryUser, String globalRegistryPassword, boolean isPasswordEncrypted, String location)
          Constructs a DfcProperties object without default values.
 
Method Summary
 void addOptionalParam(String key, String value)
          Adds an optional extra parameter to the dfc.properties.
protected  String buildEntry(String key, String value)
          Internal method that builds a line entry
 void create(boolean overwrite)
          Creates the dfc.properties.
protected  String getEncryptedPassword(String password, boolean isPasswordEncrypted)
          Internal method that encrypts a password if necessary
 String getGlobalRegistryPassword()
          Gets the encrypted global registry password
 String getGlobalRegistryRepository()
          Gets the global registry repository
 String getGlobalRegistryUser()
          Gets the global registry user
 String getHost()
          Gets the content server hostname
 String getLocation()
          Gets the location where the dfc.properties should be located
 Map<String,String> getOptionalParams()
          Gets the map with all the optional parameters defined for this dfc.properties
 int getPort()
          Gets the content server port
 boolean isValid()
          Indicates if all necessary params are entered and if the location is valid.
 void setGlobalRegistryPassword(String globalRegistryPassword, boolean isPasswordEncrypted)
          Sets the global registry password and encrypts it if necessary
 void setGlobalRegistryRepository(String globalRegistryRepository)
          Sets the global registry repository
 void setGlobalRegistryUser(String globalRegistryUser)
          Sets the global registry user
 void setHost(String host)
          Sets the content server hostname Default value = localhost
 void setLocation(String location)
          Sets the location where the dfc.properties should be located.
 void setPort(int port)
          Sets the content server port Default value = 1489
protected  void writeDfcProperties(Writer writer)
          Internal method that writes the dfc.properties file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DFC_PROPERTIES

protected static final String DFC_PROPERTIES
name of the dfc.properties file

See Also:
Constant Field Values

HOST_KEY

protected static final String HOST_KEY
key for the host's name

See Also:
Constant Field Values

PORT_KEY

protected static final String PORT_KEY
key for the host's port

See Also:
Constant Field Values

GLOBAL_REG_REPO_KEY

protected static final String GLOBAL_REG_REPO_KEY
key for the global registry repository

See Also:
Constant Field Values

GLOBAL_REG_USER_KEY

protected static final String GLOBAL_REG_USER_KEY
key for the global registry user

See Also:
Constant Field Values

GLOBAL_REG_PASS_KEY

protected static final String GLOBAL_REG_PASS_KEY
key for the global registry password

See Also:
Constant Field Values

created

protected static boolean created

host

protected String host

port

protected int port

globalRegistryRepository

protected String globalRegistryRepository

globalRegistryUser

protected String globalRegistryUser

globalRegistryPassword

protected String globalRegistryPassword

optionalParams

protected Map<String,String> optionalParams

location

protected String location
Constructor Detail

DfcProperties

public DfcProperties()
Constructs a DfcProperties object with default values for: The values can afterwards be changed...
The other values must be set manually!


DfcProperties

public DfcProperties(String host,
                     int port)
Constructs a DfcProperties object with default value for: The value can afterwards be changed...
The other values must be set manually!

Parameters:
host - the content server hostname
port - the content server port

DfcProperties

public DfcProperties(String host,
                     int port,
                     String globalRegistryRepository,
                     String globalRegistryUser,
                     String globalRegistryPassword,
                     boolean isPasswordEncrypted)
Constructs a DfcProperties object with default value for: The values can afterwards be changed...

Parameters:
host - the content server hostname
port - the content server port
globalRegistryRepository - the global registry repository
globalRegistryUser - the global registry user
globalRegistryPassword - the global registry password
isPasswordEncrypted - whether the password is encrypted or not

DfcProperties

public DfcProperties(String host,
                     int port,
                     String globalRegistryRepository,
                     String globalRegistryUser,
                     String globalRegistryPassword,
                     boolean isPasswordEncrypted,
                     String location)
Constructs a DfcProperties object without default values.
The values can afterwards be changed...

Parameters:
host - the content server hostname
port - the content server port
globalRegistryRepository - the global registry repository
globalRegistryUser - the global registry user
globalRegistryPassword - the global registry password
isPasswordEncrypted - whether the password is encrypted or not
location - the location where dfc.properties should be located
Method Detail

create

public void create(boolean overwrite)
            throws com.documentum.fc.common.DfException
Creates the dfc.properties.
This method can only be called once!

Parameters:
overwrite - if a previously existing dfc.properties should be overwritten
Throws:
com.documentum.fc.common.DfException

isValid

public boolean isValid()
Indicates if all necessary params are entered and if the location is valid.

Returns:
boolean - true if the DfcProperties object is valid, false if it's not

getHost

public String getHost()
Gets the content server hostname

Returns:

setHost

public void setHost(String host)
Sets the content server hostname Default value = localhost

Parameters:
host -

getPort

public int getPort()
Gets the content server port

Returns:

setPort

public void setPort(int port)
Sets the content server port Default value = 1489

Parameters:
port -

getGlobalRegistryRepository

public String getGlobalRegistryRepository()
Gets the global registry repository

Returns:

setGlobalRegistryRepository

public void setGlobalRegistryRepository(String globalRegistryRepository)
Sets the global registry repository

Parameters:
globalRegistryRepository -

getGlobalRegistryUser

public String getGlobalRegistryUser()
Gets the global registry user

Returns:

setGlobalRegistryUser

public void setGlobalRegistryUser(String globalRegistryUser)
Sets the global registry user

Parameters:
globalRegistryUser -

getGlobalRegistryPassword

public String getGlobalRegistryPassword()
Gets the encrypted global registry password

Returns:

setGlobalRegistryPassword

public void setGlobalRegistryPassword(String globalRegistryPassword,
                                      boolean isPasswordEncrypted)
Sets the global registry password and encrypts it if necessary

Parameters:
globalRegistryPassword -
isPasswordEncrypted -

addOptionalParam

public void addOptionalParam(String key,
                             String value)
Adds an optional extra parameter to the dfc.properties.
For example:
DfcProperties dfcProp = new DfcProperties(...); dfcProp.addOptionalParam("dfc.search.maxresults", "1000");

Parameters:
key - the key for the optional parameter
value - the value of the optional parameter

getOptionalParams

public Map<String,String> getOptionalParams()
Gets the map with all the optional parameters defined for this dfc.properties

Returns:

getLocation

public String getLocation()
Gets the location where the dfc.properties should be located

Returns:

setLocation

public void setLocation(String location)
Sets the location where the dfc.properties should be located.
Default value = {current_directory}/config

Parameters:
location -

getEncryptedPassword

protected String getEncryptedPassword(String password,
                                      boolean isPasswordEncrypted)
Internal method that encrypts a password if necessary

Parameters:
password -
isPasswordEncrypted -
Returns:

writeDfcProperties

protected void writeDfcProperties(Writer writer)
                           throws IOException
Internal method that writes the dfc.properties file

Parameters:
writer -
Throws:
IOException

buildEntry

protected String buildEntry(String key,
                            String value)
                     throws IOException
Internal method that builds a line entry

Parameters:
key -
value -
Returns:
Throws:
IOException