Hi All,
For one of my requirements I have had to create a custom console from where authors can select pages and initiate a workflow. Since authors can select multiple pages, I need to be able to pass multiple payload to the workflow. I know this could be done via Workflow packages but the documentation around it seems rather limited. I need to create Workflow package on the fly. I'm aware of a ResourceCollection and ResourceCollectionManager service that could be used but somehow it doesn't work. I'm using the following code:-
ResourceCollection resourceCollection = resourceCollectionManager.createCollection(session.getNode(workflowPkgPage.getPath())); logger.debug("resourceCollection node created = {}", resourceCollection.getPath());
and I get the following logged in my logs (INFO):-
"com.adobe.granite.workflow.core.collection.ResourceCollectionManagerImpl Resource collection at /etc/workflow/packages/mypackage2 is not a package."
Followed by a NPE in the second line of code above. "/etc/workflow/packages/mypackage2" does indeed exist in CRX. This is a node I am creating first and passing to the above code.
To add to confusion, there are two set of workflow APIs in CQ with following namespace:
I am using the first package, as I believe it to be the "latest and greatest" (Possibly because I thought that Adobe will gradually move to granite packaging namespace). Although most classes and methods do seem identical between the two namespaces.
Which one among the two should be used ?
To summarize there are two questions:
Thanks
Ashish
Solved! Go to Solution.
Views
Replies
Total Likes
1) Use granite one
2) AFAIK there is no direct api. You might need to do form submission for each resource.
For your use case is each payload will be using same workflow or different one ?
Views
Replies
Total Likes
1) Use granite one
2) AFAIK there is no direct api. You might need to do form submission for each resource.
For your use case is each payload will be using same workflow or different one ?
Views
Replies
Total Likes
Thanks Sham,
I am using the Granite workflow API. I think the official documentation needs to be updated. Every workflow documentation I came across used the "com.day.cq.." API.
In the end I created the required Workflow Package Page via Node API.
For my usecase I need to launch a workflow with multiple payloads. With the above approach my issue is now resolved.
Thanks
Ashish
Views
Replies
Total Likes
One of the solution is to call the internal AEM API - which creates a package ands triggers the provided workflow
/etc/workflow/instances.package
Which will create the package as well as create the workflow too which you want.
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.servlet-helpers</artifactId>
<version>1.4.6</version>
</dependency>
return new SlingInternalRequest(resourceResolver, slingRequestProcessor, "/etc/workflow/instances.package")
.withRequestMethod("POST")
.withParameter("workflowModel","/etc/workflow/models/your-wf-model/jcr:content/model")
.withParameter("workflowTitle", "test-APi")
.withParameter("packageTitle","api-gen-pkg")
.withParameter("srcPathList","/content/your-page")
.execute()
.checkStatus(201,400,404,200)
.getResponseAsString();
Views
Replies
Total Likes
Views
Like
Replies
Views
Likes
Replies