Snowbound Software’s VirtualViewer Java AJAX product makes use of the VirtualViewer Content Handler to perform various actions concerning the retrieval and storage of content. By default, the VirtualViewer server uses FileContentHandler as its Content Handler, which merely reads and writes to a file system location. However, a different, custom class may be implemented in order to integrate VirtualViewer into a myriad of back-end systems.
In addition to these storage and retrieval calls, the Content Handler can also be used to process various event notifications. You can provide function “hooks” that will get called when certain events happen such as viewing, saving, exporting or printing a page in a document. Your function can then record the user and the event into your auditing or privacy compliance system. You add these hook functions into your Content Handler.
FlexSnapSIContentHandlerInterface
This interface defines methods that are generally used for retrieving content for VirtualViewer. Most of the methods have a single input parameter which is an instance of the class ContentHandlerInput (an extension of java.util.Hashtable).
Most of the methods return an instance of the class ContentHandlerResult (also an extension of java.util.Hashtable) which contains the return data required by the method.
For more information on setting up the Content Handler, please see Chapter 4 – Working with the Content Handler in the VirtualViewer Java Content Server Administrator’s Guide.
To use the eventNotification method to set up event notifications in the Content Handler, please see the description of the eventNotification method below:
Method Detail
_________________________________________________________________________
eventNotification
public ContentHandlerResult eventNotification (ContentHandlerInput input) throws FlexSnapSIAPIException
Implement this content handler method to receive event notifications.
Parameters
A ContentHandlerInput object containing the following data:
KEY_EVENT | String | One of the following four VALUE_EVENT_* values: VALUE_EVENT_PAGE_REQUESTED Indicates that a page has been requested to be viewed. VALUE_EVENT_SAVE_ANNOTATION Indicates that an annotation layer has been saved. VALUE_EVENT_PRINT Indicates that a document has been printed. VALUE_EVENT_EXPORT Indicates that a document has been exported. |
VALUE_EVENT_PAGE_REQUESTED | String | The event being logged is a page request |
KEY_EVENT_PAGE_REQUESTED_NUMBER | String | The page number requested (zero-based) |
VALUE_EVENT_SAVE_ANNOTATION | String | The event being logged is a save annotation request |
Returns
A ContentHandlerResult object or null. The return value is currently ignored.
Sample Implementation
The following is a code sample showing how to implement the event notification feature:
public ContentHandlerResult eventNotification(ContentHandlerInput input)
throws FlexSnapSIAPIException
{
String eventName = (String) input.get(ContentHandlerResult.KEY_EVENT);
if(eventName.indexOf(ContentHandlerResult.VALUE_EVENT_PAGE_REQUESTED) != -1) {
String pageNumber = (String) input.get(ContentHandlerResult.KEY_EVENT_PAGE_REQUESTED_NUMBER);
System.out.println(“===========Page Requested: ” + pageNumber);
}
return ContentHandlerResult.VOID;
}
Defining the Content Handler
The VirtualViewer servlet will instantiate the Content Handler class that is specified in the application’s web.xml using the parameter contentHandlerClass. For example:
<init-param>
<param-name>contentHandlerClass</param-name>
<param-value>com.snowbound.flexsnap.custom.MyContentHandler
</param-value>
</init-param>