IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

com.ibm.btt.cs.html
Class HtmlRequestHandler

java.lang.Object
  extended by com.ibm.btt.clientserver.DSERequestHandler
      extended by com.ibm.btt.cs.html.HtmlRequestHandler
All Implemented Interfaces:
RequestHandler
Direct Known Subclasses:
AjaxHtmlRequestHandler, RemoteRequestHandler

public class HtmlRequestHandler
extends DSERequestHandler

Handle requests that are made from html clients. The btt.xml file for the server specifies this class name as the handler for html requests. One instance of it is created and held by the HandlerRegistry for use by all html clients.


Field Summary
 
Fields inherited from class com.ibm.btt.clientserver.DSERequestHandler
errorCode, javaClientException, javaClientTrace
 
Constructor Summary
HtmlRequestHandler()
          HtmlRequestHandler constructor comment.
 
Method Summary
protected  void addConseqInfoToSessionCtx(java.lang.String sessionId, KeyedCollection kcReqData)
          Adds to the session context the information needed to manage the processor's consequentiality.
protected  void addConseqInfoToSessionCtx(java.lang.String sessionId, java.lang.String applicationId, KeyedCollection kcReqData)
          Adds to the application session context the information needed to manage the processor's consequentiality.
protected  void addErrorInfo(BTTServerOperation oper, java.lang.String message)
          Adds to the operation context error information upgrading the existent array of error messages or creating it if it does not exist.
 void addFieldTo(Context ctx, java.lang.String name, java.lang.Object value)
          This method creates and adds a toolkit related field to the context passed in.
protected  void addRequiredDataToOperationCtx(Context opCtx, KeyedCollection kcReqData)
          The operation context requires some data to be added to it.
protected  void addRequiredDataToSessionCtx(java.lang.String sessionId, javax.servlet.http.HttpServletRequest req)
          The session context requires some data to be added to it.
protected  boolean areTransitionCtxErrors(Context trCtx)
          Returns true if any of the DataElements associated to this context has validation errors.
protected  void chainOperation(BTTServerOperation oper, java.lang.String sessionId, java.lang.String applicationId)
          Chains the operation or processor context to the right parent.
protected  void checkContextExistence(BTTServerOperation oper)
          just check the operation and operation context whether null, and throws exceptions with meaningful info.
 void checkForLocale(ChannelContext channelContext)
          Updates channel context's request data with the appropriate Locale.
protected  void commitSessionCtx(ChannelContext channelContext)
          commit session context to CHA server.
protected  java.lang.String createErrorMessage(java.lang.String type)
          Creates an appropriate error message depending on the error type.
(package private)  void destroySession(javax.servlet.http.HttpServletRequest req, java.lang.String sessionId)
           
 void endRequest(ChannelContext channelContext)
          Performs maintenance of the pending requests table stored in the requestValidationServices instance associated with this session.
 void endSessionRequest(ServerOperation anOperation)
          Closes the operation.
protected  java.lang.Object executeOperationRequest(ChannelContext channelContext)
          Excute operation request
protected  java.lang.Object executeProcessorRequest(ChannelContext channelContext)
          Excute processor request
 java.lang.Object executeRequest(ChannelContext channelContext)
          When a server is set up with the cookies flag in btt.xml set to false, then a DSEChannelSession object is used rather than an HttpSession.
 ServerOperation executeSessionRequest(ChannelContext channelContext)
          When a session is established, we need to call an operation which sets the context to hold data that is saved in the session.
protected  javax.servlet.http.HttpServletRequest getOrgRequest(ChannelContext channelContext)
           
protected  java.lang.String getProcessorId(ChannelContext channelContext)
          get processorId of the current processor, return null if not find
protected  RequestValidationServices getRVS(ChannelContext cc)
          Returns the RequestValidationServices instance associated with the current session.
protected  java.lang.String getSessionId(ChannelContext aChannelContext)
          Obtain the session id from the channel context.
protected  int indexOfInteger(java.lang.String address)
          TODO this method should be removed, pls refer updateContextForGrid() for reason This is a utility method used to obtain a number inside the given string.
 boolean isFirstRequest(RequestValidationServices rvs, ChannelContext chctx)
          Check whether the current request is first request.
protected  boolean isValidGridData(DataElement de, Context ctx)
          Here Just check whether a data field name is a IColl element.
 void manageValidationErrors(BTTServerOperation oper, javax.servlet.http.HttpServletRequest request, KeyedCollection kcReqData)
          Perform the necessary steps to manage validation errors.
 void preProcessRequest(ChannelContext channelContext)
          Adds current request to the pendingRequestTable
protected  void processAbnormalNavigation(ChannelContext channelContext, java.lang.String type)
          Manages an attempt of abnormal navigation detected.
 void processNavigation(ChannelContext channelContext)
          Process the request when there is no abnormal navigation.
 void processRequest(ChannelContext channelContext)
          Process the request originated from a request that already has a session
 void processSessionRequest(ChannelContext channelContext)
          This method is similar to processRequest, only back and double click validation are not performed as a new session is being established.
protected  void putProcessorIntoCache(DSEHtmlProcessorOperation oper)
          Gets the processor instance from the processor operation and puts it into cache in order to be reused by further requests.
protected  BTTServerOperation readOperation(java.lang.String operationName, boolean isProcessorOp, KeyedCollection kcReqData, java.lang.String sessionId)
          Returns an operation containing either the operation going to be executed or a processor operation encapsulating the processor to execute.
 void resetFlagForRVS(ChannelContext channelContext)
          Reset the coresponding flag for RVS
protected  void saveProcessor(DSEHtmlProcessorOperation oper, java.lang.String sessionId, java.lang.String applId)
          Saves the processor information needed to rebuild it in further requests for this processor.
 void setLocale(javax.servlet.http.HttpServletRequest req, Context ctx)
          Creates a new locale object from the headers information and stores it in the context.
protected  void setNextPageId(ChannelContext channelContext, BTTServerOperation theOperation, java.lang.String sessionId, java.lang.String applicationId, PresentationHandler presHandler)
          Updates the application session context with the next page id.
protected  void syncRequestEnd(ChannelContext channelContext)
           
protected  void syncRequestStart(ChannelContext channelContext)
          this method is used to synchronize the html channel and ajax channel to make sure that at one time just one channel request processed.
protected  void updateTimestamp(java.lang.String sessionId, java.lang.String appSessionId, Operation operation, ChannelContext channelContext)
          Updates the timestamp for this session and for the application session if it exists.
 
Methods inherited from class com.ibm.btt.clientserver.DSERequestHandler
checkExecutionPermission, executeSession, formatOpContext, getPresentationHandler, getRequestValue, getSessionContext, handleException, handleException, isNotNull, process, runInSession, setReplyFmt, tryToFormat, tryToUnformat, unFormatRequest, usingCookies
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HtmlRequestHandler

public HtmlRequestHandler()
HtmlRequestHandler constructor comment.

Method Detail

addConseqInfoToSessionCtx

protected void addConseqInfoToSessionCtx(java.lang.String sessionId,
                                         KeyedCollection kcReqData)
Adds to the session context the information needed to manage the processor's consequentiality.

Parameters:
sessionId - String
kcReqData - com.ibm.btt.base.KeyedCollection

addConseqInfoToSessionCtx

protected void addConseqInfoToSessionCtx(java.lang.String sessionId,
                                         java.lang.String applicationId,
                                         KeyedCollection kcReqData)
Adds to the application session context the information needed to manage the processor's consequentiality.

Parameters:
sessionId - String
applicationId - String
kcReqData - com.ibm.btt.base.KeyedCollection

addErrorInfo

protected void addErrorInfo(BTTServerOperation oper,
                            java.lang.String message)
                     throws DSEInvalidArgumentException,
                            DSEInvalidRequestException
Adds to the operation context error information upgrading the existent array of error messages or creating it if it does not exist.

Parameters:
oper - com.ibm.btt.base.DSEServerOperation The operation to upgrade
message - java.lang.String The message to add to the operation's context
Throws:
DSEInvalidArgumentException
DSEInvalidRequestException

addFieldTo

public void addFieldTo(Context ctx,
                       java.lang.String name,
                       java.lang.Object value)
                throws DSEInvalidRequestException
This method creates and adds a toolkit related field to the context passed in.

Parameters:
ctx - com.ibm.btt.base.Context The context where to add the new field
name - java.lang.String The name of the field to create
value - java.lang.Object The value of the field to create
Throws:
java.lang.Exception
DSEInvalidRequestException

addRequiredDataToOperationCtx

protected void addRequiredDataToOperationCtx(Context opCtx,
                                             KeyedCollection kcReqData)
The operation context requires some data to be added to it.

Parameters:
opCtx - com.ibm.btt.base.Context
kcReqData - com.ibm.btt.base.KeyedCollection

addRequiredDataToSessionCtx

protected void addRequiredDataToSessionCtx(java.lang.String sessionId,
                                           javax.servlet.http.HttpServletRequest req)
The session context requires some data to be added to it.

Parameters:
sessionId - java.lang.String
req - HttpServletRequest

areTransitionCtxErrors

protected boolean areTransitionCtxErrors(Context trCtx)
Returns true if any of the DataElements associated to this context has validation errors.

Parameters:
trCtx - com.ibm.btt.base.Context
Returns:
boolean

chainOperation

protected void chainOperation(BTTServerOperation oper,
                              java.lang.String sessionId,
                              java.lang.String applicationId)
                       throws DSEInvalidRequestException
Chains the operation or processor context to the right parent. It will be either an application session context, an application sub session context or any other predefined parent of the operation context.

Parameters:
oper - com.ibm.btt.base.DSEServerOperation
sessionId - java.lang.String
applicationId - java.lang.String
Throws:
DSEInvalidRequestException - There is no context associated with given sessionId or applicationId

checkForLocale

public void checkForLocale(ChannelContext channelContext)
                    throws java.lang.Exception
Updates channel context's request data with the appropriate Locale. It is got either from the information sent from client or from the system's default.

Parameters:
channelContext -
Throws:
java.lang.Exception

createErrorMessage

protected java.lang.String createErrorMessage(java.lang.String type)
Creates an appropriate error message depending on the error type. The error message that will be added to the operation can be customized through btt.xml. This method reads the Settings to assign the right error message depending on the type of error. If there is no customized error message a default one is assigned. There is a different default message for each different type of error.

Parameters:
type - String the type of abnormal navigation (pending, aging or unconsistent processor)

endRequest

public void endRequest(ChannelContext channelContext)
Performs maintenance of the pending requests table stored in the requestValidationServices instance associated with this session. Deletes the entry if noone is waiting as a double click, leaves it in the table updating its timestamp if there is minRequestResubmitTime defined and closes the operation if anyone else will need it.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext

endSessionRequest

public void endSessionRequest(ServerOperation anOperation)
Closes the operation.

Parameters:
anOperation - com.ibm.btt.base.ServerOperation

executeRequest

public java.lang.Object executeRequest(ChannelContext channelContext)
                                throws java.lang.Exception
When a server is set up with the cookies flag in btt.xml set to false, then a DSEChannelSession object is used rather than an HttpSession. The required actions to create, execute, and return an operation using a DSEChannelSession are performed here.

Overrides:
executeRequest in class DSERequestHandler
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Returns:
com.ibm.btt.base.ServerOperation
Throws:
java.lang.Exception

executeSessionRequest

public ServerOperation executeSessionRequest(ChannelContext channelContext)
                                      throws java.lang.Exception
When a session is established, we need to call an operation which sets the context to hold data that is saved in the session.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
java.lang.Exception

getRVS

protected RequestValidationServices getRVS(ChannelContext cc)
                                    throws DSEException
Returns the RequestValidationServices instance associated with the current session. If the session does not exist an exception is thrown, if the session does not have a requestValidationServices instance associated, a new one is created and returned, because it might be cause of a distributed environment. In distributed environments, some of the features of abnormal nabvigation will not work.

Parameters:
cc - com.ibm.btt.clientserver.ChannelContext ChannelContext used to get the session
Returns:
RequestValidationServices RequestValidationServices object associated with given session
Throws:
DSEException - Either it is not possible to retrieve a sessionId from the channelContext or there is no session associated with the sessionId.

getSessionId

protected java.lang.String getSessionId(ChannelContext aChannelContext)
Obtain the session id from the channel context. Returns the sessionId or null if there is no sessionId associated with this ChannelContext.

Overrides:
getSessionId in class DSERequestHandler
Parameters:
aChannelContext - com.ibm.btt.clientserver.ChannelContext
Returns:
java.lang.String

manageValidationErrors

public void manageValidationErrors(BTTServerOperation oper,
                                   javax.servlet.http.HttpServletRequest request,
                                   KeyedCollection kcReqData)
                            throws DSEInvalidArgumentException,
                                   DSEObjectNotFoundException
Perform the necessary steps to manage validation errors. These steps are the following: Update the operation context's errorFlag to true Set the operation or processor context to the request in order to give access to it from the PresentationHandler
If the request tries to execute a processor instead of an operation, following two steps are performed: Update operation context with processor specific information Replace the operation request context per the transition context if the erros happened whithin a transition context

Parameters:
oper - com.ibm.btt.base.DSEServerOperation The operation with errors
request - javax.servlet.HttpServletRequest request object
kcReqData - com.ibm.btt.base.KeyedCollection kColl received from client
Throws:
DSEInvalidArgumentException
DSEObjectNotFoundException

preProcessRequest

public void preProcessRequest(ChannelContext channelContext)
                       throws DSEException
Adds current request to the pendingRequestTable

Overrides:
preProcessRequest in class DSERequestHandler
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
DSEException - Is not possible to retrieve a valid RequestValidationServices for this session.

processAbnormalNavigation

protected void processAbnormalNavigation(ChannelContext channelContext,
                                         java.lang.String type)
                                  throws DSEException
Manages an attempt of abnormal navigation detected. These cases are all related with abnormal navigation support: pending requests, aging requests and unconsistent processor exceptions. The handling of these situations involve in all the cases following steps: Update operation context with error information about what has happened Do not execute the request but answer the client as if current request was the first one

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
type - java.lang.String The type of error
Throws:
DSEException

processNavigation

public void processNavigation(ChannelContext channelContext)
                       throws java.lang.Exception
Process the request when there is no abnormal navigation.

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
java.lang.Exception

processRequest

public void processRequest(ChannelContext channelContext)
Process the request originated from a request that already has a session

Specified by:
processRequest in interface RequestHandler
Overrides:
processRequest in class DSERequestHandler
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext

syncRequestStart

protected void syncRequestStart(ChannelContext channelContext)
                         throws DSEInvalidRequestException,
                                DSEObjectNotFoundException,
                                DSECSSessionNotEstablishedException,
                                DSEHtmlDoubleClickException
this method is used to synchronize the html channel and ajax channel to make sure that at one time just one channel request processed.

Parameters:
channelContext -
Throws:
DSEObjectNotFoundException
DSEInvalidRequestException
DSEHtmlDoubleClickException
DSECSSessionNotEstablishedException

syncRequestEnd

protected void syncRequestEnd(ChannelContext channelContext)
                       throws DSEInvalidRequestException,
                              DSEObjectNotFoundException,
                              DSECSSessionNotEstablishedException
Parameters:
channelContext -
Throws:
DSEInvalidRequestException
DSEObjectNotFoundException
DSECSSessionNotEstablishedException

processSessionRequest

public void processSessionRequest(ChannelContext channelContext)
This method is similar to processRequest, only back and double click validation are not performed as a new session is being established. A dummy session has been created during the preProcessRequest method. This session must be overriden by the startup operation (executed inside the executeSessionRequest) so the application is not aware of the existence of this session until the operation is executed. If an error occurs before the operation is executed the toolkit must handle the dummy session created. The dummy session has an identifier: dse_DummySession to be checked by the infrastructure in order to handle the dummy session when the application has not set its own session object.

Specified by:
processSessionRequest in interface RequestHandler
Overrides:
processSessionRequest in class DSERequestHandler
Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext

putProcessorIntoCache

protected void putProcessorIntoCache(DSEHtmlProcessorOperation oper)
Gets the processor instance from the processor operation and puts it into cache in order to be reused by further requests.

Parameters:
oper - DSEHtmlProcessorOperation

readOperation

protected BTTServerOperation readOperation(java.lang.String operationName,
                                           boolean isProcessorOp,
                                           KeyedCollection kcReqData,
                                           java.lang.String sessionId)
                                    throws DSECSSessionNotEstablishedException,
                                           DSEInvalidRequestException
Returns an operation containing either the operation going to be executed or a processor operation encapsulating the processor to execute. If this is the case, the processor is initialized before return the operation.

Parameters:
isProcessorOp - boolean indicating if the request intends to execute a processor or an operation
kcReqData - KeyedCollection created with the info sent from client
operationName - String with the id of the operation or processor that will be passed to the right externalizer
sessionId - String
Throws:
DSECSSessionNotEstablishedException - The session is expired
DSEInvalidRequestException - Operation or processor can not be found, instantiated or initialized

saveProcessor

protected void saveProcessor(DSEHtmlProcessorOperation oper,
                             java.lang.String sessionId,
                             java.lang.String applId)
                      throws DSEException
Saves the processor information needed to rebuild it in further requests for this processor.

Parameters:
oper - DSEHtmlProcessorOperation encapsulating the processor
sessionId - String containing the application session id
applId - String containing the application SUB session id (if any)
Throws:
DSEException - The processor can not be saved

setLocale

public void setLocale(javax.servlet.http.HttpServletRequest req,
                      Context ctx)
               throws java.lang.Exception
Creates a new locale object from the headers information and stores it in the context.

Parameters:
req - Request object where to get the headers from
ctx - context where to store the Locale object
Throws:
java.lang.Exception

setNextPageId

protected void setNextPageId(ChannelContext channelContext,
                             BTTServerOperation theOperation,
                             java.lang.String sessionId,
                             java.lang.String applicationId,
                             PresentationHandler presHandler)
                      throws DSEException
Updates the application session context with the next page id.

Parameters:
channelContext - Used to get the related RequestValidationServices
theOperation -
sessionId -
applicationId -
presHandler -
Throws:
DSEException

updateTimestamp

protected void updateTimestamp(java.lang.String sessionId,
                               java.lang.String appSessionId,
                               Operation operation,
                               ChannelContext channelContext)
                        throws DSEInvalidArgumentException,
                               DSEInvalidRequestException
Updates the timestamp for this session and for the application session if it exists.

Parameters:
sessionId - java.lang.String
operation - com.ibm.btt.base.Operation
Throws:
DSEInvalidArgumentException
DSEInvalidRequestException

isFirstRequest

public boolean isFirstRequest(RequestValidationServices rvs,
                              ChannelContext chctx)
                       throws DSEException
Check whether the current request is first request.

Parameters:
rvs -
chctx -
Returns:
true if the current request isthe first request. Otherwise, return false.
Throws:
DSEException

resetFlagForRVS

public void resetFlagForRVS(ChannelContext channelContext)
Reset the coresponding flag for RVS


executeOperationRequest

protected java.lang.Object executeOperationRequest(ChannelContext channelContext)
                                            throws java.lang.Exception
Excute operation request

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
java.lang.Exception

checkContextExistence

protected void checkContextExistence(BTTServerOperation oper)
                              throws DSEObjectNotFoundException
just check the operation and operation context whether null, and throws exceptions with meaningful info.

Parameters:
oper -
Throws:
DSEObjectNotFoundException

isValidGridData

protected boolean isValidGridData(DataElement de,
                                  Context ctx)
Here Just check whether a data field name is a IColl element. find the first one aa.2.ddd pattern aa.2.ddd, aa is the icoll name e.g xxx.2.dd, if the first xxx can be find in ctx and its type is IColl, it is think that the de is a icoll element

Parameters:
de -
ctx -
Returns:

indexOfInteger

protected int indexOfInteger(java.lang.String address)
TODO this method should be removed, pls refer updateContextForGrid() for reason This is a utility method used to obtain a number inside the given string. If this method finds one, the method returns its index in the String. If the method does not find one, the method returns -1. The number is supposed to be delimitated by dots ("asas.123.dfg.dfg"). If there is more than one number, the method returns the index of the first one.

Parameters:
address - java.lang.String
Returns:
int

executeProcessorRequest

protected java.lang.Object executeProcessorRequest(ChannelContext channelContext)
                                            throws java.lang.Exception
Excute processor request

Parameters:
channelContext - com.ibm.btt.clientserver.ChannelContext
Throws:
java.lang.Exception

getOrgRequest

protected javax.servlet.http.HttpServletRequest getOrgRequest(ChannelContext channelContext)

commitSessionCtx

protected void commitSessionCtx(ChannelContext channelContext)
                         throws DSEInvalidRequestException,
                                DSEObjectNotFoundException
commit session context to CHA server.

Parameters:
channelContext -
Throws:
DSEObjectNotFoundException
DSEInvalidRequestException

getProcessorId

protected java.lang.String getProcessorId(ChannelContext channelContext)
get processorId of the current processor, return null if not find

Parameters:
channelContext -
Returns:

destroySession

void destroySession(javax.servlet.http.HttpServletRequest req,
                    java.lang.String sessionId)

IBM WebSphere Multichannel Bank Transformation Toolkit Javadoc

(c) Copyright IBM Corporation 1998, 2011