Java源码示例:org.apache.jackrabbit.webdav.lock.LockInfo
示例1
@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;
}
示例2
@Test
public 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
@Test
public 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
@Test
public 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
@Test
public void testLock()
throws Exception
{
assertEquals( 0, resource.getLocks().length );
LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false );
lockManager.createLock( info, resource );
assertEquals( 1, resource.getLocks().length );
}
示例6
@Test
public void testGetLock()
throws Exception
{
LockInfo info = new LockInfo( Scope.EXCLUSIVE, Type.WRITE, "/", 0, false );
lockManager.createLock( info, resource );
assertEquals( 1, resource.getLocks().length );
// Lock should exist
assertNotNull( resource.getLock( Type.WRITE, Scope.EXCLUSIVE ) );
// Lock should not exist
assertNull( resource.getLock( Type.WRITE, Scope.SHARED ) );
}
示例7
/**
* @see DavResource#refreshLock(LockInfo, String)
*/
public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException {
return new DefaultActiveLock();
}
示例8
public ActiveLock lock(LockInfo reqLockInfo) throws DavException {
// nothing is lockable at the moment
throw new PreconditionFailedException("Resource not lockable");
}
示例9
public ActiveLock refreshLock(LockInfo reqLockInfo, String lockToken) throws DavException {
// nothing is lockable at the moment
throw new PreconditionFailedException("Resource not lockable");
}
示例10
@Override
public ActiveLock lock( LockInfo arg0 )
throws DavException
{
return null;
}
示例11
@Override
public ActiveLock refreshLock( LockInfo arg0, String arg1 )
throws DavException
{
return null;
}
示例12
@Test
public void testRefreshLock()
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 );
ActiveLock lock = resource.getLocks()[0];
lockManager.refreshLock( info, lock.getToken(), resource );
assertEquals( 1, resource.getLocks().length );
}
示例13
@Test
public void testUnlock()
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 );
ActiveLock lock = resource.getLocks()[0];
lockManager.releaseLock( lock.getToken(), resource );
assertEquals( 0, resource.getLocks().length );
}
示例14
/**
* @see DavResource#lock(LockInfo)
*
* @return the active lock
*/
public ActiveLock lock(LockInfo lockInfo) throws DavException {
throw new UnsupportedOperationException();
}