Hi guys !
How can I adapt my WorkflowSession to a ResourceResolver ?
I found this searching on google:
@Reference
ResourceResolverFactory resourceResolverFactory;
public void execute (WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
Resource resolver = null;
try{
resolver =resourceResolverFactory.getResourceResolver(Collections.singletonMap("user.jcr.session",
(Object) session.getSession()));
} catch (final Exception e) {
throw new WorkflowException("could not get resource resolver", e);
}
But then I want to pass it as a parameter and call method getResourceResolver over it and I can't.
Hmm, what is wrong here ?
I'm using AEM 6.2, thanks.
Solved! Go to Solution.
Dear Demd,
workflowSession.adaptTo(ResourceResolver.class);
Regards,
Peter
Dear Demd,
workflowSession.adaptTo(ResourceResolver.class);
Regards,
Peter
Hi,
Thanks for you answer but it doesn’t seem to work that way. I get:
cannot resolve method ‘adaptTo(java.lang.Class<org.apache.sling.api.resource.ResourceResolver
when I'm using this:
ResourceResolver resourceResolver = workflowSession.adaptTo(ResourceResolver.class);
I have faced the similar issue cannot resolve to adaptTo when I am trying to adapt workflowsession to resourceResolver.
Later I realised that I have imported wrong packages.
I have imported
import com.day.cq.workflow.WorkflowException;
import com.day.cq.workflow.WorkflowSession;
import com.day.cq.workflow.exec.WorkItem;
import com.day.cq.workflow.exec.WorkflowProcess;
import com.day.cq.workflow.metadata.MetaDataMap;
This issue has been fixed after importing the following packages.
import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.WorkflowProcess;
import com.adobe.granite.workflow.metadata.MetaDataMap;
Hope this will resolve your issue.
Views
Replies
Total Likes
yes, it also worked for me @SanthoshMandala2651,
just wondering why it worked with import com.day.granite and not working with import com.day.cq.
my one more issue is resolved by changing this I was trying to start my workflow (workflowSession.startWorkflow(workflowModel,workFlowData)) when servlet calls by hitting the "/bin/XYZ" page but when I used cq imports it gave me a failure request.getResourceResolver().adaptTo(workflowSession.class), I invested so much time in figuring out the permission but it worked by using granite.
Unable to obtain WorkflowSession from ResourceResolver
Views
Replies
Total Likes
Should work... in AEM Docs for 6.2 WorkflowSession interface implements adaptable interface[1]
[1] WorkflowSession ("The Adobe AEM Quickstart and Web Application.")
Check your imports(e.g. make sure you actually imported this interface correctly) and make sure you adapt from WorkflowSession.
Regards,
Peter
Views
Replies
Total Likes
So I guess my problem has to do with the packages I'm using.
For this project I'm using com.day.cq.workflow while for the adaptTo method I need the com.adobe.granite.workflow.
There is any way to workaround this ?
Views
Replies
Total Likes
I mean, there are any other ways to adapt the WorkflowSession to ResourceResolver ?
Views
Replies
Total Likes
You should be using latest Workflow APIS and UBER 6.2 when building the bundle,
Views
Replies
Total Likes
Yes Scott is right.
Make sure to use latest workflow API's with UBER 6.2 Jar if you use AEM 6.2. Use latest workflow API i.e., com.adobe.granite.workflow then com.day.cq.workflow.
Hope this helps!
Thanks,
Ratna Kumar.
Hi again !
I can't seem to figure it out. I'm want an workflow that send an email using a custom template.
My only problem is that I can't seem to figure it out how to pass my SlingHttpServletRequest request to my custom Workflow Step.
For that i thought i have to adapt the WorkflowSession to a ResourceResolver. Is that right ?
Thanks.
Views
Replies
Total Likes
Dear Dem,
Have a look at acs webpage that discusses how to send email's and provides utility methods[1] also have a look at implementation code for your reference[2], also find following information on how to configure email system in AEM[3].
[1] Email API
[2] acs-aem-commons/EmailServiceImpl.java at master · Adobe-Consulting-Services/acs-aem-commons · GitHub
Regards,
Peter
Views
Replies
Total Likes
Views
Likes
Replies
Views
Like
Replies