Hi,
On deletion of a resource, I need get a property from the resource BEFORE the resource becoming null.
I tried this through Event Listener. In the event listener, the resource is null.
I tried to achieve this through on delete -> launcher -> workflow. Here also the resource is null. But in this workflow, I have only one processor which tries to get the resource details.
Here can I get the resource details before it gets deleted from the workflow? Actual deletion is done in OOTB code, how can move that code to my workflow?
Here How to take an action on a deleted Asset in Adobe Experience Manager? , Jörg said we can control when the actual deletion is called. But how?
thanks
Srini
Solved! Go to Solution.
Write a custom workflow step. Then using the AEM Workflow APIs, you can get the path of the node that is deleted. You can use this API logic that writes out the path of the node that will be deleted.
public void execute(WorkItem item, WorkflowSession wfsession, MetaDataMap args) throws WorkflowException {
try
{
WorkflowData data = item.getWorkflowData();
String path = null;
String type = data.getPayloadType();
if (data.getPayload() != null) {
String payloadData = (String) data.getPayload();
path = payloadData;
}
log.info("*** THE path of the node to DELETED IS "+path);
}
catch (Exception e)
{
log.info(" MASSIVE ERROR "+e.getMessage()) ;
}
}
Then the next step in the workflow deletes the page. This is how you get information about JCR content - typically a page that is deleted.
Workflow model --
Hope this helps....
Views
Replies
Total Likes
You can create a Custom Event Listener Class when a node is removed it.
Basically, you have to add your action and response when certain event occurs, in your case, it could be something like this ( javax.jcr.observation.Event.NODE_REMOVED)
Let me know if you need complete example, how to implemented
Best Regards
Diego
Hi,
Here my case is, the content which I am deleting is unpublished content. So in this case, Preprocessor won't get triggered. Any other option I have?
Views
Replies
Total Likes
To solve this requirement, you need to do what Joerg suggests. You need to build a custom workflow step and in that custom step, read the Java node props using a Java API. This step would be invoked before the payload was deleted - which would be a later step.
I will add this use case to our HELPX articles list.
TIP - An event handler will not work as the Event Handler will be fired after the node is deleted.
Views
Replies
Total Likes
Scott,
Thanks for your reply. Please let me know once the HELPX article is available. I already built a custom workflow with only one workflow step which triggers on node delete. But the resource is getting deleted by the time it comes to the workflow. Should I add one more step for deletion?
thanks
Srini
Views
Replies
Total Likes
I will look into this at code lvl tomorrow.
Views
Replies
Total Likes
I am going to show you how to perform this use case via a custom Workflow Step so we can read the information from the deleted node prior to deleting it. I will post back soon.
Views
Replies
Total Likes
Write a custom workflow step. Then using the AEM Workflow APIs, you can get the path of the node that is deleted. You can use this API logic that writes out the path of the node that will be deleted.
public void execute(WorkItem item, WorkflowSession wfsession, MetaDataMap args) throws WorkflowException {
try
{
WorkflowData data = item.getWorkflowData();
String path = null;
String type = data.getPayloadType();
if (data.getPayload() != null) {
String payloadData = (String) data.getPayload();
path = payloadData;
}
log.info("*** THE path of the node to DELETED IS "+path);
}
catch (Exception e)
{
log.info(" MASSIVE ERROR "+e.getMessage()) ;
}
}
Then the next step in the workflow deletes the page. This is how you get information about JCR content - typically a page that is deleted.
Workflow model --
Hope this helps....
Views
Replies
Total Likes
Hi, How can we trigger this workflow while a Node/Page is deleted. If I add a launcher for Removed for cq:Page, the workflow is triggered post the page is deleted.
Is there any way to trigger this workflow right before the page/node is deleted?
Views
Replies
Total Likes
how this is a correct answer?
As said by author, workflow is fired AFTER deletion, you cannot get properties of that deleted node.
For that you would need some sling post processor to dump the property to a place from which workflow can read it after deletion of the node
Views
Replies
Total Likes
This log file has this message -- /content/summit-toys/pt] com.aem.community.core.CustomDataStep *** THE TITLE OF THE DELETED ITEM IS /content/summit-toys/pt
This code works!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies