com.day.cq.wcm.api.PageEvent 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
/*
* Copyright 1997-2008 Day Management AG
* Barfuesserplatz 6, 4001 Basel, Switzerland
* All Rights Reserved.
*
* This software is the confidential and proprietary information of
* Day Management AG, ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Day.
*/
package com.day.cq.wcm.api;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.sling.event.dea.DEAConstants;
import org.osgi.service.event.Event;
/**
* This event is fired for each page change.
*/
public final class PageEvent implements Serializable {
/**
* Event topic for page modification events.
*/
public static final String EVENT_TOPIC = "com/day/cq/wcm/core/page";
/**
* event property name of the modifications
*/
private static final String PROPERTY_MODIFICATIONS = "modifications";
private static final String PROPERTY_APPLICATION = "event.application";
private static final String PROPERTY_DISTRIBUTE = "event.distribute";
/**
* Is this a local event?
*/
private final boolean isLocal;
/**
* The list of modifications
*/
private final List modifications;
public PageEvent(PageModification mod) {
this(Collections.singletonList(mod), true);
}
public PageEvent(final List mods) {
this(mods, true);
}
public PageEvent(final List mods, final boolean isLocal) {
this.modifications = mods;
this.isLocal = isLocal;
}
/**
* Get the list of modifications.
*
* @return An iterator for the modifications.
*/
public Iterator getModifications() {
return this.modifications.iterator();
}
/**
* Is this a local or a cluster event?
* @return true
if this is a local event
*/
public boolean isLocal() {
return this.isLocal;
}
/**
* Convert an OSGi event to a page event if possible.
*
* @param evt The OSGi event.
* @return The page even or null.
*/
public static PageEvent fromEvent(Event evt) {
if (!evt.getTopic().equals(EVENT_TOPIC)) {
return null;
}
final List mods = new ArrayList();
@SuppressWarnings("unchecked")
final List