use of com.day.cq.replication.ReplicationEvent in project acs-aem-commons by Adobe-Consulting-Services.
the class JcrPackageReplicationStatusEventHandler method getInfoFromEvent.
/**
* Extracts relevant event information from a Granite Replication Event OR a Day CQ Replication event.
* @param event the Osgi Event
* @return a Map containing the relevant data points.
*/
protected final Map<String, Object> getInfoFromEvent(Event event) {
final Map<String, Object> eventConfig = new HashMap<>();
final ReplicationEvent replicationEvent = ReplicationEvent.fromEvent(event);
if (replicationEvent != null) {
// Granite event
final ReplicationAction replicationAction = replicationEvent.getReplicationAction();
eventConfig.put(PROPERTY_PATHS, replicationAction.getPaths());
eventConfig.put(PROPERTY_REPLICATED_BY, replicationAction.getUserId());
} else {
// CQ event
String[] paths = (String[]) event.getProperty(ReplicationAction.PROPERTY_PATHS);
if (paths == null) {
paths = ArrayUtils.EMPTY_STRING_ARRAY;
}
String userId = (String) event.getProperty(ReplicationAction.PROPERTY_USER_ID);
if (StringUtils.isBlank(userId)) {
userId = StringUtils.defaultIfEmpty(this.replicatedByOverride, FALLBACK_REPLICATION_USER_ID);
}
eventConfig.put(PROPERTY_PATHS, paths);
eventConfig.put(PROPERTY_REPLICATED_BY, userId);
}
return eventConfig;
}
Aggregations