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
TheSubscription
class 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 boolean
eventsProvideNodeTypeInformation()
boolean
eventsProvideNoLocalFlag()
static EventType[]
getAllEventTypes()
static EventType
getEventType(int jcrEventType)
Static utility method to convert the type defined by aJCR event
into anEventType
object.static int
getJcrEventType(EventType eventType)
Static utility method to convert anEventType
as present in the Xml body into the corresponding JCR event constant defined byEvent
.String
getSubscriptionId()
Returns the id of this subscription.void
onEvent(EventIterator events)
Records the events passed as a new event bundle in order to make them available with the nextdiscoverEvents(long)
request.protected static void
serializeInfoMap(Element eventElem, Session session, Map<?,?> map)
Element
toXml(Document document)
Return the Xml representation of thisSubscription
as required for theSubscriptionDiscovery
webdav 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:
getSubscriptionId
in interfaceSubscription
- Returns:
- subscriptionId
-
eventsProvideNodeTypeInformation
public boolean eventsProvideNodeTypeInformation()
- Specified by:
eventsProvideNodeTypeInformation
in interfaceSubscription
- Returns:
- whether events will be returned with node type information
-
eventsProvideNoLocalFlag
public boolean eventsProvideNoLocalFlag()
- Specified by:
eventsProvideNoLocalFlag
in interfaceSubscription
- Returns:
- whether events will be returned with the "noLocal" flag
-
toXml
public Element toXml(Document document)
Return the Xml representation of thisSubscription
as required for theSubscriptionDiscovery
webdav property that in included in the response body of a successful SUBSCRIBE request or as part of a PROPFIND response.- Specified by:
toXml
in 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:
onEvent
in 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 event
into anEventType
object.- Parameters:
jcrEventType
-- Returns:
EventType
representation 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 anEventType
as 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)
.
-
-