Unable to detect page copy event when copying page without children
Asked by linnn aung:

> ***The following code works when copying pages with hierarchy or children.***   
>
> @EventListener  
> public void on PageStartCopyEvent(CopyPageHierarchyStartEvent startCopy)  
> {  
> log.warn("----page start copy event----");  
> Page page = startCopy.getPage();  
> ContentId pageId = page.getContentId();  
>
> }  
> @EventListener  
> public void onPageCopyEvent(PageCopyEvent copiedPage)  
> {  
> log.warn("----page copied event----");  
> Page page = copiedPage.getPage();  
> ContentId pageId = page.getContentId();  
>
> }  
> @EventListener  
> public void onPageFinishCopyEvent(CopyPageHierarchyFinishEvent finishCopy)  
> {  
> log.warn("----page finish copy event----");  
> Page page = finishCopy.getTargetPage();  
> ContentId pageId = page.getContentId();  
>
> }  
>
> ***However, when copying page without children, the following events are triggered.***   
>
> @EventListener  
> public void onPageCreatEvent(PageCreateEvent createdPage)  
> {  
> log.warn("-----page created event----");  
> Page page = createdPage.getTargetPage();  
> ContentId pageId = page.getContentId();  
>
> }  
>
> ***Followed by ContentUpdateEvent***
>
> @EventListener  
> public void onContentUpdatedEvent(ContentUpdatedEvent updatedContent)  
> {  
> log.warn("----content updated event----");  
> ContentId pageId = updatedContent.getContentId();  
> }  
>
> ***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***   


Answers:
author: Shannon S
body: [@linnn aung](/t5/user/viewprofilepage/user-id/3598042),

Welcome to Atlassian Community! It's great to have you join us.

Could you let us know exactly what you're trying to do in Confluence? Can you tell us where you found the snippet you are referencing?

If you have questions about developing for Confluence, I would recommend reaching out on our [Atlassian Developer Community](https://developer.atlassian.com/resources), as they may be better suited to assist you.

Regards,

Shannon

comments: author: linnn aung
body: [@Shannon S](/t5/user/viewprofilepage/user-id/510046)

Thank you.

(1) I'm trying to listen page events for my add-Ons that syn with custom system.  
In other words, Whenever page copy events happened, I needed info about that copied page (for example, page property that I created before copied. Once page is copied, it didn't carry along add-ons page property that you created).  
EventListener triggers when copying page with children or hierarchy.  
However, when copying page without children or hierarchy, it falls into the category of page creation events. I needed to differentiate between create and copy though technically, they are the same.   

(2) I wrote it. You can check on java docs for specific events.

(3) Yes, I have posted as well on Atlassian Developer Community.


author: Shannon S
body: Hi [@linnn aung](/t5/user/viewprofilepage/user-id/3598042),

Thank you for confirming. If this is for an add-on you're writing, then the Dev community is the right place for that.

Can you share with us the link to the question in case anyone wants to follow the progress there?

Regards,

Shannon


author: linnn aung
body: Hi [@Shannon Spaniol](https://community.atlassian.com/t5/user/viewprofilepage/user-id/510046),  

Here is the link that I posted in atlas developer community <https://community.developer.atlassian.com/t/unable-to-detect-page-copy-event-when-copying-page-without-children/32680> .

Thank you.


author: Shannon S
body: Hi Linnn, thank you for sharing that!

Hopefully they will be able to give you some good advice there. :)

Take care, and have a pleasant week.

Regards,  
Shannon


Tags: confluence-server

event

listener

server