com.archibus.jobmanager
Interface EventHandlerContext

All Superinterfaces:
com.archibus.utility.ThreadLocal

public interface EventHandlerContext
extends com.archibus.utility.ThreadLocal

Describes event handler execution context. The context provides uniform access to named parameters from two sources:

Input parameters that are defined in the workflow rule XML configuration are evaluated by Web Central before the event handler is called. For each <input> tag Web Central:

Supported input parameter types:

The <input-group> tags in the workflow rule XML configuration are treated differently. Each <input-group> tag contains an XPath query that is evaluated to a list of attributes, usually from incoming request action. All found attribute values are put in the new Map, that is in turn added to the input map as another input parameter, using @name attribute of the <input-group> tag as a map key.


Method Summary
 void addInputParameter(java.lang.String name, java.lang.Object value)
          Adds value to the input parameter map.
 void addResponseParameter(java.lang.String name, java.lang.Object value)
          Adds value to the response.
 boolean getBoolean(java.lang.String name)
          Returns parameter value converted to boolean type.
 boolean getBoolean(java.lang.String name, boolean defaultValue)
           
 void getDataRecordValues(DataRecord record)
          Set specified DataRecordDTO values from "fieldValues" and "oldFieldValues" input parameters.
 double getDouble(java.lang.String name)
          Returns parameter value converted to double type.
 double getDouble(java.lang.String name, double defaultValue)
           
 java.util.Map getInputs()
          Returns immutable Map of input parameters.
 int getInt(java.lang.String name)
          Returns parameter value converted to int type.
 int getInt(java.lang.String name, int defaultValue)
           
 org.json.JSONArray getJSONArray(java.lang.String name)
          Returns parameter value as JSON array.
 org.json.JSONObject getJSONObject(java.lang.String name)
          Returns parameter value as JSON object.
 org.json.JSONObject getJSONObject(java.lang.String name, org.json.JSONObject defaultValue)
           
 java.lang.Object getParameter(java.lang.String name)
          Returns formatted parameter value as Java object by name.
 java.lang.Object getParameter(java.lang.String name, java.lang.Object defaultValue)
           
 java.util.Map getParameters(java.lang.String name)
          Returns a named group of parameter values.
 java.util.Map getResponse()
          Returns immutable Map of response parameters.
 java.lang.String getString(java.lang.String name)
          Returns parameter value cast to String type.
 java.lang.String getString(java.lang.String name, java.lang.String defaultValue)
           
 int getViewFormatVersion()
          Returns view format version (1 for 1.0 views, 2 for 2.0 views) if specified in the context.
 boolean parameterExists(java.lang.String key)
          Checks whether named event handler parameter exists.
 boolean parameterExistsNotEmpty(java.lang.String key)
          Checks whether named event handler parameter exists and is not an empty string.
 void removeResponseParameter(java.lang.String name)
          Removes value from the response.
 void setResponse(DataRecord record)
          Adds single record to the response using JSON format.
 void setResponse(DataSet dataSet)
          Adds dataset to the response using JSON format.
 void setResponse(org.json.JSONObject json)
          Adds a JSON object to the response as "jsonExpression" parameter.
 void setResponse(java.util.List values)
          Adds a list of values to the response using JSON format.
 void setResponse(java.util.Map values)
          Adds a map of values to the response using JSON format.
 

Method Detail

getViewFormatVersion

int getViewFormatVersion()
Returns view format version (1 for 1.0 views, 2 for 2.0 views) if specified in the context. Default (if not specified) is 1.

Returns:

getParameter

java.lang.Object getParameter(java.lang.String name)
                              throws com.archibus.utility.ExceptionBase
Returns formatted parameter value as Java object by name. If name exists in both input map and response map, the response value is returned.

Parameters:
name - Parameter name, must not be null.
Returns:
Parameter value.
Throws:
com.archibus.utility.ExceptionBase - if name is specified (not null) but not found.

getParameter

java.lang.Object getParameter(java.lang.String name,
                              java.lang.Object defaultValue)
                              throws com.archibus.utility.ExceptionBase
Throws:
com.archibus.utility.ExceptionBase

getString

java.lang.String getString(java.lang.String name)
                           throws com.archibus.utility.ExceptionBase
Returns parameter value cast to String type. If name exists in both input map and response map, the response value is returned.

Parameters:
name - Parameter name, must not be null.
Returns:
Parameter value.
Throws:
com.archibus.utility.ExceptionBase - if name is specified (not null) but not found.

getString

java.lang.String getString(java.lang.String name,
                           java.lang.String defaultValue)
                           throws com.archibus.utility.ExceptionBase
Throws:
com.archibus.utility.ExceptionBase

getBoolean

boolean getBoolean(java.lang.String name)
                   throws com.archibus.utility.ExceptionBase
Returns parameter value converted to boolean type. If name exists in both input map and response map, the response value is returned.

Parameters:
name - Parameter name, must not be null.
Returns:
Parameter value.
Throws:
com.archibus.utility.ExceptionBase - if name is specified (not null) but not found.

getBoolean

boolean getBoolean(java.lang.String name,
                   boolean defaultValue)
                   throws com.archibus.utility.ExceptionBase
Throws:
com.archibus.utility.ExceptionBase

getInt

int getInt(java.lang.String name)
           throws com.archibus.utility.ExceptionBase
Returns parameter value converted to int type. If name exists in both input map and response map, the response value is returned.

Parameters:
name - Parameter name, must not be null.
Returns:
Parameter value.
Throws:
com.archibus.utility.ExceptionBase - if name is specified (not null) but not found.

getInt

int getInt(java.lang.String name,
           int defaultValue)
           throws com.archibus.utility.ExceptionBase
Throws:
com.archibus.utility.ExceptionBase

getDouble

double getDouble(java.lang.String name)
                 throws com.archibus.utility.ExceptionBase
Returns parameter value converted to double type. If name exists in both input map and response map, the response value is returned.

Parameters:
name - Parameter name, must not be null.
Returns:
Parameter value.
Throws:
com.archibus.utility.ExceptionBase - if name is specified (not null) but not found.

getDouble

double getDouble(java.lang.String name,
                 double defaultValue)
                 throws com.archibus.utility.ExceptionBase
Throws:
com.archibus.utility.ExceptionBase

getJSONObject

org.json.JSONObject getJSONObject(java.lang.String name)
                                  throws com.archibus.utility.ExceptionBase
Returns parameter value as JSON object.

Parameters:
name - Parameter name, must not be null.
Returns:
Parameter value.
Throws:
com.archibus.utility.ExceptionBase - if name is specified (not null) but not found.

getJSONObject

org.json.JSONObject getJSONObject(java.lang.String name,
                                  org.json.JSONObject defaultValue)
                                  throws com.archibus.utility.ExceptionBase
Throws:
com.archibus.utility.ExceptionBase

getJSONArray

org.json.JSONArray getJSONArray(java.lang.String name)
                                throws com.archibus.utility.ExceptionBase
Returns parameter value as JSON array.

Parameters:
name - Parameter name, must not be null.
Returns:
Parameter value.
Throws:
com.archibus.utility.ExceptionBase - if name is specified (not null) but not found.

getDataRecordValues

void getDataRecordValues(DataRecord record)
                         throws com.archibus.utility.ExceptionBase
Set specified DataRecordDTO values from "fieldValues" and "oldFieldValues" input parameters.

Throws:
com.archibus.utility.ExceptionBase

getParameters

java.util.Map getParameters(java.lang.String name)
                            throws com.archibus.utility.ExceptionBase
Returns a named group of parameter values.

Parameters:
name - Name of parameter.
Returns:
Map of parameter values keyed by parameter names.
Throws:
com.archibus.utility.ExceptionBase - if name is specified but not found or is not a Map.

getInputs

java.util.Map getInputs()
Returns immutable Map of input parameters. Event handler must not add, remove or change objects in this map.

Returns:
Map

getResponse

java.util.Map getResponse()
Returns immutable Map of response parameters. Event handler should not add, remove or change objects in this map. Use addResponseParameter()/removeResponseParameter() methods instead.

This method may return immutable Map in future releases.

Returns:
Map

parameterExists

boolean parameterExists(java.lang.String key)
Checks whether named event handler parameter exists.

Parameters:
key - Parameter key.
Returns:
true if the parameter exists and can be obtained via getParameter().

parameterExistsNotEmpty

boolean parameterExistsNotEmpty(java.lang.String key)
Checks whether named event handler parameter exists and is not an empty string.

Parameters:
key - Parameter key.
Returns:
true if the parameter exists and is not empty.

addInputParameter

void addInputParameter(java.lang.String name,
                       java.lang.Object value)
Adds value to the input parameter map. If specified name already exists in the response, the existing value is overridden.

Parameters:
name - Parameter name.
value - Parameter value.

addResponseParameter

void addResponseParameter(java.lang.String name,
                          java.lang.Object value)
Adds value to the response. If specified name already exists in the response, the existing value is overridden.

Parameters:
name - Parameter name.
value - Parameter value.

removeResponseParameter

void removeResponseParameter(java.lang.String name)
Removes value from the response. Has no effect if specified name does not exists in the response.

Parameters:
name - Parameter name.

setResponse

void setResponse(DataRecord record)
Adds single record to the response using JSON format.

Parameters:
record - DataRecordDTO

setResponse

void setResponse(DataSet dataSet)
Adds dataset to the response using JSON format.

Parameters:
dataSet - DataSet

setResponse

void setResponse(java.util.List values)
Adds a list of values to the response using JSON format.

Parameters:
records - List

setResponse

void setResponse(java.util.Map values)
Adds a map of values to the response using JSON format.

Parameters:
records - Map

setResponse

void setResponse(org.json.JSONObject json)
Adds a JSON object to the response as "jsonExpression" parameter.

Parameters:
json - JSONObject


Copyright © 2009 ARCHIBUS, Inc. All Rights Reserved.