/** * @see ObservationResource#subscribe(org.apache.jackrabbit.webdav.observation.SubscriptionInfo, String) * @see SubscriptionManager#subscribe(org.apache.jackrabbit.webdav.observation.SubscriptionInfo, String, org.apache.jackrabbit.webdav.observation.ObservationResource) */ @Override public Subscription subscribe(SubscriptionInfo info, String subscriptionId) throws DavException { return subsMgr.subscribe(info, subscriptionId, this); }
/** * * @return true if a {@link ObservationConstants#XML_NOLOCAL} element * is present in the {@link SubscriptionInfo}. */ boolean isNoLocal() { return info.isNoLocal(); }
/** * Retrieve the {@link org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery} * object for the given resource. Note, that the discovery object will be empty * if there are no subscriptions present.<br> * Note that all subscriptions present on the given resource are returned. * However, the subscription id will not be visible in order to avoid abuse * by clients not having registered the subscription originally. * * @param resource */ public SubscriptionDiscovery getSubscriptionDiscovery(ObservationResource resource) { Subscription[] subsForResource = subscriptions.getByPath(resource.getLocator()); return new SubscriptionDiscovery(subsForResource); }
/** * Returns the Xml representation of the subscription discovery. * * @return Xml representation * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document) * @param document */ public Element toXml(Document document) { Element elem = getName().toXml(document); for (int i = 0; i < subscriptions.length; i++) { elem.appendChild(subscriptions[i].toXml(document)); } return elem; }
/** * @return The DAV event type representation for all known JCR event types. */ public static EventType[] getAllEventTypes() { EventType[] types = DefaultEventType.create(EventUtil.EVENT_ALL, NAMESPACE); return types; }
public Element toXml(Document document) { return delegatee.toXml(document); }
/** * @return true if this subscription is intended to be deep. */ boolean isDeep() { return info.isDeep(); }
public boolean eventsProvideNoLocalFlag() { return delegatee.eventsProvideNoLocalFlag(); } }
public boolean eventsProvideNodeTypeInformation() { return delegatee.eventsProvideNodeTypeInformation(); }
private String[] getFilterValues(String filterLocalName) { List<String> values = new ArrayList<String>(); for (Filter filter : info.getFilters(filterLocalName, NAMESPACE)) { String val = filter.getValue(); if (val != null) { values.add(val); } } return (values.size() > 0) ? values.toArray(new String[values.size()]) : null; }
/** * Modify the {@link SubscriptionInfo} for this subscription. * * @param info */ void setInfo(SubscriptionInfo info) { this.info = info; // validate the timeout and adjust value, if it is invalid or missing long timeout = info.getTimeOut(); if (timeout <= 0) { timeout = DEFAULT_TIMEOUT; } expirationTime = System.currentTimeMillis() + timeout; }
/** * @see ObservationResource#unsubscribe(String) * @see SubscriptionManager#unsubscribe(String, org.apache.jackrabbit.webdav.observation.ObservationResource) */ @Override public void unsubscribe(String subscriptionId) throws DavException { subsMgr.unsubscribe(subscriptionId, this); }
/** * @see ObservationResource#poll(String, long) * @see SubscriptionManager#poll(String, long, org.apache.jackrabbit.webdav.observation.ObservationResource) */ @Override public EventDiscovery poll(String subscriptionId, long timeout) throws DavException { return subsMgr.poll(subscriptionId, timeout, this); }
/** * @param resource * @return JCR session */ private static Session getRepositorySession(ObservationResource resource) throws DavException { return JcrDavSession.getRepositorySession(resource.getSession()); }
/** * @return JCR compliant integer representation of the event types defined * for this {@link SubscriptionInfo}. */ int getJcrEventTypes() throws DavException { EventType[] eventTypes = info.getEventTypes(); int events = 0; for (EventType eventType : eventTypes) { events |= getJcrEventType(eventType); } return events; }
/** * Returns true if this <code>Subscription</code> matches the given * resource. * * @param resource * @return true if this <code>Subscription</code> matches the given * resource. */ boolean isSubscribedToResource(ObservationResource resource) { return locator.getResourcePath().equals(resource.getResourcePath()); }
/** * Returns the Xml representation of the subscription discovery. * * @return Xml representation * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document) * @param document */ @Override public Element toXml(Document document) { Element elem = getName().toXml(document); for (Subscription subscription : subscriptions) { elem.appendChild(subscription.toXml(document)); } return elem; }
/** * Factory method to create an array of new <code>EventType</code> for the * specified localNames and the specified namespace. * * @param localNames * @param namespace * @return An array of event types. */ public static EventType[] create(String[] localNames, Namespace namespace) { EventType[] types = new EventType[localNames.length]; for (int i = 0; i < localNames.length; i++) { types[i] = create(localNames[i], namespace); } return types; }
/** * Returns the Xml representation of the subscription discovery. * * @return Xml representation * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document) * @param document */ @Override public Element toXml(Document document) { Element elem = getName().toXml(document); for (Subscription subscription : subscriptions) { elem.appendChild(subscription.toXml(document)); } return elem; }
/** * Factory method to create an array of new <code>EventType</code> for the * specified localNames and the specified namespace. * * @param localNames * @param namespace * @return An array of event types. */ public static EventType[] create(String[] localNames, Namespace namespace) { EventType[] types = new EventType[localNames.length]; for (int i = 0; i < localNames.length; i++) { types[i] = create(localNames[i], namespace); } return types; }