发布时间:2025-12-09 12:05:15 浏览次数:1
import org.apache.jackrabbit.webdav.lock.LockInfo; //导入依赖的package包/类@Overridepublic 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;} import org.apache.jackrabbit.webdav.lock.LockInfo; //导入依赖的package包/类@Testpublic void testLockIfResourceUnlockable() throws Exception{ assertEquals( 0, resource.getLocks().length ); LockInfo info = new LockInfo( Scope.SHARED, Type.WRITE, "/", 0, false ); try { lockManager.createLock( info, resource ); fail( "Did not throw dav exception" ); } catch ( Exception e ) { // Simple lock manager will die } assertEquals( 0, resource.getLocks().length );} import org.apache.jackrabbit.webdav.lock.LockInfo; //导入依赖的package包/类@Testpublic void testRefreshLockThrowsExceptionIfNoLockIsPresent() throws Exception{ LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false ); assertEquals( 0, resource.getLocks().length ); try { lockManager.refreshLock( info, "notoken", resource ); fail( "Did not throw dav exception" ); } catch ( DavException e ) { assertEquals( DavServletResponse.SC_PRECONDITION_FAILED, e.getErrorCode() ); } assertEquals( 0, resource.getLocks().length );} import org.apache.jackrabbit.webdav.lock.LockInfo; //导入依赖的package包/类@Testpublic void testUnlockThrowsDavExceptionIfNotLocked() throws Exception{ LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false ); assertEquals( 0, resource.getLocks().length ); lockManager.createLock( info, resource ); assertEquals( 1, resource.getLocks().length ); try { lockManager.releaseLock( "BLAH", resource ); fail( "Did not throw DavException" ); } catch ( DavException e ) { assertEquals( DavServletResponse.SC_LOCKED, e.getErrorCode() ); } assertEquals( 1, resource.getLocks().length );} import org.apache.jackrabbit.webdav.lock.LockInfo; //导入依赖的package包/类public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException{if(lockable){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); /* since lock has infinite lock (simple) or undefined timeout (jcr) return the lock as retrieved from getLock. */ return lock;}else{throw new UnsupportedOperationException();}}