Search in sources :

Example 1 with HttpSubscribe

use of org.apache.jackrabbit.webdav.client.methods.HttpSubscribe in project jackrabbit by apache.

the class RepositoryServiceImpl method subscribe.

private String subscribe(String uri, SubscriptionInfo subscriptionInfo, String subscriptionId, SessionInfo sessionInfo, String batchId) throws RepositoryException {
    HttpSubscribe request = null;
    try {
        request = new HttpSubscribe(uri, subscriptionInfo, subscriptionId);
        initMethod(request, sessionInfo);
        if (batchId != null) {
            // add batchId as separate header
            CodedUrlHeader ch = new CodedUrlHeader(TransactionConstants.HEADER_TRANSACTIONID, batchId);
            request.setHeader(ch.getHeaderName(), ch.getHeaderValue());
        }
        HttpResponse response = executeRequest(sessionInfo, request);
        request.checkSuccess(response);
        org.apache.jackrabbit.webdav.observation.Subscription[] subs = request.getResponseBodyAsSubscriptionDiscovery(response).getValue();
        if (subs.length == 1) {
            this.remoteServerProvidesNodeTypes = subs[0].eventsProvideNodeTypeInformation();
            this.remoteServerProvidesNoLocalFlag = subs[0].eventsProvideNoLocalFlag();
        }
        return request.getSubscriptionId(response);
    } catch (IOException e) {
        throw new RepositoryException(e);
    } catch (DavException e) {
        throw ExceptionConverter.generate(e);
    } finally {
        if (request != null) {
            request.releaseConnection();
        }
    }
}
Also used : CodedUrlHeader(org.apache.jackrabbit.webdav.header.CodedUrlHeader) DavException(org.apache.jackrabbit.webdav.DavException) HttpResponse(org.apache.http.HttpResponse) RepositoryException(javax.jcr.RepositoryException) IOException(java.io.IOException) Subscription(org.apache.jackrabbit.spi.Subscription) HttpSubscribe(org.apache.jackrabbit.webdav.client.methods.HttpSubscribe)

Aggregations

IOException (java.io.IOException)1 RepositoryException (javax.jcr.RepositoryException)1 HttpResponse (org.apache.http.HttpResponse)1 Subscription (org.apache.jackrabbit.spi.Subscription)1 DavException (org.apache.jackrabbit.webdav.DavException)1 HttpSubscribe (org.apache.jackrabbit.webdav.client.methods.HttpSubscribe)1 CodedUrlHeader (org.apache.jackrabbit.webdav.header.CodedUrlHeader)1