com.ibm.workflow.portlet.sample
Class AuditTrailHandler

java.lang.Object
  |
  +--com.ibm.workflow.portlet.client.GenericCommandHandler
        |
        +--com.ibm.workflow.portlet.sample.AuditTrailHandler
All Implemented Interfaces:
CommandHandler

public class AuditTrailHandler
extends GenericCommandHandler

This CommandHandler accesses the IBM WebSphere MQ Workflow audit trail using JDBC and returns the event data in XML format. This data is then optionally formatted using XSL style sheets.

This sample also demonstrates how to use the Command class.

For details on how to run this sample, see the Samples section.


Constructor Summary
AuditTrailHandler()
           
 
Method Summary
 void destroy()
          When the handler is unloaded, the cached JDBC connection is closed.
static java.lang.String format(java.lang.String code)
          This static method transforms the numeric representation of an MQWF event code to a human-readable string by looking up the translation in the 'AuditTrail.properties' file (which allows for easy language translation).
 ResponsePage getActivityStatistics(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This custom command first retrieves the audit records for all activity instances whose names match the name of work item whose OID is passed via the 'id' parameter of the HTTP-request.
 java.lang.String getHandlerInfo()
          Returns information about the handler, such as author, version, and copyright.
 ResponsePage getInstanceHistory(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This custom command first retrieves the audit records for the process instance whose OID matches the 'id' parameter in the HTTP-request, and then transforms the data to XML.
 java.lang.String getTriggerTagFor(int list, RequestContext context)
          The trigger tags for the handler.
 void init(Config cfg)
          During initialization, the handler opens a JDBC connection to the MQWF runtime database (either on the local host or on a remote host [depending on the presence of the 'DB2Server' property in the configuration file]).
 
Methods inherited from class com.ibm.workflow.portlet.client.GenericCommandHandler
execute, getConfig, getContext, getCredentials, getSessionContext, onLogoff, onLogon
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AuditTrailHandler

public AuditTrailHandler()
Method Detail

getHandlerInfo

public java.lang.String getHandlerInfo()
Returns information about the handler, such as author, version, and copyright.
Overrides:
getHandlerInfo in class GenericCommandHandler
Returns:
a String containing handler information

init

public void init(Config cfg)
During initialization, the handler opens a JDBC connection to the MQWF runtime database (either on the local host or on a remote host [depending on the presence of the 'DB2Server' property in the configuration file]). This connection is cached. Then two SQL statements are prepared which will be used to retrieve the audit data for either a particular process instance or all the data available for a particular activity (across all process instances). If configured, the corresponding style sheets are loaded and preprocessed.
Overrides:
init in class GenericCommandHandler
Parameters:
config - The servlet's configuration and initialization parameters

destroy

public void destroy()
When the handler is unloaded, the cached JDBC connection is closed.
Overrides:
destroy in class GenericCommandHandler

getTriggerTagFor

public java.lang.String getTriggerTagFor(int list,
                                         RequestContext context)
The trigger tags for the handler. Those URL's will be inserted in the corresponding lists (and show up there as the icon which is referenced in the URL. Note that the function returns an empty string if no JDBC connection could be established (which will prevent the display of the icons).
Overrides:
getTriggerTagFor in class GenericCommandHandler
Parameters:
list - Denotes the list for which the trigger tag is queried.
context - The RequestContext which was passed to the Viewer calling this method.
Returns:
For work lists, an HTML tag to inovke the getActivityStatistics command; for instance lists, an HTML tag to invoke the getInstanceHistory command.

getInstanceHistory

public ResponsePage getInstanceHistory(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response)
                                throws ClientException
This custom command first retrieves the audit records for the process instance whose OID matches the 'id' parameter in the HTTP-request, and then transforms the data to XML. If a style sheet name is either passed via the 'stylesheet' parameter or is configured, the XML data is passed to it and the resulting HTML data is returned; otherwise the XML data is returned.
Parameters:
request - The request the client has made of the servlet
response - The response the servlet sends to the client
Returns:
The result page to be sent to the client

getActivityStatistics

public ResponsePage getActivityStatistics(javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response)
                                   throws ClientException
This custom command first retrieves the audit records for all activity instances whose names match the name of work item whose OID is passed via the 'id' parameter of the HTTP-request. Then the audit data is transformed to XML. If a style sheet is configured, the XML data is passed to it and the resulting HTML data is returned; otherwise the XML data is returned.
Parameters:
request - The request the client has made of the servlet
response - The response the servlet sends to the client
Returns:
The result page to be sent to the client

format

public static final java.lang.String format(java.lang.String code)
This static method transforms the numeric representation of an MQWF event code to a human-readable string by looking up the translation in the 'AuditTrail.properties' file (which allows for easy language translation). This function is excercised by the 'AuditTrail.xsl' style sheet and is an example of how style sheets can call back to Java code.
Parameters:
code - The numeric audit event ID
Returns:
A desription for the audit event


© Copyright IBM Corporation 2002, 2007. All Rights Reserved.