/** * 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()); } }
/** * @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); } }
/** * * @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; }
/** * 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(); }
public HttpLock(URI uri, LockInfo lockInfo) throws IOException { super(uri); TimeoutHeader th = new TimeoutHeader(lockInfo.getTimeout()); super.setHeader(th.getHeaderName(), th.getHeaderValue()); DepthHeader dh = new DepthHeader(lockInfo.isDeep()); super.setHeader(dh.getHeaderName(), dh.getHeaderValue()); super.setEntity(XmlEntity.create(lockInfo)); isRefresh = false; }
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 + "'.");
/** * Build the transaction object associated by the lock. * * @param locator * @param lockInfo * @return */ private Transaction createTransaction(DavResourceLocator locator, LockInfo lockInfo) { if (TransactionConstants.GLOBAL.equals(lockInfo.getScope())) { return new GlobalTransaction(locator, new TxActiveLock(lockInfo)); } else { return new LocalTransaction(locator, new TxActiveLock(lockInfo)); } }
/** * Reset the timeout of the lock identified by the given lock token. * * @param lockInfo * @param lockToken * @param resource * @return * @throws DavException if the lock did not exist or is expired. */ private synchronized ActiveLock refreshLock(LockInfo lockInfo, String lockToken, TransactionResource resource) throws DavException { TransactionMap responsibleMap = getMap(resource); Transaction tx = responsibleMap.get(lockToken); if (tx == null) { throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No valid transaction lock found for resource '" + resource.getResourcePath() + "'"); } else if (tx.getLock().isExpired()) { removeExpired(tx, responsibleMap, resource); throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "Transaction lock for resource '" + resource.getResourcePath() + "' was already expired."); } else { tx.getLock().setTimeout(lockInfo.getTimeout()); } return tx.getLock(); }
/** * @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; }
@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; }
public HttpLock(URI uri, LockInfo lockInfo) throws IOException { super(uri); TimeoutHeader th = new TimeoutHeader(lockInfo.getTimeout()); super.setHeader(th.getHeaderName(), th.getHeaderValue()); DepthHeader dh = new DepthHeader(lockInfo.isDeep()); super.setHeader(dh.getHeaderName(), dh.getHeaderValue()); super.setEntity(XmlEntity.create(lockInfo)); isRefresh = false; }
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 + "'.");
/** * 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()); } }
/** * * @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 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; }
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 + "'.");
/** * 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()); } }