com.day.cq.replication.ReplicationEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aem-sdk-api Show documentation
Show all versions of aem-sdk-api Show documentation
The Adobe Experience Manager SDK
The newest version!
/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
* Copyright 2011 Adobe
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains
* the property of Adobe and its suppliers, if any. The intellectual
* and technical concepts contained herein are proprietary to Adobe
* and its suppliers and are protected by all applicable intellectual
* property laws, including trade secret and copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe.
**************************************************************************/
package com.day.cq.replication;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.sling.event.dea.DEAConstants;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventProperties;
/**
* An event fired when some {@link ReplicationAction} needs to be handled
*/
public class ReplicationEvent implements Serializable {
public static final String EVENT_TOPIC = "com/adobe/granite/replication";
public static final String PATHS = "paths";
private static final String PROPERTY_MODIFICATIONS = "modifications";
private static final String TYPE = "type";
private static final String TIME = "time";
private static final String USER_ID = "userId";
private static final String REVISION = "revision";
/**
* the replication action associated with this event
*/
private ReplicationAction replicationAction;
/**
* Is this a local event?
*/
private final boolean isLocal;
public ReplicationEvent(ReplicationAction replicationAction) {
this(replicationAction, true);
}
public ReplicationEvent(ReplicationAction replicationAction, boolean isLocal) {
this.replicationAction = replicationAction;
this.isLocal = isLocal;
}
/**
* Returns the underlying {@link ReplicationAction} which fired this event
*
* @return the replication action which caused the event
*/
public ReplicationAction getReplicationAction() {
return this.replicationAction;
}
/**
* Convert an OSGi event to a replication event if possible.
*
* @param evt The OSGi event.
* @return The replication event
*/
public static ReplicationEvent fromEvent(Event evt) {
if (!evt.getTopic().equals(EVENT_TOPIC)) {
return null;
}
ReplicationAction action = null;
String[] paths;
ReplicationActionType type;
Long time;
String userId;
String revision;
@SuppressWarnings("unchecked")
final List