}
private String subscribe(String uri, SubscriptionInfo subscriptionInfo,
String subscriptionId, SessionInfo sessionInfo,
String batchId) throws RepositoryException {
SubscribeMethod method = null;
try {
if (subscriptionId != null) {
method = new SubscribeMethod(uri, subscriptionInfo, subscriptionId);
} else {
method = new SubscribeMethod(uri, subscriptionInfo);
}
initMethod(method, sessionInfo);
if (batchId != null) {
// add batchId as separate header
CodedUrlHeader ch = new CodedUrlHeader(TransactionConstants.HEADER_TRANSACTIONID, batchId);
method.setRequestHeader(ch.getHeaderName(), ch.getHeaderValue());
}
getClient(sessionInfo).executeMethod(method);
method.checkSuccess();
org.apache.jackrabbit.webdav.observation.Subscription[] subs = method.getResponseAsSubscriptionDiscovery().getValue();
if (subs.length == 1) {
this.remoteServerProvidesNodeTypes = subs[0].eventsProvideNodeTypeInformation();
this.remoteServerProvidesNoLocalFlag = subs[0].eventsProvideNoLocalFlag();
}
return method.getSubscriptionId();
} catch (IOException e) {
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (method != null) {
method.releaseConnection();
}
}
}