public ConfluenceDavSession(String userName) { this.userName = userName; resourceStates = new ResourceStates(); lockTokens = new HashSet<String>(); lockManager = new SerializableLockManager(); updateActivityTimestamp(); }
/** * Recursivly tries to find the lock * * @param path * @return */ private ActiveLock getLock(String path) { ActiveLock lock = (ActiveLock) locks.get(path); if (lock != null) { // check if not expired if (lock.isExpired()) { lock = null; } } if (lock == null) { // check, if child of deep locked parent if (!path.equals("/")) { ActiveLock parentLock = getLock(Text.getRelativeParent(path, 1)); if (parentLock != null && parentLock.isDeep()) { lock = parentLock; } } } return lock; }
if (lockInfo.isDeep() || isInternalMember(resource, key)) { throw new DavException(DavServletResponse.SC_CONFLICT, "Resource '" + resource.getResourcePath() + "' cannot be locked due to a lock present on the member resource '" + key + "'.");
/** * Returns the lock applying to the given resource or <code>null</code> if * no lock can be found. * * @param type type * @param scope scope * @param resource resource * @return lock that applies to the given resource or <code>null</code>. */ public synchronized ActiveLock getLock(Type type, Scope scope, DavResource resource) { if (!(Type.WRITE.equals(type) && Scope.EXCLUSIVE.equals(scope))) { return null; } return getLock(resource.getResourcePath()); }
/** * @param lockInfo lock info * @param lockToken lock token * @param resource resource * @return lock * @throws DavException ex * @see DavResource#refreshLock(org.apache.jackrabbit.webdav.lock.LockInfo, String) */ public ActiveLock refreshLock(LockInfo lockInfo, String lockToken, DavResource resource) throws DavException { ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope(), resource); if (lock == null) { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); } else if (!lock.getToken().equals(lockToken)) { throw new DavException(DavServletResponse.SC_LOCKED); } lock.setTimeout(lockInfo.getTimeout()); return lock; }