sr508
sr508
11-06-2018
Hi,
I am trying to play around with acs common feature Querypackager .
Querypackager servlet is registered with resourcetype and have selector and extension.
I would like to programmatically call this servlet from my workflow.
I am getting 500 response. I am having following queries :
illegalargumentexception: cannot create a node on synthetic resource and ModifiableNode exception.
I have googled and ended up finding none to resolve the issue.
I have followed the same ay for calling he doos bt ith resorcetye.
My resource type is resolving in resource resolver and i am calling with _jcr_content.package.json
i didnt find any other way how to implement.
Is there any other way to implement the servlets registered with resourcetype.
I have the user with admin permissions, do i need to pass the csrf token programmatically set in the headers of the http post method?
Please provide any references and solutions to above.
smacdonald2008
smacdonald2008
11-06-2018
Is this Servlet registered by Resource type? If so - will be hard to invoke from a WOrkflow. If reg by resource type, you need:
The resource type(s) supported by the servlet. The property value must either be a single String, an array of Strings or a Vector of Strings. Either this property or the sling.servlet.paths
property must be set, or the servlet is ignored. If both are set, the servlet is registered using both ways.
See this doc for an explanation -- Apache Sling :: Servlets and Scripts
smacdonald2008
smacdonald2008
11-06-2018
If you want to call an AEM Service from a Workflow, create a custom AEM Service that contains QueryBuilder logic to do what you want. Write a custom AEM workflow step that invokes the custom service using @Reference annotation. That will invoke your service.
sr508
sr508
12-06-2018
Hi scott,
I have implemented using bundles .... it worked.
But i want to know the real difficulty in calling the servlet registered by resource type through http post.
smacdonald2008
smacdonald2008
13-06-2018
It won;t work through a POST. That is because a Servlet registered via a resource type and is fired when that resource type is accessed- not in response to an event - like when we click a button - such as a submit button on a component.
See this doc for more information -- Scott's Digital Community: Binding Adobe Experience Manager Servlets to ResourceTypes
Jörg_Hoh
Employee
Jörg_Hoh
Employee
13-06-2018
In your case I would re-implement the logic of the QueryServlet in your own code. A lot of code of this servlet is validating things and rerouting paramters to do some API calls. And instead of creating a wrapper around this wrapper servlet, study the code and use the QueryHelper services (and some others) to do that what you want.
Jörg