/** * 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; }
/** * Return the Xml representation of this <code>Subscription</code> as required * for the {@link org.apache.jackrabbit.webdav.observation.SubscriptionDiscovery} * webdav property that in included in the response body of a successful SUBSCRIBE * request or as part of a PROPFIND response. * * @return Xml representation * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document) * @param document */ public Element toXml(Document document) { Element subscr = DomUtil.createElement(document, XML_SUBSCRIPTION, NAMESPACE); subscr.appendChild(info.toXml(document)); subscr.appendChild(DomUtil.depthToXml(info.isDeep(), document)); subscr.appendChild(DomUtil.timeoutToXml(info.getTimeOut(), document)); if (getSubscriptionId() != null) { Element id = DomUtil.addChildElement(subscr, XML_SUBSCRIPTIONID, NAMESPACE); id.appendChild(DomUtil.hrefToXml(getSubscriptionId(), document)); } DomUtil.addChildElement(subscr, XML_EVENTSWITHTYPES, NAMESPACE, Boolean.toString(eventsProvideNodeTypeInformation())); DomUtil.addChildElement(subscr, XML_EVENTSWITHLOCALFLAG, NAMESPACE, Boolean.toString(eventsProvideNoLocalFlag())); return subscr; }
public HttpSubscribe(URI uri, SubscriptionInfo info, String subscriptionId) throws IOException { super(uri); if (info == null) { throw new IllegalArgumentException("SubscriptionInfo must not be null."); } // optional subscriptionId (only required to modify an existing // subscription) if (subscriptionId != null) { CodedUrlHeader h = new CodedUrlHeader(ObservationConstants.HEADER_SUBSCRIPTIONID, subscriptionId); super.setHeader(h.getHeaderName(), h.getHeaderValue()); } // optional timeout header long to = info.getTimeOut(); if (to != DavConstants.UNDEFINED_TIMEOUT) { TimeoutHeader h = new TimeoutHeader(info.getTimeOut()); super.setHeader(h.getHeaderName(), h.getHeaderValue()); } // always set depth header since value is boolean flag DepthHeader dh = new DepthHeader(info.isDeep()); super.setHeader(dh.getHeaderName(), dh.getHeaderValue()); super.setEntity(XmlEntity.create(info)); }
public HttpSubscribe(URI uri, SubscriptionInfo info, String subscriptionId) throws IOException { super(uri); if (info == null) { throw new IllegalArgumentException("SubscriptionInfo must not be null."); } // optional subscriptionId (only required to modify an existing // subscription) if (subscriptionId != null) { CodedUrlHeader h = new CodedUrlHeader(ObservationConstants.HEADER_SUBSCRIPTIONID, subscriptionId); super.setHeader(h.getHeaderName(), h.getHeaderValue()); } // optional timeout header long to = info.getTimeOut(); if (to != DavConstants.UNDEFINED_TIMEOUT) { TimeoutHeader h = new TimeoutHeader(info.getTimeOut()); super.setHeader(h.getHeaderName(), h.getHeaderValue()); } // always set depth header since value is boolean flag DepthHeader dh = new DepthHeader(info.isDeep()); super.setHeader(dh.getHeaderName(), dh.getHeaderValue()); super.setEntity(XmlEntity.create(info)); }