Java LockInfo类使用实例

发布时间:2025-12-09 12:05:15 浏览次数:1

实例1: refreshLock

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;} 

实例2: testLockIfResourceUnlockable

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 );} 

实例3: testRefreshLockThrowsExceptionIfNoLockIsPresent

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 );} 

实例4: testUnlockThrowsDavExceptionIfNotLocked

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 );} 

实例5: refreshLock

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();}} 
lockinfo
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477