As part of importing a Word document, there's the option to replace an existing page and trashing that existing page's children. It looks like this doesn't publish an event, but only updates the contentstatus of each child to TRASHED, so it gets past my existing event listener for trashed events.
Is there some sort of content status change listener I can implement?
Hei Fredrick
I would suggest the following workaround, while the team addresses the issue of missing events
import com.atlassian.confluence.api.model.content.ContentStatus;
import com.atlassian.confluence.core.ContentEntityObject;
import com.atlassian.confluence.event.events.content.page.PageUpdateEvent;
import com.atlassian.event.api.EventListener;
import com.atlassian.event.api.EventPublisher;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Component
public class ContentStatusUpdateListener {
private final EventPublisher eventPublisher;
@Autowired
public ContentStatusUpdateListener(
final @ComponentImport EventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
@PostConstruct
public void register() {
eventPublisher.register(this);
}
@PreDestroy
public void unregister() {
eventPublisher.unregister(this);
}
@EventListener
public void onPageUpdate(final PageUpdateEvent event) {
final ContentEntityObject updated = event.getContent();
if (updated.getContentStatusObject().equals(ContentStatus.TRASHED)) {
// TODO
}
}
}
Find the full commit on my sample confluence plugin available here: https://bitbucket.org/viqueen/atlassian-community/commits/47e55618cd742fc51fd7c035747f0a35d5b9075b
If you have any further questions do let us know!
Have a nice day.
Never thought about checking the PageUpdateEvent - will try that out, thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Meant to update with eventual resolution...So, checking the PageUpdateEvent gives a hook to see what the status of the page is after Word Import, but doesn't really have any tie to the WordImportAction that initially caused that event.
Ended up storing info about the children of the page being edited via word import with a listener on WordImportAction, then checked the eventual PageUpdateEvent to see if the number of children changed, and went from there. There doesn't look like there's a way to find out page deletions were caused by a WordImportAction without temporarily storing information during initial action to check during the event, or by adding a custom event to WordImportAction...Kinda disappointing.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.