jpl.mipl.pgs.utils.upf
Class UPF

java.lang.Object
  extended by jpl.mipl.pgs.utils.upf.UPF
All Implemented Interfaces:
Serializable

public class UPF
extends Object
implements Serializable

Allows parsing of User Preference File. The UPF object allows users to specify simple parameters such as


 <pgs>
   <upf>
     <logDir>somedir</logDir>
   </upf>
 </pgs>
 
to more complex and dynamic parameters such as using the <script></script> element. Refer to UPF Users Guide for more information.
 
      Copyright 2002-PRESENT, California Institute of Technology.
      ALL RIGHTS RESERVED.
      U.S. Government Sponsorship acknowledge.
 
   

Version:
1.0
Author:
Raj Patel (rrp@mipl.jpl.nasa.gov), Cecilia Cheng (csc@mipl)
See Also:
Serialized Form

Nested Class Summary
static class UPF.MyErrorHandler
           
 
Field Summary
static String CONTEXT
          Identifies vairables that needs to be added into the context
static String DATASOURCE_TIMEOUT
          Time to wait for data from also refer to also refer to DATASOURCE_TYPE before giving up
static String DATASOURCE_TYPE
          Valid values are tds, fei5 or dom (not supported yet)
static String DEFAULT_PGS_UPF_SCHEMA_FILE_NAME
          The default PGS schema name.
static String ENV
          Environment variable that can be referenced anywhere in the UPF or JVM (if so defined)
static String FEI5
          Valid values are 'ON' or 'OFF'.
static String FEI5_DOMAIN
          The domain file that is to be used by FEI5.
static String FEI5_KEYSTORE
          The FEI keystore.
static String FEI5_OUTPUT_DIR
          The directory where output from FEI5 are placed
static String FEI5_OUTPUT_TYPE
          Valid values are DIRECTORY or MEMORY.
static String FEI5_PASSWORD
          The password associated with also refer to FEI5_USERNAME
static String FEI5_QUERY
          The query that is to be used to query FEI5.
static String FEI5_SECURITY_MODEL
          The security model to be used when communicating with FEI5.
static String FEI5_SOURCE_FILE_EXTNS
          Files with these file extensions are queried from also refer to FEI5_SOURCE_FILE_TYPES.
static String FEI5_SOURCE_FILE_TYPES
          The file type that are to be queried for files.
static String FEI5_USERNAME
          The user name for logging into FEI5.
static String LOG_DIR
          Deprecated. Instead use LoggerFactory
static String LOG_FILE_PREFIX
          Deprecated. Instead use LoggerFactory
static String LOG_FILE_SIZE
          Deprecated. Instead use LoggerFactory
static String MONITOR_FREQUENCY
          Used by Service Factory
static String PASSWD
          The password associated with also refer to USERID
static String PD_NAME
          A descriptive name given to the PD.
static String PERSTORE
          Indicates weather persistent is to be performed during PI run.
static String PGS_VALIDATE_PD
           
static String PROCESS_DEFINITION_FILE_NAME
          Fully qualified name of process definition that is to be executed.
static String PROCESS_DEFINITION_NAME
          The name of process definition as stored in persistent store that is to be executed.
static String PROCESS_DEFINITION_VERSION
          The version of process definition as stored in persistent store that is to be executed.
static String PROCESS_INSTANCE_ID
          The id of the process instance to rerun.
static String REQUEST_CHECK_FREQUENCY
          Used by Controller
static String REQUEST_UPF
          Key used in the JBPM Context to pass the UPF object around.
static String SCRIPT
          Used in creating script element
static String SCRIPT_EXPRESSION
          Used in creating script expression
static String SCRIPT_FILE
          Used in referencing a script file name
static String SCRIPT_PARAM
          Used in creating script parameter
static String TDS_HOST
          The host where the TDS server is running.
static String TDS_PORT
          The port on also refer to TDS_HOST that the server is listening to.
static String TDS_PVL_FILE_NAME
          Fully qualified name of the file containing a valid PVL query.
static String TDS_SFDU_FILE
          Fully qualified name of the file containing SFDU's.
static String TDS_SFDU_SOURCE
          Valid values are file or server.
static String USERID
          The user id as assigned by PGS.
 
Constructor Summary
UPF(String upfFileName)
          Parse the given UPF file without validating it against any XML schema.
UPF(StringBuffer upfFileContent, String upfFileName)
          Parses the given StringBuffer which contains the content of an UPF file.
UPF(String upfFileName, String schemaFileName)
          Parse the given UPF file and validate against the given schema.
 
Method Summary
 Vector<String> getAllValues(String keyword)
          For obtaining the values of a multivalued keyword that is repeated more than once.
 Vector<Map<String,String>> getAttributes(String key)
          Return all attributes associated with the named parameter or null if the key is not specified.
 Hashtable getAttributes(String key, int instanceNo)
          Return attributes associated with the instanceNo instance of the key as hashtable where the key is the attribute's local name.
 Map<String,String> getContextVariables()
          Return all variables that are marked as context variables.
 String getFileName()
          Returns the name of the associated UPF file.
 Enumeration getKeywords()
           
 String getLastAttributeValue(String key, String attributeName)
          Return the named attribute associated with the named parameter or null if the key is not specified or the attribute is not specified.
 String getLastValue(String keyword)
          For obtaining the last instance of a multivalued keyword that is repeated more than once.
 String getNthValue(String keyword, int index)
          For obtaining the instance at the given index of a multivalued keyword that is repeated more than once.
static String getPGSUPFSchemaFileName()
          Returns the default UPF schema name(which is ${PGS_CONFIG_DIR}/UPF.xsd).
 Vector<Script> getScripts()
          Returns all scripts associated with this UPF.
 String getUPF()
          Returns the entire UPF, in it's raw form, as it was received.
protected  void parseUPFContent(StringBuffer upfFileContent)
           
protected  Object removeKey(String key)
           
 Map<String,Vector<String>> toMap()
          Returns the given UPF as Hashtable.
 Map<String,String> toSingleValueMap()
          Returns the given UPF as Hashtable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PGS_VALIDATE_PD

public static final String PGS_VALIDATE_PD
See Also:
Constant Field Values

REQUEST_UPF

public static final String REQUEST_UPF
Key used in the JBPM Context to pass the UPF object around.

See Also:
Constant Field Values

DEFAULT_PGS_UPF_SCHEMA_FILE_NAME

public static final String DEFAULT_PGS_UPF_SCHEMA_FILE_NAME
The default PGS schema name.

See Also:
Constant Field Values

PD_NAME

public static final String PD_NAME
A descriptive name given to the PD. This name is used when printing messages to associate messages with PD names.

See Also:
Constant Field Values

LOG_DIR

public static final String LOG_DIR
Deprecated. Instead use LoggerFactory
The directory where log files are created.

See Also:
Constant Field Values

LOG_FILE_PREFIX

public static final String LOG_FILE_PREFIX
Deprecated. Instead use LoggerFactory
The prefix of the log file name

See Also:
Constant Field Values

LOG_FILE_SIZE

public static final String LOG_FILE_SIZE
Deprecated. Instead use LoggerFactory
The size of the log file. After this size, the file is rolled and a new log file is created.

See Also:
Constant Field Values

DATASOURCE_TYPE

public static final String DATASOURCE_TYPE
Valid values are tds, fei5 or dom (not supported yet)

See Also:
Constant Field Values

DATASOURCE_TIMEOUT

public static final String DATASOURCE_TIMEOUT
Time to wait for data from also refer to also refer to DATASOURCE_TYPE before giving up

See Also:
Constant Field Values

TDS_SFDU_SOURCE

public static final String TDS_SFDU_SOURCE
Valid values are file or server. Only applicable if also refer to DATASOURCE_TYPE = TDS

See Also:
Constant Field Values

TDS_SFDU_FILE

public static final String TDS_SFDU_FILE
Fully qualified name of the file containing SFDU's. Only applicable if also refer to TDS_SFDU_SOURCE = FILE

See Also:
Constant Field Values

TDS_HOST

public static final String TDS_HOST
The host where the TDS server is running. Only applicable if also refer to DATASOURCE_TYPE = TDS

See Also:
Constant Field Values

TDS_PORT

public static final String TDS_PORT
The port on also refer to TDS_HOST that the server is listening to. Only applicable if also refer to DATASOURCE_TYPE = TDS

See Also:
Constant Field Values

TDS_PVL_FILE_NAME

public static final String TDS_PVL_FILE_NAME
Fully qualified name of the file containing a valid PVL query. Only applicable if also refer to DATASOURCE_TYPE = TDS

See Also:
Constant Field Values

FEI5_SOURCE_FILE_TYPES

public static final String FEI5_SOURCE_FILE_TYPES
The file type that are to be queried for files. Only applicable if also refer to DATASOURCE_TYPE = FEI5

See Also:
Constant Field Values

FEI5_SOURCE_FILE_EXTNS

public static final String FEI5_SOURCE_FILE_EXTNS
Files with these file extensions are queried from also refer to FEI5_SOURCE_FILE_TYPES. Only applicable if also refer to DATASOURCE_TYPE = FEI5

See Also:
Constant Field Values

FEI5_OUTPUT_TYPE

public static final String FEI5_OUTPUT_TYPE
Valid values are DIRECTORY or MEMORY. DIRECTORY means that output file are to be written to the directory specified by also refer to FEI5_OUTPUT_DIR

See Also:
Constant Field Values

FEI5_OUTPUT_DIR

public static final String FEI5_OUTPUT_DIR
The directory where output from FEI5 are placed

See Also:
Constant Field Values

FEI5_QUERY

public static final String FEI5_QUERY
The query that is to be used to query FEI5.

See Also:
Constant Field Values

FEI5

public static final String FEI5
Valid values are 'ON' or 'OFF'. 'ON' means FEI will be used for sending data.

See Also:
Constant Field Values

FEI5_DOMAIN

public static final String FEI5_DOMAIN
The domain file that is to be used by FEI5. Default is to use the one in $FEI5 directory.

See Also:
Constant Field Values

FEI5_KEYSTORE

public static final String FEI5_KEYSTORE
The FEI keystore. Default is to use one in $FEI5 directory.

See Also:
Constant Field Values

FEI5_SECURITY_MODEL

public static final String FEI5_SECURITY_MODEL
The security model to be used when communicating with FEI5. See FEI5 documentation for more details. Default is SSL.

See Also:
Constant Field Values

FEI5_USERNAME

public static final String FEI5_USERNAME
The user name for logging into FEI5.

See Also:
Constant Field Values

FEI5_PASSWORD

public static final String FEI5_PASSWORD
The password associated with also refer to FEI5_USERNAME

See Also:
Constant Field Values

USERID

public static final String USERID
The user id as assigned by PGS. This user id is used in user authentication and authorization.

See Also:
Constant Field Values

PASSWD

public static final String PASSWD
The password associated with also refer to USERID

See Also:
Constant Field Values

REQUEST_CHECK_FREQUENCY

public static final String REQUEST_CHECK_FREQUENCY
Used by Controller

See Also:
Constant Field Values

MONITOR_FREQUENCY

public static final String MONITOR_FREQUENCY
Used by Service Factory

See Also:
Constant Field Values

PROCESS_DEFINITION_FILE_NAME

public static final String PROCESS_DEFINITION_FILE_NAME
Fully qualified name of process definition that is to be executed.

See Also:
Constant Field Values

PROCESS_DEFINITION_NAME

public static final String PROCESS_DEFINITION_NAME
The name of process definition as stored in persistent store that is to be executed. Note that the value of jpl.mipl.pgs.utils.Configuration#PERSTORE must not be 'OFF' when using this variable.

See Also:
Constant Field Values

PROCESS_DEFINITION_VERSION

public static final String PROCESS_DEFINITION_VERSION
The version of process definition as stored in persistent store that is to be executed. Note that the value of also refer to PERSTORE must not be 'OFF' when using this variable. The default is to use latest process definition.

See Also:
Constant Field Values

PROCESS_INSTANCE_ID

public static final String PROCESS_INSTANCE_ID
The id of the process instance to rerun. Also refer to PROCESS_DEFINITION_NAME

See Also:
Constant Field Values

PERSTORE

public static final String PERSTORE
Indicates weather persistent is to be performed during PI run. Valid values are 'ON' or 'OFF'. Applies to PI execution and persistence only.

See Also:
Constant Field Values

SCRIPT

public static final String SCRIPT
Used in creating script element

See Also:
Constant Field Values

SCRIPT_PARAM

public static final String SCRIPT_PARAM
Used in creating script parameter

See Also:
Constant Field Values

SCRIPT_EXPRESSION

public static final String SCRIPT_EXPRESSION
Used in creating script expression

See Also:
Constant Field Values

SCRIPT_FILE

public static final String SCRIPT_FILE
Used in referencing a script file name

See Also:
Constant Field Values

ENV

public static final String ENV
Environment variable that can be referenced anywhere in the UPF or JVM (if so defined)

See Also:
Constant Field Values

CONTEXT

public static final String CONTEXT
Identifies vairables that needs to be added into the context

See Also:
Constant Field Values
Constructor Detail

UPF

public UPF(String upfFileName)
    throws Exception
Parse the given UPF file without validating it against any XML schema.

Parameters:
upfFileName - Complete pathname of the UPF file.
Throws:
Exception - If the UPF file name is null, the specified UPF file does not exists, or is unreadable or if the UPF file is ill formated.

UPF

public UPF(String upfFileName,
           String schemaFileName)
    throws Exception
Parse the given UPF file and validate against the given schema.

Parameters:
upfFileName - Complete pathname of the UPF file.
schemaFileName - Complete pathname of the schema file to use to validate the given UPF file.
Throws:
Exception - If the UPF file name is null, the specified UPF file does not exists, or is unreadable or if the UPF file is ill formated.

UPF

public UPF(StringBuffer upfFileContent,
           String upfFileName)
    throws Exception
Parses the given StringBuffer which contains the content of an UPF file.

Parameters:
upfFileContent - The content of the UPF file.
upfFileName - The name of the UPF file whose content is supplied in upfFileContent. This is an optional parameter.
Throws:
Exception - If the upfFileContent is null or if the content of UPF is ill formated.
Method Detail

removeKey

protected Object removeKey(String key)

parseUPFContent

protected void parseUPFContent(StringBuffer upfFileContent)
                        throws Exception
Throws:
Exception

getContextVariables

public Map<String,String> getContextVariables()
Return all variables that are marked as context variables.


getScripts

public Vector<Script> getScripts()
Returns all scripts associated with this UPF.


getPGSUPFSchemaFileName

public static String getPGSUPFSchemaFileName()
Returns the default UPF schema name(which is ${PGS_CONFIG_DIR}/UPF.xsd).


getKeywords

public Enumeration getKeywords()
Returns:
All of the keywords specified in the associated UPF as Strings

getAllValues

public Vector<String> getAllValues(String keyword)
For obtaining the values of a multivalued keyword that is repeated more than once.

Parameters:
keyword - The String that represents the keyword
Returns:
null if the keyword does not exists. Otherwise returns a vector of values

getLastValue

public String getLastValue(String keyword)
For obtaining the last instance of a multivalued keyword that is repeated more than once.

Parameters:
keyword - The String that represents the keyword
Returns:
null if the keyword does not exists.

getNthValue

public String getNthValue(String keyword,
                          int index)
For obtaining the instance at the given index of a multivalued keyword that is repeated more than once. Starts from 0

Parameters:
keyword - The String that represents the keyword
Returns:
null if the keyword does not exists, or if the index is out of range Otherwise returns a vector of values

getFileName

public String getFileName()
Returns the name of the associated UPF file.


getUPF

public String getUPF()
Returns the entire UPF, in it's raw form, as it was received.


toSingleValueMap

public Map<String,String> toSingleValueMap()
Returns the given UPF as Hashtable. For multivalued key, the last value is returned.

Returns:
Map containing string as both it's key and value.

toMap

public Map<String,Vector<String>> toMap()
Returns the given UPF as Hashtable.

Returns:
Map with key of type sting and value is of type vector.

getAttributes

public Vector<Map<String,String>> getAttributes(String key)
Return all attributes associated with the named parameter or null if the key is not specified.

Returns:
a vector containing maps where the key in map is the name of the attribute and value at that key is the value of the attribute.

getLastAttributeValue

public String getLastAttributeValue(String key,
                                    String attributeName)
Return the named attribute associated with the named parameter or null if the key is not specified or the attribute is not specified. If the keyword and/or the attribute has more than one instance, the value associated with LAST instance is returned.

Returns:
the value of the attribute

getAttributes

public Hashtable getAttributes(String key,
                               int instanceNo)
Return attributes associated with the instanceNo instance of the key as hashtable where the key is the attribute's local name.

Parameters:
key - The key that is of interest.
instanceNo - the instance number that is of interest (base 0).
Returns:
Attributes attributes associated with the instance or null if the key or the instanceNo does not exists or there are no attributes associated with the key.