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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Sling Event Listener

Murali89
Level 3
Level 3

Is there way to listen to the Tag Move events? I could find there is one for Page move when we have event topic value as below

EventConstants.EVENT_TOPIC + "=com/day/cq/wcm/core/page"

But i want to do something when tags are moved around namespaces.

3 Replies
Arun_Patidar
Community Advisor
Community Advisor

Hi,

like page move , there is no special event for Tag move. When we move Tags it will create events like CHANGED and ADDED wrt to destination and source of tag.

e.g. if I move /etc/tags/we-retail/activity/biking tag to we-retail root(/etc/tags/we-retail/), following events are captured.

Screen Shot 2018-06-18 at 2.26.31 PM.png

Thanks

Arun

Techaspect_Solu
Level 7
Level 7

Hi,

There is no specific EVENT for the 'tags', instead of EVENT_TOPIC we can use EVENT_FILTER. The following code snippet can be used for the event to be triggered  when tag is moved from one namespace to other.

@Component(

  immediate = true,

  service = EventHandler.class,

  property = {

    EventConstants.EVENT_FILTER + "=(path=/etc/tags/*)",

    EventConstants.EVENT_TOPIC + "=" + SlingConstants.TOPIC_RESOURCE_ADDED,

    EventConstants.EVENT_TOPIC + "=" + SlingConstants.TOPIC_RESOURCE_CHANGED,

    EventConstants.EVENT_TOPIC + "=" + SlingConstants.TOPIC_RESOURCE_REMOVED

  }

)

public class EventHandlerDemo implements EventHandler {

@Override

public void handleEvent(Event event) {

  String topic = event.getTopic();

  Object path = event.getProperty(SlingConstants.PROPERTY_PATH);

  logger.info("Path of the asset and topic of the event:" + topic + ":::path:" + path);

}

}

Hope this helps.

Regards,

TechAspect Solutions