use of org.apache.jackrabbit.webdav.lock.LockDiscovery in project jackrabbit by apache.
the class RepositoryServiceImpl method lock.
@Override
public LockInfo lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep, boolean sessionScoped, long timeoutHint, String ownerHint) throws RepositoryException {
HttpLock request = null;
try {
checkSessionInfo(sessionInfo);
long davTimeout = (timeoutHint == Long.MAX_VALUE) ? INFINITE_TIMEOUT : timeoutHint * 1000;
String ownerInfo = (ownerHint == null) ? sessionInfo.getUserID() : ownerHint;
String uri = getItemUri(nodeId, sessionInfo);
Scope scope = (sessionScoped) ? ItemResourceConstants.EXCLUSIVE_SESSION : Scope.EXCLUSIVE;
request = new HttpLock(uri, new org.apache.jackrabbit.webdav.lock.LockInfo(scope, Type.WRITE, ownerInfo, davTimeout, deep));
HttpResponse response = execute(request, sessionInfo);
String lockToken = request.getLockToken(response);
((SessionInfoImpl) sessionInfo).addLockToken(lockToken, sessionScoped);
LockDiscovery disc = request.getResponseBodyAsLockDiscovery(response);
return retrieveLockInfo(disc, sessionInfo, nodeId, null);
} catch (IOException e) {
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (request != null) {
request.releaseConnection();
}
}
}
Aggregations