IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.cs.rest.resource
Enum RestUtils

java.lang.Object
  extended by java.lang.Enum<RestUtils>
      extended by com.ibm.btt.cs.rest.resource.RestUtils
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<RestUtils>

public enum RestUtils
extends java.lang.Enum<RestUtils>


Enum Constant Summary
INSTANCE
           
 
Method Summary
 int checkSession(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Check if BTT Session is established or not
static JSONArray convertToArray(IndexedCollection ic, java.util.Locale loc, java.lang.String convType)
          Convert given Indexed Collection basing on give Locale and conversion type to JSONArray
 KeyedCollection convertToFlatKeyedCollection(JSONObject jo)
          Convert the JSONObject to KeyedCollection in flat format
 IndexedCollection convertToIndexedCollection(JSONArray ja)
          Convert the indexed collection to JSONArray
 IndexedCollection convertToIndexedCollection(JSONArray ja, java.lang.String name)
          Convert the indexed collection to JSONArray
static java.lang.String convertToJson(Context ctx, java.util.Locale loc, java.lang.String convType)
          Convert given Context basing on give Locale and conversion type to JSONObject then return it as String
static JSONObject convertToJson(KeyedCollection kc, java.util.Locale loc, java.lang.String convType)
          Convert given KeyedCollection basing on give Locale and conversion type to JSONObject
 KeyedCollection convertToKeyedCollection(JSONObject jo)
          Convert the JSONObject to KeyedCollection
 KeyedCollection convertToKeyedCollection(JSONObject jo, java.lang.String name)
          * Convert the keyed collection to JSONObject
 void convertToStringJSON(JSONObject json)
           
 void convertToStringJSONArray(JSONArray json)
           
 JSONObject establishSession(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Establish a new BTT session then return the session context
 JSONObject executeFlow(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, java.lang.String flowName, java.lang.String procId, JSONObject flowParams)
          Execute processor/flow with give processor/flow id or instance id, and necessary parameters, then return the flow context at current state
 JSONObject executeOperation(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp, java.lang.String operationName, JSONObject operationParams)
          Execute the operation of give name with specified parameters, then return the operation context as JSONObject
 JSONArray filterJSONArray(JSONArray arr,  params)
          Filter given JSONArray basing on given parameters.
 java.lang.String getCurrentSessionId(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Find current BTT session id from BTT Channel Driver
 Context getFlowContext(javax.servlet.http.HttpServletRequest req, java.lang.String flowName, java.lang.String procId)
           
 JSONObject getFlowContext(java.lang.String sid, java.lang.String flowName, java.lang.String procId)
          Return processor/flow context by given session id, flow id and instance id.
 JSONObject getFlowContextJSON(javax.servlet.http.HttpServletRequest req, java.lang.String flowName, java.lang.String procId)
          Return the specific processor/flow context by given http request, flow id and instance id
 java.lang.Object getHierarchyContextData(JSONObject json, java.lang.String[] datanames)
          Return hierarchy context as JSONObject or JSONArray by given datanames
 java.lang.String getJSONP(java.lang.String callback, JSONArray json)
          Return JSONP String for given JSONArray
 JSONObject getOperationContext(javax.servlet.http.HttpServletRequest req, java.lang.String operationName)
          Return Operation Context by give http request and operation name.
 JSONObject getOperationContext(java.lang.String sid, java.lang.String operationName)
          Return Operation Context by given session id and operation name
 Context getSessionContext(javax.servlet.http.HttpServletRequest req)
          Find current session context
 Context getSessionContext(java.lang.String sid)
          Find session context for specified session id
 JSONObject getSessionContextJSON(javax.servlet.http.HttpServletRequest req)
          Return current session context as JSON Object
 JSONObject getSessionContextJSON(java.lang.String sid)
          Get current session context for specified session id
 JSONObject paginateJSONArray(JSONArray input, int start, int end)
          Extract a set of JSONArray by given pagination parameters, then return them inside a JSONObject
 BTTServerOperation readOperation(java.lang.String operationName)
          Read Operation definition
 Processor readProcessor(java.lang.String processorName)
          Read processor/flow definition
 boolean removeFlowContext(javax.servlet.http.HttpServletRequest req, java.lang.String flowName, java.lang.String procId)
          Destroy the flow/processor context, find the context by processor id, then remove it out of HtmlProcessorManager context table.
 boolean removeHierarchyContextData(JSONObject json, java.lang.String[] datanames)
          Delete specified context data
 boolean removeOperationContext(javax.servlet.http.HttpServletRequest req, java.lang.String operationName)
          Set specified context data value to null
 void setFlowContext(javax.servlet.http.HttpServletRequest req, java.lang.String flowName, java.lang.String procId, JSONObject json)
          Set processor/flow Context for specified processor/flow id and instance id
 void setOperationContext(javax.servlet.http.HttpServletRequest req, java.lang.String operationName, JSONObject json)
          Set session context for specified operation
 void setSessionContext(javax.servlet.http.HttpServletRequest req, JSONObject json)
          Set session context
 JSONArray sortJSONArray(JSONArray arr, java.lang.String params)
          Sort JSONArray members basing on give sorting parameters.
 boolean updateHierarchyContextData(JSONObject json, java.lang.String[] datanames, java.lang.Object value)
          Update the hierarchy context data with given value
static RestUtils valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static RestUtils[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

INSTANCE

public static final RestUtils INSTANCE
Method Detail

values

public static RestUtils[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (RestUtils c : RestUtils.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static RestUtils valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

convertToArray

public static JSONArray convertToArray(IndexedCollection ic,
                                       java.util.Locale loc,
                                       java.lang.String convType)
Convert given Indexed Collection basing on give Locale and conversion type to JSONArray

Parameters:
ic -
loc -
convType -
Returns:
the result JSONArray

convertToJson

public static java.lang.String convertToJson(Context ctx,
                                             java.util.Locale loc,
                                             java.lang.String convType)
Convert given Context basing on give Locale and conversion type to JSONObject then return it as String

Parameters:
ctx -
loc -
convType -
Returns:

convertToJson

public static JSONObject convertToJson(KeyedCollection kc,
                                       java.util.Locale loc,
                                       java.lang.String convType)
Convert given KeyedCollection basing on give Locale and conversion type to JSONObject

Parameters:
kc -
loc -
convType -
Returns:

checkSession

public int checkSession(javax.servlet.http.HttpServletRequest req,
                        javax.servlet.http.HttpServletResponse resp)
                 throws java.lang.Exception
Check if BTT Session is established or not

Parameters:
req -
resp -
Returns:
Throws:
java.lang.Exception

convertToFlatKeyedCollection

public KeyedCollection convertToFlatKeyedCollection(JSONObject jo)
Convert the JSONObject to KeyedCollection in flat format

Parameters:
jo -
Returns:

convertToIndexedCollection

public IndexedCollection convertToIndexedCollection(JSONArray ja)
Convert the indexed collection to JSONArray

Parameters:
ic - the indexed collection
Returns:
the JSONArray

convertToIndexedCollection

public IndexedCollection convertToIndexedCollection(JSONArray ja,
                                                    java.lang.String name)
Convert the indexed collection to JSONArray

Parameters:
ic - the indexed collection
Returns:
the JSONArray

convertToKeyedCollection

public KeyedCollection convertToKeyedCollection(JSONObject jo)
Convert the JSONObject to KeyedCollection

Parameters:
jo - the JSONObject
Returns:
the converted JSON object

convertToKeyedCollection

public KeyedCollection convertToKeyedCollection(JSONObject jo,
                                                java.lang.String name)
* Convert the keyed collection to JSONObject

Parameters:
kc - the keyed collection
Returns:
the converted JSON object

convertToStringJSON

public void convertToStringJSON(JSONObject json)
                         throws JSONException
Parameters:
json -
Throws:
JSONException

convertToStringJSONArray

public void convertToStringJSONArray(JSONArray json)
                              throws JSONException
Parameters:
json -
Throws:
JSONException

establishSession

public JSONObject establishSession(javax.servlet.http.HttpServletRequest req,
                                   javax.servlet.http.HttpServletResponse resp)
                            throws java.lang.Exception
Establish a new BTT session then return the session context

Parameters:
req -
resp -
Returns:
Throws:
java.lang.Exception

executeFlow

public JSONObject executeFlow(javax.servlet.http.HttpServletRequest req,
                              javax.servlet.http.HttpServletResponse resp,
                              java.lang.String flowName,
                              java.lang.String procId,
                              JSONObject flowParams)
                       throws java.lang.Exception
Execute processor/flow with give processor/flow id or instance id, and necessary parameters, then return the flow context at current state

Parameters:
req -
resp -
flowName -
procId -
flowParams -
Returns:
Throws:
java.lang.Exception

executeOperation

public JSONObject executeOperation(javax.servlet.http.HttpServletRequest req,
                                   javax.servlet.http.HttpServletResponse resp,
                                   java.lang.String operationName,
                                   JSONObject operationParams)
                            throws java.lang.Exception
Execute the operation of give name with specified parameters, then return the operation context as JSONObject

Parameters:
req -
resp -
operationName -
operationParams -
Returns:
Throws:
java.lang.Exception

filterJSONArray

public JSONArray filterJSONArray(JSONArray arr,
                                  params)
                          throws java.lang.Exception
Filter given JSONArray basing on given parameters.

Parameters:
arr -
params -
Returns:
Throws:
java.lang.Exception

getCurrentSessionId

public java.lang.String getCurrentSessionId(javax.servlet.http.HttpServletRequest req,
                                            javax.servlet.http.HttpServletResponse resp)
                                     throws java.lang.Exception
Find current BTT session id from BTT Channel Driver

Parameters:
req -
resp -
Returns:
Throws:
java.lang.Exception

getFlowContextJSON

public JSONObject getFlowContextJSON(javax.servlet.http.HttpServletRequest req,
                                     java.lang.String flowName,
                                     java.lang.String procId)
                              throws java.lang.Exception
Return the specific processor/flow context by given http request, flow id and instance id

Parameters:
req -
flowName -
procId -
Returns:
Throws:
java.lang.Exception

getFlowContext

public Context getFlowContext(javax.servlet.http.HttpServletRequest req,
                              java.lang.String flowName,
                              java.lang.String procId)
                       throws java.lang.Exception
Parameters:
req -
flowName -
procId -
Returns:
Throws:
java.lang.Exception

getFlowContext

public JSONObject getFlowContext(java.lang.String sid,
                                 java.lang.String flowName,
                                 java.lang.String procId)
                          throws java.lang.Exception
Return processor/flow context by given session id, flow id and instance id.

Parameters:
sid -
flowName -
procId -
Returns:
Throws:
java.lang.Exception

getHierarchyContextData

public java.lang.Object getHierarchyContextData(JSONObject json,
                                                java.lang.String[] datanames)
                                         throws java.lang.Exception
Return hierarchy context as JSONObject or JSONArray by given datanames

Parameters:
json -
datanames -
Returns:
Throws:
java.lang.Exception

getJSONP

public java.lang.String getJSONP(java.lang.String callback,
                                 JSONArray json)
Return JSONP String for given JSONArray

Parameters:
callback -
json -
Returns:

getOperationContext

public JSONObject getOperationContext(javax.servlet.http.HttpServletRequest req,
                                      java.lang.String operationName)
                               throws java.lang.Exception
Return Operation Context by give http request and operation name.

Parameters:
req -
operationName -
Returns:
Throws:
java.lang.Exception

getOperationContext

public JSONObject getOperationContext(java.lang.String sid,
                                      java.lang.String operationName)
                               throws java.lang.Exception
Return Operation Context by given session id and operation name

Parameters:
sid -
operationName -
Returns:
Throws:
java.lang.Exception

getSessionContext

public Context getSessionContext(javax.servlet.http.HttpServletRequest req)
                          throws java.lang.Exception
Find current session context

Parameters:
req -
Returns:
Throws:
java.lang.Exception

getSessionContext

public Context getSessionContext(java.lang.String sid)
                          throws java.lang.Exception
Find session context for specified session id

Parameters:
sid -
Returns:
Throws:
java.lang.Exception

getSessionContextJSON

public JSONObject getSessionContextJSON(javax.servlet.http.HttpServletRequest req)
                                 throws java.lang.Exception
Return current session context as JSON Object

Parameters:
req -
Returns:
Throws:
java.lang.Exception

getSessionContextJSON

public JSONObject getSessionContextJSON(java.lang.String sid)
                                 throws java.lang.Exception
Get current session context for specified session id

Parameters:
sid -
Returns:
Throws:
java.lang.Exception

paginateJSONArray

public JSONObject paginateJSONArray(JSONArray input,
                                    int start,
                                    int end)
                             throws JSONException
Extract a set of JSONArray by given pagination parameters, then return them inside a JSONObject

Parameters:
input -
start -
end -
Returns:
Throws:
JSONException

readOperation

public BTTServerOperation readOperation(java.lang.String operationName)
                                 throws DSEInvalidRequestException
Read Operation definition

Parameters:
operationName -
Returns:
Throws:
DSEInvalidRequestException

readProcessor

public Processor readProcessor(java.lang.String processorName)
                        throws DSEInvalidRequestException
Read processor/flow definition

Parameters:
processorName -
Returns:
Throws:
DSEInvalidRequestException

removeFlowContext

public boolean removeFlowContext(javax.servlet.http.HttpServletRequest req,
                                 java.lang.String flowName,
                                 java.lang.String procId)
                          throws java.lang.Exception
Destroy the flow/processor context, find the context by processor id, then remove it out of HtmlProcessorManager context table.

Parameters:
req - the original HttpServletRequest
flowName - the name of the processor/flow
procId - the id of the processor/flow instance
Returns:
true for destroyed the context successfully, false for not found or any error occurred
Throws:
java.lang.Exception

removeHierarchyContextData

public boolean removeHierarchyContextData(JSONObject json,
                                          java.lang.String[] datanames)
                                   throws java.lang.Exception
Delete specified context data

Parameters:
json -
datanames -
Returns:
Throws:
java.lang.Exception

removeOperationContext

public boolean removeOperationContext(javax.servlet.http.HttpServletRequest req,
                                      java.lang.String operationName)
Set specified context data value to null

Parameters:
req -
operationName -
Returns:

setFlowContext

public void setFlowContext(javax.servlet.http.HttpServletRequest req,
                           java.lang.String flowName,
                           java.lang.String procId,
                           JSONObject json)
                    throws java.lang.Exception
Set processor/flow Context for specified processor/flow id and instance id

Parameters:
req -
flowName -
procId -
json -
Throws:
java.lang.Exception

setOperationContext

public void setOperationContext(javax.servlet.http.HttpServletRequest req,
                                java.lang.String operationName,
                                JSONObject json)
                         throws java.lang.Exception
Set session context for specified operation

Parameters:
req -
operationName -
json -
Throws:
java.lang.Exception

setSessionContext

public void setSessionContext(javax.servlet.http.HttpServletRequest req,
                              JSONObject json)
                       throws java.lang.Exception
Set session context

Parameters:
req -
json -
Throws:
java.lang.Exception

sortJSONArray

public JSONArray sortJSONArray(JSONArray arr,
                               java.lang.String params)
                        throws java.lang.Exception
Sort JSONArray members basing on give sorting parameters. The params should be a String like "(+foo,-bar)"

Parameters:
arr -
params -
Returns:
Throws:
java.lang.Exception

updateHierarchyContextData

public boolean updateHierarchyContextData(JSONObject json,
                                          java.lang.String[] datanames,
                                          java.lang.Object value)
                                   throws java.lang.Exception
Update the hierarchy context data with given value

Parameters:
json -
datanames -
value -
Returns:
Throws:
java.lang.Exception

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011