Return error message from +PReS Enhance workflow invoked by HTTP Client Input

In my PlanetPress Conect workflow I call +PReS Enhance workflow using REST service and HTTP Client Input component (http://localhost:9340/rest/serverengine/workflow/outputcreation/execute/).

In +PReS Workflow I use Validate component to throw fatal error when there is a problem with metadata (see weaver config below).

 <component class="nl.edmond.workflow.components.validate.Validate" id="validate-1">
      <config>
        <validate>
          <rule scope="document" severity="fatal">
            <condition>document.myMetadata.DocId == undefined</condition>
            <message>DocId not found! TemplateId = ${document.TemplateId}, page number = ${document.sequence.job}</message>
          </rule>
        </validate>
      </config>
    </component> 

 

My error message goes to Weaver log (see below), but I want to return it to the calling PlanetPress workflow (and then send it to the error handler).

Is it possible? I want to inform my internal users (and IT Staff) what caused the error during the processing.


 FATAL [28 Nov 2017 08:05:03,623][qtp668777304-26] nl.edmond.workflow.components.validate.Validate.beforeStart(Validate.java:?) DocId not found! TemplateId = 4839, page number = 1
ERROR [28 Nov 2017 08:05:03,625][qtp668777304-26] nl.edmond.weaver.engine.WeaverEngineImpl.a(WeaverEngineImpl.java:?) A FATAL-level validation did not succeed
ERROR [28 Nov 2017 08:05:04,399][qtp668777304-26] com.objectiflune.weaver.service.rest.WeaverRestService.execute(WeaverRestService.java:?) A FATAL-level validation did not succeed
com.objectiflune.core.base.ApplicationException: A FATAL-level validation did not succeed
 at com.objectiflune.weaver.service.impl.WeaverServiceImpl.execute(WeaverServiceImpl.java)
 at com.objectiflune.weaver.service.rest.WeaverRestService.execute(WeaverRestService.java)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:498)

 

This response may be too late, but perhaps it is still helpful.

The HTTP Server Input plugin will only give you a generic error, so not a lot you can use, because you will not be able to distinguish between a validation error and errors for different reasons. If you want to have the same response to any error, then you can use the On Error tab in the plugin to trigger an action. But I don’t think you are looking for this.

By using a script to directly access the Connect REST API, you get more control.

For example, this script:

var http = new ActiveXObject("WinHttp.WinHttpRequest.5.1");
var url = Watch.GetVariable('connectRequestUrlEscaped');

http.open("GET", url, false);
http.SetCredentials ('ol-admin', 'secret', 0);

http.send();

var response = http.responseText;

Watch.log ('response headers="'+http.GetAllResponseHeaders()+'"',4);
Watch.log ('response="'+response+'"',4);

Gave me the following string in the response:

There was an error initiating to the output creation process caused by ApplicationException: WeaverException: A FATAL-level validation did not succeed (SRV000041)

By checking the response for the part starting at WeaverException, you should be able to check specifically for fatal validation errors.

Cheers,
Manuel.

Thank you very much for your answer and a working code example.

I tested it yesterday and it worked like charm.