Expand my Community achievements bar.

SOLVED

CQ5 modify event fired on page delete

Avatar

Level 1

Hi there!

I'm trying to use CQ5 workflow to control my resources (page in particular). 
I want to start different scripts on different events (Add/Delete/Modify). I have registered a launcher on each event.
When I delete a page anyway both the delete and modify events get fired and so both the script run. I can't understand how to exclude the modify event on delete.

Thanks for any advice

1 Accepted Solution

Avatar

Correct answer by
Employee

When the delete event is fired the resource will unfortunately be gone.  There is no capability in workflow launchers to start a workflow on a node being deleted and have it execute before the node is gone.

As for the modification event firing when a node is deleted --> are you sure there are no nodes being modified before the delete occurs?  What is the payload of the workflow for the modified event?

Providing details on how you've configured the launchers, what the payloads are for the workflows started, and what actions in the repository were taken to make these workflows fire might help.  Also what version are you running?

thanks,

Will

View solution in original post

4 Replies

Avatar

Level 10

Are you using a javax.jcr.observation.ObservationManager to setup your event handler? If you setup the event using this API, you can specify which event the handler should respond to using Event. For example - this responds to a new node:

// Setup the event handler to respond to a new claim under content/claim.... 
 observationManager = session.getWorkspace().getObservationManager();
 final String[] types = { "nt:unstructured","sling:Folder" };
 final String path = "/content/claim"; // define the path
 observationManager.addEventListener(this, Event.NODE_ADDED, path, true, null, types, false);
 log.info("Observing property changes to {} nodes under {}", Arrays.asList(types), path);

Avatar

Level 1

I'm working directly on the workflow CQ5 console (http://localhost:4502/libs/cq/workflow/content/console.html). I've defined 3 models (which use 3 .ecma scripts) and 3 different launcher (one for each event).

The firts issue is that on the delete event also the modifcation is fired. The latter (I've just discovered this one) is that when the delete event is fired the resource is no longer available: I'm guessing if there's a way to catch the event before the effective deleting.

Avatar

Correct answer by
Employee

When the delete event is fired the resource will unfortunately be gone.  There is no capability in workflow launchers to start a workflow on a node being deleted and have it execute before the node is gone.

As for the modification event firing when a node is deleted --> are you sure there are no nodes being modified before the delete occurs?  What is the payload of the workflow for the modified event?

Providing details on how you've configured the launchers, what the payloads are for the workflows started, and what actions in the repository were taken to make these workflows fire might help.  Also what version are you running?

thanks,

Will

Avatar

Level 10

You are using a higher level event model. The ObservationManager monitors at the JCR level. I will ask our Workflow Eng member to look at this one.