Skip to main content
Jul 6, 2018 11:27 AM UTC
Solved

Event listener for patterned path

Hi Friends,

As per the API of observation manager, we can't use regular expression as path while adding the event using Event Listener.

Is there any other way of adding regular expression path except Event Handler(we can use regular expression path).

Use case : I want to trigger the event for home page of all locales and countries  /content/google/en/us/home ->  /content/google/*/*/home

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
Community Advisor
Jul 6, 2018 12:03 PM UTC

Hi,

No you can't use RegEx in place of absolute path while adding Listener but you can do while listening.

ObservationManager (Content Repository for Java Technology API 1.0)

OnEvents function you can write condition to check path with regex.

for example :

public void onEvent(EventIterator it) {

  while (it.hasNext()) {

  Event event = it.nextEvent();

  try {

  Property changedProperty = session.getProperty(event.getPath());

  if (changedProperty.getName().equalsIgnoreCase("jcr:title")

  logger.info("*************Property updated: {}", event.getPath());

 

  }

  }

  catch (Exception e) {

  logger.error(e.getMessage(), e);

  }

  }

Thanks

Arun

Arun Patidar

2 replies

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
Jul 6, 2018 12:03 PM UTC

Hi,

No you can't use RegEx in place of absolute path while adding Listener but you can do while listening.

ObservationManager (Content Repository for Java Technology API 1.0)

OnEvents function you can write condition to check path with regex.

for example :

public void onEvent(EventIterator it) {

  while (it.hasNext()) {

  Event event = it.nextEvent();

  try {

  Property changedProperty = session.getProperty(event.getPath());

  if (changedProperty.getName().equalsIgnoreCase("jcr:title")

  logger.info("*************Property updated: {}", event.getPath());

 

  }

  }

  catch (Exception e) {

  logger.error(e.getMessage(), e);

  }

  }

Thanks

Arun

Translate
Arun Patidar
Level 2
Feb 25, 2024 2:20 AM UTC

Hi @vishalm91130305 

Can you share approach you used?

Translate