protected void processNewLock( HttpManager milton, Request request, Response response, LockableResource r, LockTimeout timeout) throws NotAuthorizedException { LockInfo lockInfo; try { lockInfo = LockInfoSaxHandler.parseLockInfo(request); } catch (SAXException ex) { throw new RuntimeException("Exception reading request body", ex); } catch (IOException ex) { throw new RuntimeException("Exception reading request body", ex); } if (handlerHelper.isLockedOut(request, r)) { this.responseHandler.respondLocked(request, response, r); return; } log.debug("locking: " + r.getName()); LockResult result; try { result = r.lock(timeout, lockInfo); } catch (PreConditionFailedException ex) { responseHandler.respondPreconditionFailed(request, response, r); return; } catch (LockedException ex) { responseHandler.respondLocked(request, response, r); return; } if (result.isSuccessful()) { LockToken tok = result.getLockToken(); log.debug("..locked ok: " + tok.tokenId); response.setLockTokenHeader( "<opaquelocktoken:" + tok.tokenId + ">"); // spec says to set response header. See 8.10.1 respondWithToken(tok, request, response); } else { respondWithLockFailure(result, request, response); } }
protected void processRefresh( HttpManager milton, Request request, Response response, LockableResource r, LockTimeout timeout, String ifHeader) throws NotAuthorizedException { String token = parseToken(ifHeader); log.debug("refreshing lock: " + token); LockResult result; try { result = r.refreshLock(token); } catch (PreConditionFailedException ex) { responseHandler.respondPreconditionFailed(request, response, r); return; } if (result.isSuccessful()) { LockToken tok = result.getLockToken(); respondWithToken(tok, request, response); } else { respondWithLockFailure(result, request, response); } }