Making a call to servlet from workflow process
Hi,
I have a use case where there is an already a servlet providing data of certain nodes in json format.
Now: There is a workflow which needs same json data to be pushed AWS S3 storage.
Trial 1: Is it possible to get a sling request in a workflow process step ?
I tried to common out all the reusable code out of servlet, but still there are references to request object.
Trial2: Used Apache HTTP Client api to make a call to servlet url and got anonymous user access not allowed, unauthorized.
Trial3: Used below code, even though servlet sending back all the response, bytearrayoutputstram does NOT have all the response.
String requestPath = "/srvpub/topnav.consumer.json " // servlet path
/* Setup request */
HttpServletRequest req = requestResponseFactory.createRequest("GET", requestPath);
WCMMode.DISABLED.toRequest(req);
/* Setup response */
ByteArrayOutputStream out = new ByteArrayOutputStream();
HttpServletResponse resp = requestResponseFactory.createResponse(out);
/* Process request through Sling */
requestProcessor.processRequest(req, resp, request.getResourceResolver());
String html = out.toString();
Any help or ideas on what I am missing or working ways to solve this use case.
Thanks,
Sri