/** * {@inheritDoc} * * @throws DavException Thrown if this resource couldn't find a {@link org.apache.jackrabbit.webdav.lock.LockManager} to use to handle the lock operation. */ public ActiveLock lock(LockInfo lockInfo) throws DavException { if (null == lockManager) throw new DavException(HttpServletResponse.SC_PRECONDITION_FAILED, new StringBuffer("Unable to lock on ").append(getResourcePath()).append(" because LockManager is null.").toString()); else return lockManager.createLock(lockInfo, this); }
/** * {@inheritDoc} * * @throws NullPointerException Thrown if this resource couldn't find a {@link org.apache.jackrabbit.webdav.lock.LockManager} to use to handle the lock operation. */ public ActiveLock getLock(Type type, Scope scope) { if (null == lockManager) throw new NullPointerException(new StringBuffer("Unable to query for lock on ").append(getResourcePath()).append(" because LockManager is null.").toString()); else return lockManager.getLock(type, scope, this); }
/** * {@inheritDoc} * * @throws DavException Thrown if this resource couldn't find a {@link org.apache.jackrabbit.webdav.lock.LockManager} to use to handle the lock operation. */ public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException { if (null == lockManager) throw new DavException(HttpServletResponse.SC_PRECONDITION_FAILED, new StringBuffer("Unable to refresh lock on ").append(getResourcePath()).append(" because LockManager is null.").toString()); else return lockManager.refreshLock(lockInfo, lockToken, this); }
/** * {@inheritDoc} * * @throws DavException Thrown if this resource couldn't find a {@link org.apache.jackrabbit.webdav.lock.LockManager} to use to handle the lock operation. */ public void unlock(String lockToken) throws DavException { if (null == lockManager) throw new DavException(HttpServletResponse.SC_PRECONDITION_FAILED, new StringBuffer("Unable to release lock on ").append(getResourcePath()).append(" because LockManager is null.").toString()); else lockManager.releaseLock(lockToken, this); }
@Override public void unlock(String lockToken) throws DavException { ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE); if (lock != null && lock.isLockedByToken(lockToken)) { getContext().getLockManager().releaseLock(lockToken, this); } }
@Override public void unlock( String lockToken ) throws DavException { ActiveLock lock = getLock( Type.WRITE, Scope.EXCLUSIVE ); if ( lock == null ) { throw new DavException( HttpServletResponse.SC_PRECONDITION_FAILED ); } else if ( lock.isLockedByToken( lockToken ) ) { lockManager.releaseLock( lockToken, this ); } else { throw new DavException( DavServletResponse.SC_LOCKED ); } }
@Override public ActiveLock getLock(Type type, Scope scope) { return getContext().getLockManager().getLock(type, scope, this); }
@Override public ActiveLock lock( LockInfo lockInfo ) throws DavException { ActiveLock lock = null; if ( isLockable( lockInfo.getType(), lockInfo.getScope() ) ) { lock = lockManager.createLock( lockInfo, this ); } else { throw new DavException( DavServletResponse.SC_PRECONDITION_FAILED, "Unsupported lock type or scope." ); } return lock; }
@Override public ActiveLock refreshLock( LockInfo lockInfo, String lockToken ) throws DavException { if ( !exists() ) { throw new DavException( DavServletResponse.SC_NOT_FOUND ); } ActiveLock lock = getLock( lockInfo.getType(), lockInfo.getScope() ); if ( lock == null ) { throw new DavException( DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given type/scope present on resource " + getResourcePath() ); } lock = lockManager.refreshLock( lockInfo, lockToken, this ); return lock; }
/** * @see DavResource#unlock(String) */ public void unlock(String lockToken) throws DavException { ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE); if (lock == null) { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); } else if (lock.isLockedByToken(lockToken)) { if (lock instanceof JcrActiveLock) { try { node.unlock(); } catch (RepositoryException e) { throw new JcrDavException(e); } } else { lockManager.releaseLock(lockToken, this); } } else { throw new DavException(DavServletResponse.SC_LOCKED); } }
@Override public ActiveLock getLock( Type type, Scope scope ) { ActiveLock lock = null; if ( exists() && Type.WRITE.equals( type ) && Scope.EXCLUSIVE.equals( scope ) ) { lock = lockManager.getLock( type, scope, this ); } return lock; }
@Override public ActiveLock lock(LockInfo reqLockInfo) throws DavException { ActiveLock lock = null; if (isLockable(reqLockInfo.getType(), reqLockInfo.getScope())) { lock = getContext().getLockManager().createLock(reqLockInfo, this); } else { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); } return lock; }
@Override public ActiveLock refreshLock(LockInfo reqLockInfo, String lockToken) throws DavException { if (!exists()) { throw new DavException(DavServletResponse.SC_NOT_FOUND); } ActiveLock lock = getLock(reqLockInfo.getType(), reqLockInfo.getScope()); if (lock == null) { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); } return getContext().getLockManager().refreshLock(reqLockInfo, lockToken, this); }
/** * @see DavResource#removeMember(DavResource) */ public void removeMember(DavResource member) throws DavException { if (!exists() || !member.exists()) { throw new DavException(DavServletResponse.SC_NOT_FOUND); } if (isLocked(this) || isLocked(member)) { throw new DavException(DavServletResponse.SC_LOCKED); } // don't allow removal of nodes, that would be filtered out if (isFilteredResource(member)) { log.debug("Avoid removal of filtered resource: " + member.getDisplayName()); throw new DavException(DavServletResponse.SC_FORBIDDEN); } DeleteManager dm = config.getDeleteManager(); dm.delete(new DeleteContextImpl(getJcrSession()), member); // make sure, non-jcr locks are removed, once the removal is completed try { if (!isJcrLockable()) { ActiveLock lock = getLock(Type.WRITE, Scope.EXCLUSIVE); if (lock != null) { lockManager.releaseLock(lock.getToken(), member); } } } catch (DavException e) { // since check for 'locked' exception has been performed before // ignore any error here } }
/** * @see DavResource#getLock(Type, Scope) */ public ActiveLock getLock(Type type, Scope scope) { ActiveLock lock = null; if (exists() && Type.WRITE.equals(type) && Scope.EXCLUSIVE.equals(scope)) { // try to retrieve the repository lock information first try { if (node.isLocked()) { Lock jcrLock = node.getLock(); if (jcrLock != null && jcrLock.isLive()) { lock = new JcrActiveLock(jcrLock); String lockroot = locator .getFactory() .createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), jcrLock.getNode().getPath(), false).getHref(false); lock.setLockroot(lockroot); } } } catch (RepositoryException e) { // LockException (no lock applies) >> should never occur // RepositoryException, AccessDeniedException or another error >> ignore } // could not retrieve a jcr-lock. test if a simple webdav lock is present. if (lock == null) { lock = lockManager.getLock(type, scope, this); } } return lock; }
lock = lockManager.createLock(lockInfo, this);
/** * @see DavResource#refreshLock(LockInfo, String) */ public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException { if (!exists()) { throw new DavException(DavServletResponse.SC_NOT_FOUND); } ActiveLock lock = getLock(lockInfo.getType(), lockInfo.getScope()); if (lock == null) { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given type/scope present on resource " + getResourcePath()); } if (lock instanceof JcrActiveLock) { try { // refresh JCR lock and return the original lock object. node.getLock().refresh(); } catch (RepositoryException e) { throw new JcrDavException(e); } } else { lock = lockManager.refreshLock(lockInfo, lockToken, this); } /* since lock has infinite lock (simple) or undefined timeout (jcr) return the lock as retrieved from getLock. */ return lock; }