/** * @see DavResource#lock(org.apache.jackrabbit.webdav.lock.LockInfo) */ @Override public ActiveLock lock(LockInfo reqLockInfo) throws DavException { if (isLockable(reqLockInfo.getType(), reqLockInfo.getScope())) { return txMgr.createLock(reqLockInfo, this); } else { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); } }
@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; }
/** * Create a new lock * * @param lockInfo * @throws IllegalArgumentException if either scope or type is invalid. */ public DefaultActiveLock(LockInfo lockInfo) { if (lockInfo != null) { if (!(Type.WRITE.equals(lockInfo.getType()) && Scope.EXCLUSIVE.equals(lockInfo.getScope()))) { throw new IllegalArgumentException("Only 'exclusive write' lock is allowed scope/type pair."); } owner = lockInfo.getOwner(); isDeep = lockInfo.isDeep(); setTimeout(lockInfo.getTimeout()); } }
/** * Create a new lock * * @param lockInfo * @throws IllegalArgumentException if either scope or type is invalid. */ public DefaultActiveLock(LockInfo lockInfo) { if (lockInfo != null) { if (!(Type.WRITE.equals(lockInfo.getType()) && Scope.EXCLUSIVE.equals(lockInfo.getScope()))) { throw new IllegalArgumentException("Only 'exclusive write' lock is allowed scope/type pair."); } owner = lockInfo.getOwner(); isDeep = lockInfo.isDeep(); setTimeout(lockInfo.getTimeout()); } }
/** * Create a new lock * * @param lockInfo lock info * @throws IllegalArgumentException if either scope or type is invalid. */ public SerializableActiveLock(LockInfo lockInfo) { if (lockInfo != null) { if (!(Type.WRITE.equals(lockInfo.getType()) && Scope.EXCLUSIVE.equals(lockInfo.getScope()))) { throw new IllegalArgumentException("Only 'exclusive write' lock is allowed scope/type pair."); } owner = lockInfo.getOwner(); isDeep = lockInfo.isDeep(); setTimeout(lockInfo.getTimeout()); } }
/** * Create a new lock * * @param lockInfo * @throws IllegalArgumentException if either scope or type is invalid. */ public DefaultActiveLock(LockInfo lockInfo) { if (lockInfo != null) { if (!(Type.WRITE.equals(lockInfo.getType()) && Scope.EXCLUSIVE.equals(lockInfo.getScope()))) { throw new IllegalArgumentException("Only 'exclusive write' lock is allowed scope/type pair."); } owner = lockInfo.getOwner(); isDeep = lockInfo.isDeep(); setTimeout(lockInfo.getTimeout()); } }
@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; }
/** * @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; }
/** * * @param lockInfo * @param lockToken * @param resource * @return * @throws DavException * @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; }
/** * * @param lockInfo * @param lockToken * @param resource * @return * @throws DavException * @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; }
/** * * @param lockInfo * @param lockToken * @param resource * @return * @throws DavException * @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; }
@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); }
/** * Create a new transaction lock.<br> * If the lockInfo element is <code>null</code> the timeout defaults to * half and hour. The default scope is 'local'. * * @param lockInfo * @throws IllegalArgumentException if either scope or type is invalid or if * a depth other than infinity is requested. */ public TxActiveLock(LockInfo lockInfo) { if (lockInfo != null) { if (!TRANSACTION.equals(lockInfo.getType())) { throw new IllegalArgumentException("Only 'transaction' type is allowed for a transaction-activelock object."); } if (!(LOCAL.equals(lockInfo.getScope()) || GLOBAL.equals(lockInfo.getScope()))) { throw new IllegalArgumentException("Only 'global' or 'local' are valid scopes within a transaction-activelock element."); } if (!lockInfo.isDeep()) { throw new IllegalArgumentException("Only transaction locks can only be deep."); } setOwner(lockInfo.getOwner()); setTimeout(lockInfo.getTimeout()); scope = lockInfo.getScope(); } else { setTimeout(DEFAULT_TIMEOUT); // local scope by default scope = LOCAL; } }
/** * Create a new transaction lock.<br> * If the lockInfo element is <code>null</code> the timeout defaults to * half and hour. The default scope is 'local'. * * @param lockInfo * @throws IllegalArgumentException if either scope or type is invalid or if * a depth other than infinity is requested. */ public TxActiveLock(LockInfo lockInfo) { if (lockInfo != null) { if (!TRANSACTION.equals(lockInfo.getType())) { throw new IllegalArgumentException("Only 'transaction' type is allowed for a transaction-activelock object."); } if (!(LOCAL.equals(lockInfo.getScope()) || GLOBAL.equals(lockInfo.getScope()))) { throw new IllegalArgumentException("Only 'global' or 'local' are valid scopes within a transaction-activelock element."); } if (!lockInfo.isDeep()) { throw new IllegalArgumentException("Only transaction locks can only be deep."); } setOwner(lockInfo.getOwner()); setTimeout(lockInfo.getTimeout()); scope = lockInfo.getScope(); } else { setTimeout(DEFAULT_TIMEOUT); // local scope by default scope = LOCAL; } }
@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; }
/** * Create a new transaction lock.<br> * If the lockInfo element is <code>null</code> the timeout defaults to * half and hour. The default scope is 'local'. * * @param lockInfo * @throws IllegalArgumentException if either scope or type is invalid or if * a depth other than infinity is requested. */ public TxActiveLock(LockInfo lockInfo) { if (lockInfo != null) { if (!TRANSACTION.equals(lockInfo.getType())) { throw new IllegalArgumentException("Only 'transaction' type is allowed for a transaction-activelock object."); } if (!(LOCAL.equals(lockInfo.getScope()) || GLOBAL.equals(lockInfo.getScope()))) { throw new IllegalArgumentException("Only 'global' or 'local' are valid scopes within a transaction-activelock element."); } if (!lockInfo.isDeep()) { throw new IllegalArgumentException("Only transaction locks can only be deep."); } setOwner(lockInfo.getOwner()); setTimeout(lockInfo.getTimeout()); scope = lockInfo.getScope(); } else { setTimeout(DEFAULT_TIMEOUT); // local scope by default scope = LOCAL; } }
if (isLockable(lockInfo.getType(), lockInfo.getScope())) {
/** * Create a new lock. * * @param lockInfo * @param resource * @return the lock * @throws DavException if the request lock has the wrong lock type or if * the lock could not be obtained for any reason. */ private synchronized ActiveLock createLock(LockInfo lockInfo, TransactionResource resource) throws DavException { if (!lockInfo.isDeep() || !TransactionConstants.TRANSACTION.equals(lockInfo.getType())) { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED); } ActiveLock existing = getLock(lockInfo.getType(), lockInfo.getScope(), resource); if (existing != null) { throw new DavException(DavServletResponse.SC_LOCKED); } // TODO: check for locks on member resources is required as well for lock is always deep! Transaction tx = createTransaction(resource.getLocator(), lockInfo); tx.start(resource); // keep references to this lock addReferences(tx, getMap(resource), resource); return tx.getLock(); }
/** * @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; }
ActiveLock lock = getLock(reqLockInfo.getType(), reqLockInfo.getScope()); if (lock == null) { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given scope/type present on this resource.");