Intervening a running process at a certain position and redirecting the process flow in order to include project-specific processing steps.
Table of Contents
Introduction
The interceptors allow for project-specific extensions of the yuuvis® Momentum standard process flows. The running process flow can be intervened in a condition on the processed object, that has to be specified in the interceptor definition. Whenever the process flow satisfies the condition, the project-specific process extension is included for the currently processed object at this position of the process flow. Thus, the alternative process can replace the standard one from this position completely or resume the standard process at a specified position.
Interceptor Configuration
The condition for the intervention of the process flow is defined in the interceptor configuration.
Parameters
The following parameters can/have to be defined in the interceptor configuration:
Parameter | Type | Required | Description |
---|---|---|---|
type | String | yes | The type of the interceptor. It defines the position in the process flow where the interceptor can step in. |
predicate | String | yes | The condition that triggers the intervention of the process flow in order to include the project-specific process extension. The string can provide the condition either in Spring Expression Language (SpEL) or Javascript. Thus, the string has to start always with a prefix spel: for SpEL or js: for Javascript. |
url | String | yes | HTTP address of the project-specific process extension. Dynamic components (properties of the processed object) can be included in braces. |
useDiscovery | boolean | no | Decides whether to resolve the url string at the Discovery-Service or not. If not specified, default |
Interceptor Types
There are different types of interceptors available, that interrupt the process flow at different positions.
Intercepor Type | Evaluation Target of the Predicate | Description |
---|---|---|
getContent | API dms object in JSON format | Manipulation of the binary content of the return statement by a project-specific service |
search | structure of the specific class SearchInterceptorObject | Manipulation of the search query parameter and the search result. |
updateDmsObject | first API dms object in the list in JSON format, that is passed to the corresponding update endpoint | Manipulation of the update properties that will be applied to a dms object. |
Configuration Examples
The interceptor configuration is part of the interceptorConfiguration.json file. It is a JSON list of all interceptors, each of them specified by its type
, predicate
, url
and useDirectory
parameters. If there are two or more interceptors of the same type, all of them will be executed in random order.
The following two code examples show the configuration of a getContent interceptor. In the first case, the predicate contains the condition in JavaScript. In contrast, the second code example makes use of SpEL.
{ "interceptors" : [ { "type" : "getContent", "predicate" : "js:function process(dmsApiObject){return dmsApiObject[\"contentStreams\"][0][\"range\"]!=null && dmsApiObject[\"contentStreams\"][0][\"range\"].startsWith(\"page:\")}", "url" : "http://<server>:<port>/api/dms/objects/{system:objectId}", "useDiscovery" : false } ] }
{ "interceptors" : [ { "type" : "getContent", "predicate" : "spel:contentStreams[0]['range'] != null ? contentStreams[0]['range'] matches '(?i)^page:.*' : false", "url" : "http://<server>:<port>/api/dms/objects/{system:objectId}", "useDiscovery" : false } ] }
A search interceptor can have a SpEL or a JavaScript statement in the predicate as well. In the example code below, only the SpEL variant is shown. In addition to the actual search interceptor configuration, the class SearchInterceptionObject has to be defined.
{ "interceptors" : [ { "type" : "search", "predicate" : "spel:!grantedAuthorities.contains('ACCESS_FOREIGN_JOURNAL_OBJECTS')", "url" : "http://<server>:<port>/api/search/dsl", "useDiscovery" : false } ] }
{ "objects": [ { "properties": { "system:objectId": { "value": "333c226c-3a44-5e66-7777-8d999a0000e1" }, "system:baseTypeId": { "value": "system:document" }, "system:objectTypeId": { "value": "document" }, "system:createdBy": { "value": "111c226c-3a44-5e66-7777-8d999a0000e1" }, "system:creationDate": { "value": "2020-09-16T16:57:40.780Z" }, "system:lastModifiedBy": { "value": "111c226c-3a44-5e66-7777-8d999a0000e5" }, "system:lastModificationDate": { "value": "2020-09-16T16:57:40.780Z" }, "system:versionNumber": { "value": 1 }, "system:tenant": { "value": "default" }, "system:traceId": { "value": "1234567887654321" }, "Name": { "value": "test.eml" } }, "contentStreams": [ { "contentStreamId": "0AB98765-CDEF-4321-ABCD-098EF76AB543", "archivePath": "default/DOCUMENT/32/15/7/", "length": 82683, "mimeType": "message/rfc822", "fileName": "test.eml", "digest": "12345678123456781234567812345678123456781234567812345678", "range": "1234-12345,123456-123458,123489-234567,245678-345678", "repositoryId": "repo252" } ] } } ] }
Summary
This article gave an overview of the interceptor handling in yuuvis® Momentum. If you want to extend the functionality of your system, also system hooks might be an interesting topic for you.