Hi, As suggested, we have implemented the below EventHandler, to capture page events like create, modify, delete, activate and de activate using Page events and Replication events), which we are interested. Please confirm whether this approach is correct.
We have to handle the below 3 more scenarios, please suggest.
1. First time, as one time activity, we have to store the current status of all the pages ( page url, locale, node_update_date) in CQ into DB.
2. On adhoc basic, we have to store the current status of all the pages for certain time period (say from date to to date).
3. The event handler should be running always and should handle bulk activation's (say 1000 at a time), please suggest the proper design to the event handler.
package com.intel.myintel.servlets;
import com.day.cq.replication.ReplicationAction;
import com.day.cq.wcm.api.PageEvent;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
@Component
@Service
@Property(name="event.topics",value= {ReplicationAction.EVENT_TOPIC, PageEvent.EVENT_TOPIC})
public class CustomAgent implements EventHandler {
private final Logger LOG = LoggerFactory.getLogger(CustomAgent.class);
@Override
public void handleEvent(org.osgi.service.event.Event event) {
if (event.getTopic().equals(ReplicationAction.EVENT_TOPIC)){
LOG.info("Event captured!!");
// get page url,locale,node_update_date and save to DB
}else if(event.getTopic().equals(PageEvent.EVENT_TOPIC)){
LOG.info("Event captured!!");
// get page url,locale,node_update_date and save to DB
}
}
}