Event Handler not triggered in AEM 6.3
Hi all,
I have a requirement where i have to trigger the event handler to read all the images in a particular dam folder when ever an asset is added. the dam folder structure can have multiple levels where we add assets inside each folder. I used JCR EventListener which is working fine but not working for EventHandler. I'm using OSGI DS annotations in Archetype 11. Please find the code below. What am i missing? It's not getting triggered at all.
package uk.co.my.project.my_project.core.impl;
import org.apache.sling.api.SlingConstants;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import uk.co.my_project.core.service.ProductDAMService;
@Component(
immediate = true,
service = EventHandler.class,
property = {
EventConstants.EVENT_FILTER + "=(path=/content/dam/my_project/*)",
EventConstants.EVENT_TOPIC + "=" + SlingConstants.TOPIC_RESOURCE_ADDED,
EventConstants.EVENT_TOPIC + "=" + SlingConstants.TOPIC_RESOURCE_CHANGED,
EventConstants.EVENT_TOPIC + "=" + SlingConstants.TOPIC_RESOURCE_REMOVED
},
configurationPid = "uk.co.my.project.my_project.core.impl.ProductDAMEventHandler"
)
public class ProductDAMEventHandler implements EventHandler {
private Logger log = LoggerFactory.getLogger(this.getClass());
@Reference
private ProductDAMService productDAMService;
@Override
public void handleEvent(Event event) {
String topic = event.getTopic();
Object path = event.getProperty(SlingConstants.PROPERTY_PATH);
log.info("Inside the event handler for DAM:"+topic+":::path:"+path);
boolean associateDAMAndPoducts = productDAMService.associateDAMAndPoducts();
log.info("assets associated:" + associateDAMAndPoducts);
}
}
I've taken this as reference
