简体   繁体   中英

How to read a JCR Node's properties BEFORE it's deleted in Adobe Experience Manager?

I need to audit properties of a JCR Node before the OTB deleted workflow physically deletes the node.

AEM provides a few ways to listen to deleted events. I've tried both the EventListener and a ResourceChangeListner. Both scenarios alert my code when a delete is triggered. However, I receive a "does not exist" when performing a session.getNode on the onChange path.

To validate I'm using the correct session/user/etc, I tested that I AM able to retrieve the node's parent. So, this proves I have the correct permissions and my listener is being informed after the node is already gone. Also, I have seen this work at least once so this is, obviously, a race condition. Sometimes I am alerted before the node is gone sometimes I am not.

So, how do I guarantee my code will be called before the JCR Node is actually gone?

Before you reference this post , I am applying solutions #2 and #3. Both have the same race condition result. #1 doesn't describe how to tie into the existing OTB AEM 'delete' 'workflow', is that possible?

To answer your last question, yes it is possible and in my opinion the easiest way.
See here how to extend Workflows.
And see here in the official documentation how to interact with workflows programmatically.

If you need to read the data on specific nodes, you could also write your own workflow and apply it on those nodes with a workflow launcher. See this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM