Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

On Deletion, how to get the resource details before it gets deleted?

Avatar

Avatar
Validate 1
Level 2
Srinin
Level 2

Like

1 like

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 2
Srinin
Level 2

Like

1 like

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
Srinin
Level 2

18-08-2017

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

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

23-08-2017

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 --

cusStep.png

Hope this helps....

Answers (8)

Answers (8)

Avatar

Avatar
Validate 1
Level 4
Diego_Fontan
Level 4

Likes

29 likes

Total Posts

62 posts

Correct Reply

12 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
Diego_Fontan
Level 4

Likes

29 likes

Total Posts

62 posts

Correct Reply

12 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
Diego_Fontan
Level 4

20-08-2017

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

Avatar

Avatar
Validate 1
Level 3
poojac35931336
Level 3

Likes

20 likes

Total Posts

50 posts

Correct Reply

8 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile

Avatar
Validate 1
Level 3
poojac35931336
Level 3

Likes

20 likes

Total Posts

50 posts

Correct Reply

8 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
poojac35931336
Level 3

20-08-2017

You can implement Preprocessor to fetch the data from resource before it's deletion. Remember Preprocessor works only on activated page as mentioned here.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

23-08-2017

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!

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

23-08-2017

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.

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

22-08-2017

I will look into this at code lvl tomorrow.

Avatar

Avatar
Validate 1
Level 2
Srinin
Level 2

Like

1 like

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 2
Srinin
Level 2

Like

1 like

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
Srinin
Level 2

22-08-2017

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

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

22-08-2017

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.

Avatar

Avatar
Validate 1
Level 2
Srinin
Level 2

Like

1 like

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 2
Srinin
Level 2

Like

1 like

Total Posts

22 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
Srinin
Level 2

22-08-2017

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?