Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Set up PageEvent Handler/Listener

Avatar

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
gregorio_meraz
Level 1

07-02-2019

Hello AEM Community

Im currently working on setting up a event handler for page creations and deletions on aem to then call one of our vendors API.

Ive been basing my work on a module we already have that listens to replication events.

So far i was able to reproduce that behavior on my module and trigger the code upon replications. However, i only need the calls to the API on Page Publications and deletions.

Ive been trying to find how to diferentiate between replications and page deletions and activations.

So far, it seems that AEM handles crx replications and page publications as the same type of event "type= ACTIVATION".

If i delete a page, it does set the type as "DELETE" so i can work with that to call  the API but for the page publications im lost since as i mentioned, AEM looks like it handles CRX replications and pages publications as the same type.

After some research, i found the PageEvent API and I tried to set up a Page Event Listener but it is not getting triggered upon publications or deletions of pages, so im not sure that if what im trying to do its possible or maybe my componet is located on a wrong part of the project to listen for Page Events.

Thanks beforehand

Replies

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,077 likes

Total Posts

3,112 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,077 likes

Total Posts

3,112 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

07-02-2019

What is the difference between "CRX replication" and "page publication" from your point of view?

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,406 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

07-02-2019

Have you written code that uses the PageEvent API:

https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/in..."The Adobe AEM Quickstart and Web Application."

This is certainly the API to use to capture page changes.

Can you post it so the community can see if its properly set up to help solve your issue?

Avatar

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
gregorio_meraz
Level 1

07-02-2019

Hello.

So, for example, if i go to crx and i replicate any of the files we already have being html, css or js, i get a replicate type=ACTIVATE event.

However, we only want to catch whenever a new page is created or deleted.

Not sure if that answers your question

Avatar

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
gregorio_meraz
Level 1

07-02-2019

yes, ill post what i have currently.

I dont see an option to edit the original post so ill post it here.

Component(

   configurationPolicy = ConfigurationPolicy.REQUIRE,
   immediate = true,
   service = EventHandler.class)

@Designate(ocd = APIConfiguration.class)

public class CustomEventListener implements EventHandler {

   private static final Logger LOGGER = LoggerFactory.getLogger(CustomEventListener.class);

  
  public void handleEvent(final Event event) {

   LOGGER.debug("handling event");
   PageEvent pgEvent = PageEvent.fromEvent(event);
   LOGGER.debug(pgEvent.toString());
   LOGGER.debug(pgEvent.toEvent().toString());


   }

}

on my config class i have:

@ObjectClassDefinition(

   name = "API Connection Details",
   description = "APIConnection Details")

public @interface APIConfiguration {

   @AttributeDefinition(

   name = EventConstants.EVENT_TOPIC,
   description = "Page Action Event"
   )

  String page_topics() default PageEvent.EVENT_TOPIC;
}

So whenever i either create a new page or delete it from AEM Dashboard the code doesnt get triggered.

It only works if add the replication topic to the config class.

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,077 likes

Total Posts

3,112 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,077 likes

Total Posts

3,112 posts

Correct Reply

1,060 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

07-02-2019

When you want to track creation or deletion of pages (and ignore all activation and deactivation stuff) on a single instance, you can use eventing for it.

Create a page in your AEM instance then check localhost:4502/system/console/events for the event describing the page creation.

Avatar

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
gregorio_meraz
Level 1

07-02-2019

ok, seems that the topic would be: org/apache/sling/api/resource/Resource/ADDED for page additions

And org/apache/sling/api/resource/Resource/REMOVED

Avatar

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
gregorio_meraz
Level 1

07-02-2019

I set both topics on the configuration file

topics config.png

but i still dont get the event triggered upon page addition or deletion even tho i can see the event with the topic being generated correctly on /system/console/events

Avatar

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
gregorio_meraz
Level 1

Like

1 like

Total Posts

6 posts

Correct Reply

0 solutions
Top badges earned
Boost 1
View profile
gregorio_meraz
Level 1

08-02-2019

any idea why it wont tigger even if the topics are bindend to the module?

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

08-02-2019

Debug the code to check if it get's registered and listens to the topics or not? If not, then possibly you're running into some API versions/library versions conflicts.

check if this helps - java - AEM 6.3 - Creating Event handler using OSGi R6 annotations - Stack Overflow

this one uses SCR annotations - Adobe CQ Help | Creating Replication Event Handlers for Adobe Experience Manager