Mentioning Multiple paths in EventHandler class | Community
Skip to main content
Level 7
December 12, 2023
Solved

Mentioning Multiple paths in EventHandler class

  • December 12, 2023
  • 3 replies
  • 1636 views

Hello All,

 

I have CustomEventHandler class which implements  EventHandler interface.

handleEvent method is called during page activation, deactivation, deletion time. Here, I need to mention the page path. I mean if a page is present under /content/abc/project/en then only my custom event handler should trigger. I need to mention multiple page path.   /content/abc/project/en,   /content/xyz/project/en

Any help in this?

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

Hi @arunpatidar 

Checked your code. Still have confusion.

As of now, I have used: EventConstants.EVENT_FILTER + "=(paths=/content/abc/myArticle/*)"

 

Now, how to mention 2 paths here:

/content/abc/myArticle/*
/content/abc/newArticle/*

 

Since, your code has:  EventConstants.EVENT_FILTER + "(&" + "(path=/content/we-retail/us/en/*/jcr:content) (|("
+ SlingConstants.PROPERTY_CHANGED_ATTRIBUTES + "=*jcr:title) " + "(" + ResourceChangeListener.CHANGES
+ "=*jcr:title)))" })


here you go

https://github.com/arunpatidar02/aem63app-repo/blob/24aaa3d42fb06f5f43df94a0acefb13bc08807bc/java/ReplicationEvent2.java#L16 

 

|(paths=/content/abc/myArticle/*)(paths=/content/abc/newArticle/*)

 

3 replies

divanshug
Adobe Champion
Adobe Champion
December 12, 2023
arunpatidar
Community Advisor
Community Advisor
December 12, 2023
Arun Patidar
aanchal-sikka
Community Advisor
Community Advisor
December 12, 2023

@mahesh_gunaje 

 

Preferably use ResourceChangeListener

 

It will also allow you to use multiple paths

https://techrevel.blog/2017/03/15/resourcechangelistener/

Aanchal Sikka
Level 7
December 12, 2023

Hi @aanchal-sikka 

ResourceChangeListener logic sounds interesting. But in my case, if I use implements EventHandler, then I can write my logic for 

if ReplicationActionType.ACTIVATE :  call add customMethod();

if ReplicationActionType.DEACTIVATE :  call customDelete Method

if ReplicationActionType.DELETE:  call customDelete Method

So, How can I call my method if i implement ResourceChangeListener.

I can see only one method.

aanchal-sikka
Community Advisor
Community Advisor
December 13, 2023

Hello @mahesh_gunaje 

 

Please refer to this blog https://aemhints.com/2020/11/08/event-listener-in-aem-6-5/

 

It uses Event Handler with multiple Paths.

Aanchal Sikka