com.ibm.dse.cs.html
Class RequestValidationServices

java.lang.Object
  |
  +--com.ibm.dse.cs.html.RequestValidationServices

public class RequestValidationServices
extends java.lang.Object

Back and double post validation requires that we keep a table of operations which are in progress. The table key is a composite key of sessionid.pageid. The data held for each record is a RequestData object, which encapsulates the channelContext and the operation which is running. Double (multiple) post validation is performed by testing that no entry is present for a sessionid.pageid before processing the request. Back button validation is related to processes. This support has not been added yet.


Field Summary
protected static long ageLimit
           
protected static java.util.Hashtable pendingRequestTable
           
protected static java.util.Hashtable sessionIdTable
           
 
Constructor Summary
RequestValidationServices()
           
 
Method Summary
static void addFieldTo(Context ctx, java.lang.String name, java.lang.Object value)
          This method adds framework related fields to a context.
static void addOpToPendingRequest(ChannelContext channelContext, DSEServerOperation addOperation)
          Once a record is added in the pending requests table, this method adds to this record the operation related with the request.
static boolean addPendingRequest(ChannelContext channelContext, DSEServerOperation addOperation)
          Add a record for an operation in process for a given session id and a given page id.
static void beginAgingRequest(ChannelContext channelContext)
          If the system has a non-zero age limit, then set a timestamp (actually a date) for the pending request matching the session and page that is passed in.
protected static boolean deletePendingRequest(java.lang.String compositeKey)
          This method removes an operation which has completed for a given page in a given session.
static java.lang.String getCompositeKey(ChannelContext channelContext)
          Builds the composite key used to identify a request in the pending requests table.
static java.lang.String getNextPageId(java.lang.String sessionId)
          Generate and return the next page ID for a given session.
static DSEServerOperation getOperationInProcess(ChannelContext channelContext)
          Return the operation in process that corresponds to the session id and page id specified in the channelContext
protected static Semaphore getOperationInProcessSem(ChannelContext channelContext)
          Return the semaphore for the operation in process that corresponds to the session id and page id specified in the channelContext.
static ChannelContext getPendingRequestChannelContext(ChannelContext channelContext)
          Returns the channel context associated in the pending requests table with a given sessionId/pageId.
static boolean isProcessorRequest(ChannelContext channelContext)
          See if the request asks or a processor instead of an operation.
static boolean isRequestAging(ChannelContext channelContext)
          See if a request recently completed for a given page in a given session.
static boolean isRequestPending(ChannelContext channelContext)
          See if there is already a request in process for a given page in a given session.
static boolean isUnconsistentProcessor(ChannelContext channelContext)
          See if a request for this processor is still in process or its aging timeout has not been reached yet.
protected static void removeExpiredRequests()
          Remove requests that are in the pendingRequestTable which have been there longer than the max aging time set for the system.
static boolean replaceChannelContext(ChannelContext channelContext)
          Replace the ChannelContext for an operation in process for a given session id and a given page id.
static void signalOnOpInProcessSem(ChannelContext channelContext)
          Signal the associated semaphores: awakes all the threads waiting in the semaphore associated to this request.
static void waitOnOpInProcessSem(ChannelContext channelContext)
          Forces the calling thread to wait in the semaphore associated to this request.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sessionIdTable

protected static java.util.Hashtable sessionIdTable

pendingRequestTable

protected static java.util.Hashtable pendingRequestTable

ageLimit

protected static long ageLimit
Constructor Detail

RequestValidationServices

public RequestValidationServices()
Method Detail

addFieldTo

public static void addFieldTo(Context ctx,
                              java.lang.String name,
                              java.lang.Object value)
                       throws java.lang.Exception
This method adds framework related fields to a context.
Parameters:
ctx - com.ibm.dse.base.Context
name - java.lang.String
value - java.lang.Object

addOpToPendingRequest

public static void addOpToPendingRequest(ChannelContext channelContext,
                                         DSEServerOperation addOperation)
                                  throws DSEException
Once a record is added in the pending requests table, this method adds to this record the operation related with the request.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext
oper - com.ibm.dse.cs.html.HtmlServerOperation

addPendingRequest

public static boolean addPendingRequest(ChannelContext channelContext,
                                        DSEServerOperation addOperation)
                                 throws DSEException
Add a record for an operation in process for a given session id and a given page id.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext
oper - com.ibm.dse.cs.html.HtmlServerOperation

beginAgingRequest

public static void beginAgingRequest(ChannelContext channelContext)
                              throws DSEException
If the system has a non-zero age limit, then set a timestamp (actually a date) for the pending request matching the session and page that is passed in. Then if another request from the same session.page comes in, and it is before the aging process ends, we declare a double post and we will not process the request any further.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

deletePendingRequest

protected static boolean deletePendingRequest(java.lang.String compositeKey)
This method removes an operation which has completed for a given page in a given session.
Parameters:
compositeKey - java.lang.String
Returns:
boolean

getCompositeKey

public static java.lang.String getCompositeKey(ChannelContext channelContext)
                                        throws DSEException
Builds the composite key used to identify a request in the pending requests table. It is constructed concatenating three keys:

If the request is intended to execute an operation instead of a processor, the operation identifier is just the operation name.
If the request is intended to execute a processor we need more than the processor name because the same page could contain more than one reference to the same processor, each of them asking for different transitions, so the processor name is constructed concatenating processor name and next event name.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext
Returns:
java.lang.String

getNextPageId

public static java.lang.String getNextPageId(java.lang.String sessionId)
Generate and return the next page ID for a given session.
Parameters:
sessionId - java.lang.String
Returns:
java.lang.String

getOperationInProcess

public static DSEServerOperation getOperationInProcess(ChannelContext channelContext)
                                                throws DSEException
Return the operation in process that corresponds to the session id and page id specified in the channelContext
Parameters:
com.ibm.dse.clientserver.ChannelContext -  

getOperationInProcessSem

protected static Semaphore getOperationInProcessSem(ChannelContext channelContext)
                                             throws DSEException
Return the semaphore for the operation in process that corresponds to the session id and page id specified in the channelContext.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

getPendingRequestChannelContext

public static ChannelContext getPendingRequestChannelContext(ChannelContext channelContext)
                                                      throws DSEException
Returns the channel context associated in the pending requests table with a given sessionId/pageId.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

isProcessorRequest

public static boolean isProcessorRequest(ChannelContext channelContext)
                                  throws DSEException
See if the request asks or a processor instead of an operation. It looks for a valid event name in the request data received from client. If this field does not exist or it is empty, this request won't be considered as an automaton request.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

isRequestAging

public static boolean isRequestAging(ChannelContext channelContext)
                              throws DSEException
See if a request recently completed for a given page in a given session.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

isRequestPending

public static boolean isRequestPending(ChannelContext channelContext)
                                throws DSEException
See if there is already a request in process for a given page in a given session.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

isUnconsistentProcessor

public static boolean isUnconsistentProcessor(ChannelContext channelContext)
                                       throws DSEException
See if a request for this processor is still in process or its aging timeout has not been reached yet.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

removeExpiredRequests

protected static void removeExpiredRequests()
Remove requests that are in the pendingRequestTable which have been there longer than the max aging time set for the system.

replaceChannelContext

public static boolean replaceChannelContext(ChannelContext channelContext)
                                     throws DSEException
Replace the ChannelContext for an operation in process for a given session id and a given page id.
Parameters:
channelContext - com.ibm.dse.clientserver.ChannelContext

signalOnOpInProcessSem

public static void signalOnOpInProcessSem(ChannelContext channelContext)
                                   throws DSEException
Signal the associated semaphores: awakes all the threads waiting in the semaphore associated to this request.
Parameters:
ctx - com.ibm.dse.cs.ChannelContext

waitOnOpInProcessSem

public static void waitOnOpInProcessSem(ChannelContext channelContext)
                                 throws DSEException
Forces the calling thread to wait in the semaphore associated to this request. SignalOn the semaphore to awake the threads that could be waiting.
Parameters:
ctx - com.ibm.dse.base.Context