How to detect that a document deletion takes place in a renaming context

Hi everyone,

In the frame of an extension which has to perform some actions on page removal, I was wondering whether there’s a canonical way to detect that a DocumentDeletedEvent takes place in a renaming context by opposition to a complete page removal. Currently, the listener performs the check below using the ObservationContext, but there might be something more appropriate, what do you think?

observationContext.isIn(new JobStartedEvent("refactoring/rename"));

Cheers

Stéphane

No, that’s exactly what ObservationContext was made for.

While the use of ObservationContext is the right direction the event you are using is not the most accurate one if you are running in XWiki 11.1+: you should look for DocumentRenamingEvent instead.

1 Like

Thanks Thomas, I’ll use DocumentRenamingEvent instead then.