Skip to main content
Version: 2.8

Adding around-processor logic for Web Reader

This page describes how to add a new service processor for Web Reader.

To prepare a script to be used by the Web Reader

In the example script described on this page, we are creating the DocumentRetrievalRequest that will add a simple around-processor that retrieves a requestMeta parameter from the call to Web Reader.

The script fetches a metadata map of a service request and then tries to find a parameter called myParameter by using the Tribefire-standard requestMeta method. This parameter must be passed in the URL when calling the Web Reader.

The following Groovy script is a key part of our processor:


//fetch metaData map which holds requestMeta.* URL parameters
def metaData = $request.getMetaData();

//fetch my custom context URL parameter
def myParameter = metaData.get("requestMeta.myParameter");
if (myParameter != null) {
//print out custom URL parameter
$tools.logger.info(myParameter);
}

//We could do some real world tasks here - e.g.
// - call other applications
// - adapt the request
// - ...

//execute actual request - e.g. DocumentRetrievalRequest
def response = $proceedContext.proceed($request);

//We could do some real world tasks here - e.g.
// - call other applications
// - adapt response
// - ...

//return response of e.g. DocumentRetrievalRequest
return response;
Note

Services are executed on the server side, so you have access to everything that D1 can provide.

To add a new service processor

  1. Log in to D1 and go to the Administrator page.

  2. Click Repositories and double-click on a repository where you want to customize the Web Reader.

  3. Double-click Processing Configuration. The editing form opens.

  4. Click Add under Service Interceptors to add new service interceptors.

  5. Double-click the Scripted Interceptor.

Editing form for the interceptor opens.

  1. Define your interceptor:

    • Interceptor Type - specify when the script should be executed: before, after, or around service request.
    • Script - assign a script to be executed.
    • Service Type - select DocumentRetrievalRequest from the list.
  2. Apply your changes.

  3. Click Reactivate to activate the repository.

The following video shows the initial configuration of adding a new service processor.

Video version

Note that some of the UI components shown in this video might have changed as the video was created based on a older version of the D1.

Where to go from here

Your script can now be used. To check how to try it out, see Calling Web Reader with custom parameters.