Unable to detect page copy event when copying page without children

The following code works when copying pages with hierarchy or children.

@EventListener
public void onPageStartCopyEvent(CopyPageHierarchyStartEvent startCopy)
{
Page page = startCopy.getPage();
ContentId pageId = page.getContentId();
log.warn("----page start copy event----");
}
@EventListener
public void onPageCopyEvent(PageCopyEvent copiedPage)
 {
Page page = copiedPage.getPage();
ContentId pageId = page.getContentId();
log.warn("----page copied event----");
}
@EventListener
public void onPageFinishCopyEvent(CopyPageHierarchyFinishEvent finishCopy)
{
Page page = finishCopy.getTargetPage();
ContentId pageId = page.getContentId();
log.warn("----page finish copy event----");
}

However, when copying page without children, the following events are triggered.

@EventListener
public void onPageCreatEvent(PageCreateEvent createdPage)
{
Page page = createdPage.getTargetPage();
ContentId pageId = page.getContentId();
log.warn("-----page created event----");
}

Followed by ContentUpdateEvent

@EventListener
public void onContentUpdatedEvent(ContentUpdatedEvent updatedContent)
{
ContentId pageId = updatedContent.getContentId();
log.warn("----content updated event----");
}

Unfortunately, both PageCreateEvent & ContentUpdatedEvent share page creation and page copy. I need away to differentiate between copy and create. Is there any events that I could refer to? Thank you

1 Like