org.ifeth.sehr.lib
Class SEHRCfg

java.lang.Object
  extended byorg.ifeth.sehr.lib.SEHRCfg

public class SEHRCfg
extends java.lang.Object

This method is the only one and basic configuration layer between the SEHR modules and the operating system.

The configuration file knows (due to the setup procedure) where to find the databases, environments like Apache, SAMBA etc.

To retrieve the running configuration one of the methods listed below should be used in accordance to the context:

Important: This object requires always a local read access to the running or defined configuration file for security reasons.
On remote clients get relevant data of the running SEHR system like SMTP relay or POP3 server by the implemented SOAP interface.

Version:
$Id: SEHRCfg.java,v 1.16 2005/07/17 21:14:05 hansjhaase Exp $
Author:
Hans J. Haase HJH

Constructor Summary
SEHRCfg()
          Parameterless instance for using object in JSP as bean.
SEHRCfg(boolean search)
          Init SEHR environment object either by scaning for the configuration or by accessing the default host/port
SEHRCfg(java.lang.String file)
          Init SEHR environment object using specified configuration file
SEHRCfg(java.lang.String ip, int port)
          Init SEHR environment object using specified host/port to get the configuration file to load.
 
Method Summary
 java.sql.Connection getCon()
           
 java.lang.String getCssfile()
          Get the style file for WEB pages.
 java.lang.String getdbHost()
           
 java.lang.String getdbHostname()
           
 java.lang.String getdbSec()
           
 java.lang.String getdbSecUser()
           
 java.lang.String getdbSecUserPw()
           
 java.lang.String getDebug()
           
 int getDebugInt()
           
 java.util.logging.Level getDebugLevel()
          Returns a 'Level' object related to the stored/set debug level
static java.util.logging.Level getDebugLevel(int d)
          Returns a 'Level' object related to a given 'int' between 0 to 9 See SEHR conventions for debugging details
 java.lang.String getDomain()
           
 SEHRDataSource getFbds()
           
 java.lang.String getFQNN()
           
 java.lang.String getIMAPServer()
           
 java.lang.String getLANIP()
          Get LAN IP where current server by SERVER IP running in Due to IP conventions the LAN Ip can be build from SERVER IP otherwise the server would not work :)
 java.lang.String getLogfile()
           
 org.apache.log4j.Logger getLogger()
           
 java.lang.String getModuleOwner()
           
 java.lang.String getModuleRoot()
           
 java.lang.String getPOP3Server()
           
 java.lang.String getRunningCfgFile()
           
 java.lang.String getSEHRCfgValue(java.lang.String key)
          Common getter to retrieve a setting value from running configuration Note: There are a lot predefined methods...
 java.lang.String getSERVERIP()
           
 java.lang.String getSERVERPort()
           
 java.lang.String getSMTPServer()
           
 java.lang.String getSubdomain()
           
 java.lang.String getSYSHOME()
           
 java.lang.String getTitle()
           
 java.lang.String getURLSEHRAdminAsIP()
          Returns the URL to access the SEHR-OSI module by Tomcat for administration purposes.
 java.lang.String getZoneID()
           
 void initDBConnection()
          Init a db connection to zone admin db using settings of this object
static boolean isNULLOrEmpty(java.lang.String s)
          Check if a given String is null or empty.
 boolean isSEHRCfgLoaded()
          Simple check wether the SEHR object was loaded (is available).
 boolean isSEHRCfgProp()
          Check wether SEHR environment is initialized (configuration is avlb.)
 boolean loadSEHRCfg()
          Load SEHR configuration by searching for the running configuration Use this method to get/init the SEHR configuration for all modules.
 boolean loadSEHRCfg(java.lang.String f)
          Load SEHR configuration from a given configuration file.
 boolean loadSEHRCfg(java.lang.String host, int port)
          Get the configuration from the running server.
 void logDebug(java.lang.String message)
           
 void logError(java.lang.String message)
           
 void logInfo(java.lang.String message)
           
 void logWarn(java.lang.String message)
           
static void main(java.lang.String[] args)
           
 boolean readSEHRCfgFile(java.lang.String file)
          Read configuration file and store key value pairs as properties.
 void readSEHRCfgFileToProp(java.lang.String file)
          Deprecated. (for downgrading compatibility)

from modules use 'loadSEHRCfg()'

 void saveCfgFile(java.lang.String file)
          Save configuration in memory as configuration property file This method is used by the SEHRServer task to store the 'runnning' configuration and may be used by the user to redefine settings...
 void setCon(java.sql.Connection con)
           
 void setdbHost(java.lang.String dbHost)
           
 void setdbSecUser(java.lang.String dbSecUser)
           
 void setdbSecUserPw(java.lang.String dbSecUserPw)
           
 void setDebugLevel(int level)
           
 void setFbds(SEHRDataSource fbds)
           
 java.lang.String toString()
          Retrieve a very simple object information....
static java.lang.String trimnull(java.lang.String s)
          Helper method to set 'null' strings to "" strings for a better review from database.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SEHRCfg

public SEHRCfg()
Parameterless instance for using object in JSP as bean.

If using object as bean don't forget to load the configuration by sehrcfg.loadSEHRCfg([options]);


SEHRCfg

public SEHRCfg(boolean search)
Init SEHR environment object either by scaning for the configuration or by accessing the default host/port


SEHRCfg

public SEHRCfg(java.lang.String file)
Init SEHR environment object using specified configuration file


SEHRCfg

public SEHRCfg(java.lang.String ip,
               int port)
Init SEHR environment object using specified host/port to get the configuration file to load.

Note: Finally you must have a physical read access to the file to load the configuration. On WEB services 127.0.0.1/24100 is the default and you can use the simplified instantiation by using SEHRCfg(true). This method is used in testing environments...

Method Detail

toString

public java.lang.String toString()
Retrieve a very simple object information....


getSEHRCfgValue

public java.lang.String getSEHRCfgValue(java.lang.String key)
Common getter to retrieve a setting value from running configuration

Note: There are a lot predefined methods...


getModuleRoot

public java.lang.String getModuleRoot()

getModuleOwner

public java.lang.String getModuleOwner()

getLogfile

public java.lang.String getLogfile()

getTitle

public java.lang.String getTitle()

getZoneID

public java.lang.String getZoneID()

getDomain

public java.lang.String getDomain()

getSubdomain

public java.lang.String getSubdomain()

getSERVERPort

public java.lang.String getSERVERPort()

getSERVERIP

public java.lang.String getSERVERIP()

getLANIP

public java.lang.String getLANIP()
Get LAN IP where current server by SERVER IP running in

Due to IP conventions the LAN Ip can be build from SERVER IP otherwise the server would not work :)

Returns:
lanip

getFQNN

public java.lang.String getFQNN()

getURLSEHRAdminAsIP

public java.lang.String getURLSEHRAdminAsIP()
Returns the URL to access the SEHR-OSI module by Tomcat for administration purposes. The method may be useful for retrieving the URL with the correct server IP for using by 'thick' clients.


getSMTPServer

public java.lang.String getSMTPServer()

getPOP3Server

public java.lang.String getPOP3Server()

getIMAPServer

public java.lang.String getIMAPServer()

getDebug

public java.lang.String getDebug()

getDebugInt

public int getDebugInt()

setDebugLevel

public void setDebugLevel(int level)

getDebugLevel

public java.util.logging.Level getDebugLevel()
Returns a 'Level' object related to the stored/set debug level


getDebugLevel

public static java.util.logging.Level getDebugLevel(int d)
Returns a 'Level' object related to a given 'int' between 0 to 9

See SEHR conventions for debugging details

Returns:
Level_object

getdbSec

public java.lang.String getdbSec()

getdbHost

public java.lang.String getdbHost()

getdbHostname

public java.lang.String getdbHostname()

setdbHost

public void setdbHost(java.lang.String dbHost)

getdbSecUser

public java.lang.String getdbSecUser()

setdbSecUser

public void setdbSecUser(java.lang.String dbSecUser)

getdbSecUserPw

public java.lang.String getdbSecUserPw()

setdbSecUserPw

public void setdbSecUserPw(java.lang.String dbSecUserPw)

getCon

public java.sql.Connection getCon()
Returns:
Returns the database connection handle.

setCon

public void setCon(java.sql.Connection con)
Parameters:
con - Set (store) the current connection to IntraSEC by this object.

getFbds

public SEHRDataSource getFbds()
Returns:
Returns the fbds.

setFbds

public void setFbds(SEHRDataSource fbds)
Parameters:
fbds - The fbds to set.

getSYSHOME

public java.lang.String getSYSHOME()
Returns:
syshome Returns the 'home' path of the system

getRunningCfgFile

public java.lang.String getRunningCfgFile()

initDBConnection

public void initDBConnection()
Init a db connection to zone admin db using settings of this object


isSEHRCfgLoaded

public boolean isSEHRCfgLoaded()
Simple check wether the SEHR object was loaded (is available).

Use this method to check if the configuration is avbl. and the db 'intrasec' is accessable

Returns:
'true' if running cfg is avlb. otherwise 'false'

isSEHRCfgProp

public boolean isSEHRCfgProp()
Check wether SEHR environment is initialized (configuration is avlb.)

Returns:
'true' if running cfg is avlb. otherwise 'false'

loadSEHRCfg

public boolean loadSEHRCfg()
Load SEHR configuration by searching for the running configuration

Use this method to get/init the SEHR configuration for all modules.
The configuration file is placed at 'path_to_sehrroot/etc/.sehr' by convention. If the server has been started (with default or another configuration file using option -c) the running configuration is stored as 'path_to_sehrroot/tmp/.running'.
This method tries to get the running configuration using some methods to find it.
To use another configuration file use
'loadSEHRCfg(fullpath_and_name)'
If the SEHR service host(ip and port) is known use
'loadSEHRCfg(ip, port)'
If the SEHR module/client is running on the same host (localhost) just use
'loadSEHRCfg('127.0.0.1', port)'

Note:
Keep in mind that there must be finally a physical request to the local configuration file - You can't hop to an external SEHR node configuration file due to important security aspects!


loadSEHRCfg

public boolean loadSEHRCfg(java.lang.String host,
                           int port)
Get the configuration from the running server.

This is a helper function to get the path and name of the configuration file on a running server. If the server is not running the method returns "false".
This method also usable as an indicator for a well running SEHR core.

Parameters:
host -
port -

loadSEHRCfg

public boolean loadSEHRCfg(java.lang.String f)
Load SEHR configuration from a given configuration file.


getCssfile

public java.lang.String getCssfile()
Get the style file for WEB pages.

Notes:
The default CSS file to use is defined in WEB.XML
Path must be included within HTML code and depends on the location the styles are located

Returns:
cssfile file w/o path

isNULLOrEmpty

public static boolean isNULLOrEmpty(java.lang.String s)
Check if a given String is null or empty.

Returns:
'true' if null or empty

trimnull

public static java.lang.String trimnull(java.lang.String s)
Helper method to set 'null' strings to "" strings for a better review from database. If string is not null the string itself is returned trimmed.

The method is static so it can be used by other classes :)

Returns:
string

readSEHRCfgFileToProp

public void readSEHRCfgFileToProp(java.lang.String file)
                           throws java.io.IOException
Deprecated. (for downgrading compatibility)

from modules use 'loadSEHRCfg()'

This method reads the configuration file and generates a prop object

Throws:
java.io.IOException

readSEHRCfgFile

public boolean readSEHRCfgFile(java.lang.String file)
Read configuration file and store key value pairs as properties.

Use

  • 'loadSEHRCfg()' to get DEFAULT SEHR configuration.
  • 'loadSEHRCfg(file)' to use a specific SEHR configuration.
  • Returns:
    (boolean) true if configuration was loaded successfully

    saveCfgFile

    public void saveCfgFile(java.lang.String file)
                     throws java.io.IOException
    Save configuration in memory as configuration property file

    This method is used by the SEHRServer task to store the 'runnning' configuration and may be used by the user to redefine settings...

    Throws:
    java.io.IOException

    getLogger

    public org.apache.log4j.Logger getLogger()

    logInfo

    public void logInfo(java.lang.String message)

    logDebug

    public void logDebug(java.lang.String message)

    logWarn

    public void logWarn(java.lang.String message)

    logError

    public void logError(java.lang.String message)

    main

    public static void main(java.lang.String[] args)