com.ibm.dse.automaton.html
Class DSEHtmlProcessorOperation

java.lang.Object
  |
  +--com.ibm.dse.base.DSEOperation
        |
        +--com.ibm.dse.base.DSEServerOperation
              |
              +--com.ibm.dse.automaton.html.DSEHtmlProcessorOperation

public class DSEHtmlProcessorOperation
extends DSEServerOperation
implements ProcessorOperation

This class represents a virtual processor manager for the Homebanking HTML Client. It allows for processes to be run over multiple invocations across the HTML CS mechanism, without having to maintain the processor object on the server machine. This class provides for persistence of a processor object such that it can be reinstantiated in the state it was in on the last CS invocation. The class also provides for updating the processor context with data obtained on each invocation across the CS mechanism.

See Also:
Serialized Form

Field Summary
static java.lang.String ILLEGALSWITCH
           
static java.lang.String NORMAL
           
 
Fields inherited from class com.ibm.dse.base.DSEOperation
aOperationRepliedListener, externalizer
 
Constructor Summary
DSEHtmlProcessorOperation()
          DSEHtmlProcessorOperation constructor.
DSEHtmlProcessorOperation(java.lang.String anOperationName)
          DSEHtmlProcessorOperation constructor.
DSEHtmlProcessorOperation(java.lang.String anOperationName, Context aParentContext)
          DSEHtmlProcessorOperation constructor.
DSEHtmlProcessorOperation(java.lang.String anOperationName, java.lang.String aParentContext)
          DSEHtmlProcessorOperation constructor.
 
Method Summary
static void chainToSessionContext(Context context, java.lang.String sessionId)
          This utility method chains the supplied context to the session context identified by the session id argument.
protected  boolean checkBackClick(java.lang.String currentPageId, java.lang.String previousPageId)
          This utility method checks to see if this invocation of the processor operation has arisen a a result of a back click by the user (either by using the browser navigation bar, or browser history or by typing a previously viewed URL in the location bar).
protected  boolean checkLegalSwitch(Processor processor, java.lang.String processorState)
          This is a utility method that checks to see whether it is legal for this processor to be put in the state specified by the supplied state name, from the point of view of consequentiality.
 void close()
          Closes the processor operation.
 void closeProcessor(Processor processor)
          This is equivalent of calling closeProcessor(Processor, false)
 void closeProcessor(Processor processor, boolean removeParents)
          This method close the processor supplied to it as argument.
protected  Processor createProcessor(java.lang.String processorName)
          This method creates a processor object of the type specified by the name argument supplied to it.
 Processor createSubProcessor(java.lang.String procName, Processor parent)
          This method creates a sub processor, for the supplied processor object, using the supplied processor name.
protected  void doDataMapping(DataMapperFormat format, Context sourceCtx, Context targetCtx)
          This utility method maps data from the source context to the target context using the supplied DataMapperFormat.
 void execute(java.lang.String eventName)
          This method serves as the entry point for execution of the processor object currently being managed by the processor operation.
protected  Processor getParent(Processor processor)
          This method obtains the parent processor, if any, for the processor supplied as argument.
 Processor getProcessor()
          Returns the processor object currently being managed.
 java.lang.String getResponseId()
          Returns the current response id existing in the framework.
 java.lang.String getStatus()
          Returns the status attributes of this object.
protected  java.lang.String getValidEventName(Processor currentProcessor, Processor parentProcessor, java.lang.String currentEventName)
          This method will make something only when the event name wouldn't include a notifier name.
protected  java.lang.Object getValueFromContext(Context context, java.lang.String name, boolean required)
          This utility method attempts to obtain the value corresponding to the supplied name from the supplied context.
protected  java.lang.Object getValueFromKColl(KeyedCollection coll, java.lang.String name, boolean required)
          This utility method attempts to obtain the value corresponding to the supplied name from the supplied collection.
 void initializeProcessor(KeyedCollection coll)
          This method creates or restores a processor object.
protected  boolean isEmpty(java.lang.String s)
          Checks for an empty string by first checking if the string is null then checking if it contains any characters.
protected  boolean isEmpty(java.lang.String string, boolean trim)
          Checks for an empty string by first checking if the string is null then checking if it contains any characters.
protected  void mapDataFromChild(Processor child, Processor parent, java.lang.String exitEventName)
          This utility method maps data from a child processor to its parent upon the child processor's completion.
protected  boolean processorHasParent(DSEHtmlProcessor processor)
          Checks to see if the processor supplied as argument has a parent.
protected  boolean processorHasParent(Processor processor)
          Checks to see if the processor supplied as argument has a parent.
 boolean replaceCtxIfNeeded()
          This method is used only when a HtmlTransition with its skipValidation value set to true is executed.
 void setFinalResponseId(java.lang.String id)
          Sets the reply page.
 void setProcessor(Processor processor)
          Sets the processor object to be managed.
 void setResponseId(java.lang.String id)
          Sets the response id to be set into the HTML Client framework.
 void setStatus(java.lang.String newStatus)
          Sets the status of this object.
 void startSubProcessor(java.lang.String processorName)
          This is a utility method for creating and executing a subprocessor.
 boolean updateContext(KeyedCollection collection)
          This method requests that the processor (which this processor operation is handling) update its context with the data supplied in the collection supplied as argument.
 
Methods inherited from class com.ibm.dse.base.DSEServerOperation
execute, getCSReplyFormat, getCSRequestFormat, getOriginWorkstation, runInSession, setCSReplyFormat, setCSRequestFormat, setOriginWorkstation
 
Methods inherited from class com.ibm.dse.base.DSEOperation
addElement, addOperationRepliedListener, chainTo, chainToContextNamed, chainToCurrentContext, externalizer, fireHandleOperationRepliedEvent, getApplicationId, getContext, getContextByType, getContextName, getContextNamed, getElementAt, getExternalizer, getFormat, getFormats, getHostReceiveFormat, getHostSendFormat, getInstanceOfOperationStep, getKeyedCollection, getName, getOperationStep, getOperationStepRC, getOperationSteps, getParent, getSelfDefinedOpTagInputStream, getService, getServiceByType, getSessionId, getSgmlSelfDefinedOpFileName, getType, getValueAt, hasServices, initializeFormatFrom, initializeFrom, initializeKeyedCollectionValueFrom, initializeOpStep, initializeOpStepsFrom, isCacheable, isChained, isContext, occurrencesNamed, prune, readExternal, readExternal, readObject, reinitialize, removeAt, removeExternal, removeOperationRepliedListener, setApplicationId, setContext, setContextName, setExternalizer, setHostReceiveFormat, setHostSendFormat, setKeyedCollection, setName, setSessionId, setType, setValueAt, toString, toStrings, toTags, unchain, writeExternal, writeExternal, xValidate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NORMAL

public static final java.lang.String NORMAL

ILLEGALSWITCH

public static final java.lang.String ILLEGALSWITCH
Constructor Detail

DSEHtmlProcessorOperation

public DSEHtmlProcessorOperation()
DSEHtmlProcessorOperation constructor.

DSEHtmlProcessorOperation

public DSEHtmlProcessorOperation(java.lang.String anOperationName)
                          throws java.io.IOException
DSEHtmlProcessorOperation constructor.
Parameters:
anOperationName - java.lang.String
Throws:
java.io.IOException -  

DSEHtmlProcessorOperation

public DSEHtmlProcessorOperation(java.lang.String anOperationName,
                                 Context aParentContext)
                          throws java.io.IOException,
                                 DSEInvalidRequestException
DSEHtmlProcessorOperation constructor.
Parameters:
anOperationName - java.lang.String
aParentContext - com.ibm.dse.base.Context
Throws:
java.io.IOException -  
DSEInvalidRequestException -  

DSEHtmlProcessorOperation

public DSEHtmlProcessorOperation(java.lang.String anOperationName,
                                 java.lang.String aParentContext)
                          throws java.io.IOException,
                                 DSEObjectNotFoundException,
                                 DSEInvalidRequestException
DSEHtmlProcessorOperation constructor.
Parameters:
anOperationName - java.lang.String
aParentContext - java.lang.String
Throws:
java.io.IOException -  
DSEObjectNotFoundException -  
DSEInvalidRequestException -  
Method Detail

chainToSessionContext

public static void chainToSessionContext(Context context,
                                         java.lang.String sessionId)
                                  throws DSEException
This utility method chains the supplied context to the session context identified by the session id argument. A check is made first to ensure that the supplied context is not already chained to the session context.
Parameters:
processor - com.ibm.dse.base.Context
sessionId - java.lang.String
Throws:
DSEException -  

checkBackClick

protected boolean checkBackClick(java.lang.String currentPageId,
                                 java.lang.String previousPageId)
This utility method checks to see if this invocation of the processor operation has arisen a a result of a back click by the user (either by using the browser navigation bar, or browser history or by typing a previously viewed URL in the location bar). This method relies on system values defined for the HTML client to determine whether such a back click as described above has occured.
Parameters:
pageId - java.lang.String
lastPageId - java.lang.String
Returns:
boolean

checkLegalSwitch

protected boolean checkLegalSwitch(Processor processor,
                                   java.lang.String processorState)
This is a utility method that checks to see whether it is legal for this processor to be put in the state specified by the supplied state name, from the point of view of consequentiality.
Parameters:
processor - com.ibm.dse.automaton.Processor
processorState - java.lang.String
Returns:
boolean

close

public void close()
           throws DSEInvalidRequestException,
                  DSEObjectNotFoundException
Closes the processor operation. This method closes the processor currently being managed and releases its hold on the instance.
Specified by:
close in interface ProcessorOperation
Overrides:
close in class DSEOperation
Throws:
DSEInvalidRequestException -  
com.ibm.dse.base.DSEDSEObjectNotFoundException -  

closeProcessor

public void closeProcessor(Processor processor)
This is equivalent of calling closeProcessor(Processor, false)
Specified by:
closeProcessor in interface ProcessorOperation
Parameters:
processor - com.ibm.dse.automaton.Processor

closeProcessor

public void closeProcessor(Processor processor,
                           boolean removeParents)
This method close the processor supplied to it as argument. If the boolean argument is true, then any parent processor will also be closed.
Parameters:
processor - com.ibm.dse.automaton.Processor
removeParents - boolean

createProcessor

protected Processor createProcessor(java.lang.String processorName)
                             throws DSEHtmlCreateProcessorException
This method creates a processor object of the type specified by the name argument supplied to it.
Parameters:
processorName - java.lang.String
Returns:
com.ibm.dse.automaton.Processor
Throws:
DSEHtmlCreateProcessorException -  

createSubProcessor

public Processor createSubProcessor(java.lang.String procName,
                                    Processor parent)
                             throws DSEHtmlCreateProcessorException
This method creates a sub processor, for the supplied processor object, using the supplied processor name. The new processor object is chained to its parent.
Parameters:
procName - java.lang.String
parent - com.ibm.dse.automaton.Processor
Returns:
com.ibm.dse.automaton.Processor
Throws:
DSEHtmlCreateProcessorException -  

doDataMapping

protected void doDataMapping(DataMapperFormat format,
                             Context sourceCtx,
                             Context targetCtx)
                      throws DSEException
This utility method maps data from the source context to the target context using the supplied DataMapperFormat.
Parameters:
format - com.ibm.dse.base.DataMapperFormat
sourceCtx - com.ibm.dse.base.Context
targetCtx - com.ibm.dse.base.Context
Throws:
DSEException -  

execute

public void execute(java.lang.String eventName)
             throws DSEException,
                    DSEInvalidArgumentException
This method serves as the entry point for execution of the processor object currently being managed by the processor operation. A check is first made to ensure that consequentiality has not been violated for the processor object being managed. If it has, then execution is terminated. If not, then the control is passed over to the processor for it to carry on execution, using the event name supplied as argument to this method. Upon return of control from the processor, the processor operation examines its status to determine the next course of action. These are the possible course of action:
Specified by:
execute in interface ProcessorOperation
Throws:
DSEException -  
DSEInvalidArgumentException -  

getParent

protected Processor getParent(Processor processor)
This method obtains the parent processor, if any, for the processor supplied as argument.
Parameters:
processor - com.ibm.dse.automaton.Processor
Returns:
com.ibm.dse.automaton.Processor

getProcessor

public Processor getProcessor()
Returns the processor object currently being managed.
Specified by:
getProcessor in interface ProcessorOperation
Returns:
com.ibm.dse.automaton.Processor

getResponseId

public java.lang.String getResponseId()
                               throws DSEException
Returns the current response id existing in the framework.
Specified by:
getResponseId in interface ProcessorOperation
Returns:
java.lang.String
Throws:
DSEException -  

getStatus

public java.lang.String getStatus()
Returns the status attributes of this object.
Specified by:
getStatus in interface ProcessorOperation
Returns:
java.lang.String

getValidEventName

protected java.lang.String getValidEventName(Processor currentProcessor,
                                             Processor parentProcessor,
                                             java.lang.String currentEventName)
This method will make something only when the event name wouldn't include a notifier name. Then, a dummy notifier will be created. The name of the notifier is very important because the transitions must be defined as notifierName.eventName. The convention is: when the event comes from a page, the notifier will be constructed using the name of the state, but if the event is the "start" event of the processor, the notifier is built using the processor name. If the event comes from a subFlow's final state, the notifier will be built from the name of the subFlow.
Parameters:
eventName - java.lang.String
typePage - boolean
Returns:
java.lang.String

getValueFromContext

protected java.lang.Object getValueFromContext(Context context,
                                               java.lang.String name,
                                               boolean required)
                                        throws DSEException
This utility method attempts to obtain the value corresponding to the supplied name from the supplied context. If the value cannot be obtained and the boolean required attribute is true, then an exception is generated, else a null value is returned.
Parameters:
context - com.ibm.dse.base.Context
name - java.lang.String
required - boolean
Returns:
java.lang.Object
Throws:
DSEException -  

getValueFromKColl

protected java.lang.Object getValueFromKColl(KeyedCollection coll,
                                             java.lang.String name,
                                             boolean required)
                                      throws DSEException
This utility method attempts to obtain the value corresponding to the supplied name from the supplied collection. If the value cannot be obtained and the boolean required attribute is true, then an exception is generated, else a null value is returned.
Parameters:
coll - com.ibm.dse.base.KeyedCollection
name - java.lang.String
required - boolean
Returns:
java.lang.Object
Throws:
DSEException -  

initializeProcessor

public void initializeProcessor(KeyedCollection coll)
                         throws DSEException
This method creates or restores a processor object. The data required to carry this out is expected to be supplied within the collection supplied as argument to the method. The following variables are expected: processor id - keyed by HtmlConstants.PROCESSORID, OR processor name - keyed by HtmlConstants.OPERATIONNAME processor state - keyed by HtmlConstants.PROCESSORSTATE If a processor id is specified then an attempt is made to load the processor from storage. If the processor id is not supplied and the processor name is, then a new processor object is created, corresponding to the name. An error results if neither the processor id or processor name are specified. Once a processor object is obtained, then its state is changed to the one specified in the keyed collection.
Specified by:
initializeProcessor in interface ProcessorOperation
Parameters:
coll - com.ibm.dse.base.KeyedCollection
Throws:
DSEException -  

isEmpty

protected boolean isEmpty(java.lang.String s)
Checks for an empty string by first checking if the string is null then checking if it contains any characters. If the boolean argument is true, then space characters are trimmed from the beginning and end of the string before it is checked for characters. Trimming the string is the default behaviour.
Parameters:
s - java.lang.String
Returns:
boolean

isEmpty

protected boolean isEmpty(java.lang.String string,
                          boolean trim)
Checks for an empty string by first checking if the string is null then checking if it contains any characters. If the boolean argument is true, then space characters are trimmed from the beginning and end of the string before it is checked for characters. Trimming the string is the default behaviour.
Parameters:
string - java.lang.String
trim - boolean
Returns:
boolean

mapDataFromChild

protected void mapDataFromChild(Processor child,
                                Processor parent,
                                java.lang.String exitEventName)
                         throws DSEException
This utility method maps data from a child processor to its parent upon the child processor's completion.
Parameters:
child - com.ibm.dse.automaton.Processor
parent - com.ibm.dse.automaton.Processor
exitEventName - java.lang.String
Throws:
DSEException -  

processorHasParent

protected boolean processorHasParent(DSEHtmlProcessor processor)
Checks to see if the processor supplied as argument has a parent.
Parameters:
processor - com.ibm.dse.automaton.html.DSEHtmlProcessor
Returns:
boolean

processorHasParent

protected boolean processorHasParent(Processor processor)
Checks to see if the processor supplied as argument has a parent.
Parameters:
processor - com.ibm.dse.automaton.html.DSEHtmlProcessor
Returns:
boolean

replaceCtxIfNeeded

public boolean replaceCtxIfNeeded()
This method is used only when a HtmlTransition with its skipValidation value set to true is executed. Gets the transition context from the processor context (only is stored there if there is a skipValidation transition), chains the tr ctx to the pr ctx, and removes the tr ctx from the pr ctx.
Returns:
boolean

setFinalResponseId

public void setFinalResponseId(java.lang.String id)
                        throws DSEInvalidArgumentException,
                               DSEObjectNotFoundException,
                               DSEInvalidRequestException
Sets the reply page. Does not need to add any automaton specific information because the processor is ended. If the application wants to begin a new processor from this page, must add on its own, the state field.
Parameters:
id - java.lang.String
Throws:
DSEInvalidArgumentException -  
DSEObjectNotFoundException -  

setProcessor

public void setProcessor(Processor processor)
Sets the processor object to be managed.
Specified by:
setProcessor in interface ProcessorOperation
Parameters:
processor - com.ibm.dse.automaton.Processor

setResponseId

public void setResponseId(java.lang.String id)
                   throws DSEInvalidArgumentException,
                          DSEObjectNotFoundException
Sets the response id to be set into the HTML Client framework.
Specified by:
setResponseId in interface ProcessorOperation
Parameters:
id - java.lang.String
Throws:
DSEInvalidArgumentException -  
DSEObjectNotFoundException -  

setStatus

public void setStatus(java.lang.String newStatus)
Sets the status of this object.
Specified by:
setStatus in interface ProcessorOperation
Parameters:
newStatus - java.lang.String

startSubProcessor

public void startSubProcessor(java.lang.String processorName)
                       throws DSEException
This is a utility method for creating and executing a subprocessor. A processor object is created and initialized based on the processor name supplied as argument to this function. The current processor being managed by the processor operation is saved, then replaced with the sub processor. Data is optionally passed from the parent processor to the subprocessor using data mapping formats defined in the current state of the parent processor. Execution is then passed off to the subprocessor, with an event that corresponds to its start state.
Parameters:
processName - java.lang.String
Throws:
DSEException -  

updateContext

public boolean updateContext(KeyedCollection collection)
                      throws DSETypeException,
                             DSEObjectNotFoundException,
                             DSEInvalidArgumentException
This method requests that the processor (which this processor operation is handling) update its context with the data supplied in the collection supplied as argument. It returns a boolean indicating whether the update was successful or not. Before updating the context, checks if the request is legal according to the consequentiality (back button support).
Specified by:
updateContext in interface ProcessorOperation
Overrides:
updateContext in class DSEServerOperation
Returns:
boolean
Throws:
DSETypeException -  
DSEObjectNotFoundException -  
DSEInvalidArgumentException -