use of org.apache.jackrabbit.webdav.header.CodedUrlHeader in project jackrabbit by apache.
the class AbstractWebdavServlet method doLock.
/**
* The LOCK method
*
* @param request
* @param response
* @param resource
* @throws IOException
* @throws DavException
*/
protected void doLock(WebdavRequest request, WebdavResponse response, DavResource resource) throws IOException, DavException {
LockInfo lockInfo = request.getLockInfo();
if (lockInfo.isRefreshLock()) {
// refresh any matching existing locks
ActiveLock[] activeLocks = resource.getLocks();
List<ActiveLock> lList = new ArrayList<ActiveLock>();
for (ActiveLock activeLock : activeLocks) {
// adjust lockinfo with type/scope retrieved from the lock.
lockInfo.setType(activeLock.getType());
lockInfo.setScope(activeLock.getScope());
DavProperty<?> etagProp = resource.getProperty(DavPropertyName.GETETAG);
String etag = etagProp != null ? String.valueOf(etagProp.getValue()) : "";
if (request.matchesIfHeader(resource.getHref(), activeLock.getToken(), etag)) {
lList.add(resource.refreshLock(lockInfo, activeLock.getToken()));
}
}
if (lList.isEmpty()) {
throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED);
}
ActiveLock[] refreshedLocks = lList.toArray(new ActiveLock[lList.size()]);
response.sendRefreshLockResponse(refreshedLocks);
} else {
int status = HttpServletResponse.SC_OK;
if (!resource.exists()) {
// lock-empty requires status code 201 (Created)
status = HttpServletResponse.SC_CREATED;
}
// create a new lock
ActiveLock lock = resource.lock(lockInfo);
CodedUrlHeader header = new CodedUrlHeader(DavConstants.HEADER_LOCK_TOKEN, lock.getToken());
response.setHeader(header.getHeaderName(), header.getHeaderValue());
DavPropertySet propSet = new DavPropertySet();
propSet.add(new LockDiscovery(lock));
response.sendXmlResponse(propSet, status);
}
}
use of org.apache.jackrabbit.webdav.header.CodedUrlHeader 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();
}
}
}
use of org.apache.jackrabbit.webdav.header.CodedUrlHeader in project jackrabbit by apache.
the class RepositoryServiceImpl method initMethod.
private static void initMethod(HttpUriRequest request, BatchImpl batchImpl, boolean addIfHeader) throws RepositoryException {
initMethod(request, batchImpl.sessionInfo, addIfHeader);
// add batchId as separate header, TODO: could probably re-use session id Link relation
CodedUrlHeader ch = new CodedUrlHeader(TransactionConstants.HEADER_TRANSACTIONID, batchImpl.batchId);
request.setHeader(ch.getHeaderName(), ch.getHeaderValue());
}
use of org.apache.jackrabbit.webdav.header.CodedUrlHeader in project jackrabbit by apache.
the class WebdavResponseImpl method sendSubscriptionResponse.
// ----------------------------< ObservationDavServletResponse Interface >---
/**
* @param subscription
* @throws IOException
* @see org.apache.jackrabbit.webdav.observation.ObservationDavServletResponse#sendSubscriptionResponse(org.apache.jackrabbit.webdav.observation.Subscription)
*/
public void sendSubscriptionResponse(Subscription subscription) throws IOException {
String id = subscription.getSubscriptionId();
if (id != null) {
Header h = new CodedUrlHeader(ObservationConstants.HEADER_SUBSCRIPTIONID, id);
httpResponse.setHeader(h.getHeaderName(), h.getHeaderValue());
}
DavPropertySet propSet = new DavPropertySet();
propSet.add(new SubscriptionDiscovery(subscription));
sendXmlResponse(propSet, SC_OK);
}
Aggregations