Class SubscriptionImpl
- java.lang.Object
-
- org.apache.jackrabbit.webdav.jcr.observation.SubscriptionImpl
-
- All Implemented Interfaces:
EventListener,ObservationConstants,Subscription,XmlSerializable
public class SubscriptionImpl extends Object implements Subscription, ObservationConstants, EventListener
TheSubscriptionclass encapsulates a single subscription with the following responsibilities:- Providing access to the subscription info,
- Recording events this subscription is interested in,
- Providing access to the events.
-
-
Field Summary
-
Fields inherited from interface org.apache.jackrabbit.webdav.observation.ObservationConstants
HEADER_POLL_TIMEOUT, HEADER_SUBSCRIPTIONID, N_EVENT, N_EVENTBUNDLE, N_EVENTDATE, N_EVENTDISCOVERY, N_EVENTINFO, N_EVENTMIXINNODETYPE, N_EVENTPRIMARYNODETYPE, N_EVENTTYPE, N_EVENTUSERDATA, N_EVENTUSERID, NAMESPACE, SUBSCRIPTIONDISCOVERY, XML_EVENT, XML_EVENT_LOCAL, XML_EVENT_TRANSACTION_ID, XML_EVENTBUNDLE, XML_EVENTDATE, XML_EVENTDISCOVERY, XML_EVENTIDENTIFIER, XML_EVENTINFO, XML_EVENTMIXINNODETYPE, XML_EVENTPRIMARNODETYPE, XML_EVENTSWITHLOCALFLAG, XML_EVENTSWITHTYPES, XML_EVENTTYPE, XML_EVENTUSERDATA, XML_EVENTUSERID, XML_FILTER, XML_NODETYPE_NAME, XML_NOLOCAL, XML_SUBSCRIPTION, XML_SUBSCRIPTIONID, XML_SUBSCRIPTIONINFO, XML_UUID
-
-
Constructor Summary
Constructors Constructor Description SubscriptionImpl(SubscriptionInfo info, ObservationResource resource)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleaneventsProvideNodeTypeInformation()booleaneventsProvideNoLocalFlag()static EventType[]getAllEventTypes()static EventTypegetEventType(int jcrEventType)Static utility method to convert the type defined by aJCR eventinto anEventTypeobject.static intgetJcrEventType(EventType eventType)Static utility method to convert anEventTypeas present in the Xml body into the corresponding JCR event constant defined byEvent.StringgetSubscriptionId()Returns the id of this subscription.voidonEvent(EventIterator events)Records the events passed as a new event bundle in order to make them available with the nextdiscoverEvents(long)request.protected static voidserializeInfoMap(Element eventElem, Session session, Map<?,?> map)ElementtoXml(Document document)Return the Xml representation of thisSubscriptionas required for theSubscriptionDiscoverywebdav property that in included in the response body of a successful SUBSCRIBE request or as part of a PROPFIND response.
-
-
-
Constructor Detail
-
SubscriptionImpl
public SubscriptionImpl(SubscriptionInfo info, ObservationResource resource) throws DavException
- Parameters:
info-resource-- Throws:
DavException- if resource is not based on a JCR repository or the repository does not support observation.
-
-
Method Detail
-
getSubscriptionId
public String getSubscriptionId()
Returns the id of this subscription.- Specified by:
getSubscriptionIdin interfaceSubscription- Returns:
- subscriptionId
-
eventsProvideNodeTypeInformation
public boolean eventsProvideNodeTypeInformation()
- Specified by:
eventsProvideNodeTypeInformationin interfaceSubscription- Returns:
- whether events will be returned with node type information
-
eventsProvideNoLocalFlag
public boolean eventsProvideNoLocalFlag()
- Specified by:
eventsProvideNoLocalFlagin interfaceSubscription- Returns:
- whether events will be returned with the "noLocal" flag
-
toXml
public Element toXml(Document document)
Return the Xml representation of thisSubscriptionas required for theSubscriptionDiscoverywebdav property that in included in the response body of a successful SUBSCRIBE request or as part of a PROPFIND response.- Specified by:
toXmlin interfaceXmlSerializable- Parameters:
document-- Returns:
- Xml representation
- See Also:
XmlSerializable.toXml(Document)
-
onEvent
public void onEvent(EventIterator events)
Records the events passed as a new event bundle in order to make them available with the nextdiscoverEvents(long)request. If this subscription is expired it will remove itself as listener from the observation manager.- Specified by:
onEventin interfaceEventListener- Parameters:
events- to be recorded.- See Also:
EventListener.onEvent(EventIterator),discoverEvents(long)
-
getEventType
public static EventType getEventType(int jcrEventType)
Static utility method to convert the type defined by aJCR eventinto anEventTypeobject.- Parameters:
jcrEventType-- Returns:
EventTyperepresentation of the given JCR event type.- Throws:
IllegalArgumentException- if the given int does not represent a valid type constants as defined byEvent.
Valid values are
-
getAllEventTypes
public static EventType[] getAllEventTypes()
- Returns:
- The DAV event type representation for all known JCR event types.
-
getJcrEventType
public static int getJcrEventType(EventType eventType) throws DavException
Static utility method to convert anEventTypeas present in the Xml body into the corresponding JCR event constant defined byEvent.- Parameters:
eventType-- Returns:
- Any of the event types defined by
Event.
Possible values are - Throws:
DavException- if the given event type does not define a valid JCR event type, such as returned bygetEventType(int).
-
-