Dear community,
I need a workflow that allows users to upload a file to DAM at one step, the same file can be downloaded at another step ahead.
Here comes the issue, I need WorkflowSession and WorkItem to write properties on workflow instance, but I cannot get them on the Servlet that adds asset to DAM.
find snippet below, the workitemId is null;
ResourceResolver resolver = request.getResourceResolver();
String workitemId = request.getParameter("item");
However, this part does work if I call the servlet with "sling:resourceType". So it's about the object that calls servlet I assume.
So there are 2 ways to get WorkflowSession and WorkItem
1. Using "custom process step", WorkflowProcess interface get me these two.
2. Calling servlet with sling:resourceType.
But in my case, I can only imagine designing upload / download step with participant dialog step. As I click custom upload button, the servlet writes the file path on workflow instance, and another servlet ahead fetch the property with same approach.
Is there anything I can do to get WorkflowSession and WorkItem with dialog participant step?
Or I could use other steps in my workflow to achieve this?
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks @YuSheng for sharing additional details.
I'm not sure why you're using servlet to upload the file in this case.
May be you can also try below steps:
1. Dialog participant where the workflow user browse the file.
- In this step, it will just store the image/file details in workflow payload.
2. Custom workflow process step : To read the file path from the payload and then upload the file to AEM. Below you can find the sample servlet to upload the asset in AEM. So you can the same code in your workflow process which will upload file in DAM.
https://github.com/arunpatidar02/aem63app-repo/blob/master/java/UploadAssets.java
3. Other process steps goes here to complete your business logic.
4. You can even send email notifications to the participants with all the required information to review it.
5. Assign the step to the participant to publish/Reject etc..
Hope this helps.
@YuSheng Are you creating workflow just to upload the file into DAM and download same on another step or it also has some other business logic to execute in the between upload & download the file from DAM?
There might be other business logic in between upload & download, but would be separate from upload & download steps.
The use case is about the workflow initiator uploads file(s) along with a page, reviewers ahead should be able to download that file and proceed to next step (say, activate the page).
Thanks @YuSheng for sharing additional details.
I'm not sure why you're using servlet to upload the file in this case.
May be you can also try below steps:
1. Dialog participant where the workflow user browse the file.
- In this step, it will just store the image/file details in workflow payload.
2. Custom workflow process step : To read the file path from the payload and then upload the file to AEM. Below you can find the sample servlet to upload the asset in AEM. So you can the same code in your workflow process which will upload file in DAM.
https://github.com/arunpatidar02/aem63app-repo/blob/master/java/UploadAssets.java
3. Other process steps goes here to complete your business logic.
4. You can even send email notifications to the participants with all the required information to review it.
5. Assign the step to the participant to publish/Reject etc..
Hope this helps.
Thank you @Siva_Sogalapalli @ for sharing the steps
I'd transfrom the steps you suggested to my case, only for upload / download use:
1. Dialog Participant Step- Upload the asset file and store the path in payload
=> I have no problem with this.
2. Custom Process Step- Get the file path stored in payload temporarily and write it on workflow instance
=> Store the file path in workflow instance is necessary in my case. For example, there are different sections with different editors on the same page, and they all use the same workflow. If file path is stored in payload, it would be overwrite by the same workflow initiated by others.
So as long as the file is uploaded and write on payload, the Process Step, with the access to WorkflowSession and WorkItem, would write the path on workflow instance metadata.
3. Dialog Participant Step (? - Get the same file and download it
=> This step would be like, there is a button for user to click and download the same file which was uploaded. The file path is store on workflow instance metadata,
but without WorkflowSession and WorkItem, the step won't be able to get the instance.
I think my question could be narrowed down to the third step above.
Views
Likes
Replies