AEM 6.5: How do I remove an event from page? | Community
Skip to main content
Magicr
Level 6
June 30, 2022

AEM 6.5: How do I remove an event from page?

  • June 30, 2022
  • 4 replies
  • 2553 views

Hello,

through search in Internet I found this site: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/delete-event-listener/m-p/222731

Unfortunaltly the provided links produces a 404 error. So my question is, how can I remove an event from a page with AEM6.5?

 

Thanks in advanced.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

4 replies

Mohit_KBansal
Adobe Employee
Adobe Employee
June 30, 2022

@magicr Please check if there is any launcher configured for your page/hierarchy
<server>/libs/cq/workflow/admin/console/content/launchers.html

Magicr
MagicrAuthor
Level 6
June 30, 2022

Thanks for answer. I checked this page and I could not found any workflow for this event. Why schould I check it?

Mohit_KBansal
Adobe Employee
Adobe Employee
June 30, 2022

What kind of event is getting invoked? When it's invoked? Do you see any code in your repository causing this? Also, have you checked logs ?

arunpatidar
Community Advisor
Community Advisor
June 30, 2022

Hi,

The link works, here is the response from page

 

 

Hi Vishwanath,

Basically when you delete the pages/nodes or assets, the event listener must trigger the events.

Look into this article which discuss of your use case: 

https://helpx.adobe.com/experience-manager/using/events.html
https://helpx.adobe.com/experience-manager/kb/ReplicationListener.html

Thanks,
Ratna Kumar.

Arun Patidar
Magicr
MagicrAuthor
Level 6
July 1, 2022

@arunpatidar  schrieb:

Hi,

The link works, here is the response from page

 

 

Hi Vishwanath,

Basically when you delete the pages/nodes or assets, the event listener must trigger the events.

Look into this article which discuss of your use case: 

https://helpx.adobe.com/experience-manager/using/events.html
https://helpx.adobe.com/experience-manager/kb/ReplicationListener.html

Thanks,
Ratna Kumar.


For me the links redirects to https://community.adobe.com/

ShaileshBassi
Community Advisor
Community Advisor
June 30, 2022

@magicr Removing the event from the class "com.day.cq.wcm.api.PageEvent" will not be easy as could be that there are many things interlinked to this event.

Currently in AEM the Page event is registered with the topic "com/day/cq/wcm/core/page" and all the events i.e.

PROPERTY_MODIFICATIONS
PROPERTY_APPLICATION
PROPERTY_DISTRIBUTE

all are getting triggered from the single topic.

And the event PROPERTY_MODIFICATIONS consists of the below list 

    CREATED("PageCreated"),
    MODIFIED("PageModified"),
    MOVED("PageMoved"),
    DELETED("PageDeleted"),
    VERSION_CREATED("VersionCreated"),
    RESTORED("PageRestored"),
    ROLLEDOUT("PageRolledOut"),
    VALID("PageValid"),
    INVALID("PageInvalid");

And this is a list rather than some OSGi configuration which could be changed easily. So ideally removing the event a Page is not a feasible solution.

 

Thanks 

 

 

Shiv_Prakash_Patel
Community Advisor
Community Advisor
July 2, 2022

Hi @magicr,

If you are trying to trigger listeners on DELETE/REMOVED of Asset or Pages with EventHandler(org.osgi.service.event.EventHandler) that may not work properly because some of the EVENT_TOPIC( like TOPIC_RESOURCE_REMOVED, ) are deprecated and suggested to use ResourceChangeListener- https://sling.apache.org/apidocs/sling9/org/apache/sling/api/resource/observation/ResourceChangeListener.html 

Check out the deprecation here-  https://sling.apache.org/apidocs/sling9/org/apache/sling/api/SlingConstants.html#TOPIC_RESOURCE_REMOVED 

You can use ResourceChangeListener to trigger a listener on Page or Asset Deletion as below. It will work for all cases(Tested it, working fine for me):

  • Deleting Assets from the DAM
  • Deleting Pages from Sites
  • Deleting Assets or Pages from CRX/DE ( It will trigger when you will click on Save All)
@Component(service = ResourceChangeListener.class, property = {
ResourceChangeListener.PATHS + "=" + "/content",
ResourceChangeListener.CHANGES + "=" + "REMOVED"
}
)
public class RemovedResourceChangeListener implements ResourceChangeListener {
public static final Logger LOGGER = LoggerFactory.getLogger(RemovedResourceChangeListener.class);

@Override
public void onChange(List<ResourceChange> list) {
list.forEach((change) -> {
LOGGER.info(change.getPath());
LOGGER.info(change.getType().toString());
//Custom Code Implementation
});
}
}

Hope this could help you!!!

Regards,

Shiv

 

 

Shiv Prakash
Magicr
MagicrAuthor
Level 6
July 8, 2022

Thanks for your answer. It helped me a lot. Due to the fact that my question has been moved from questions to discussion I'm unable to mark this as accepted answer.