org.apache.jackrabbit.webdav.lock.LockInfo Java Examples

The following examples show how to use org.apache.jackrabbit.webdav.lock.LockInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArchivaDavResource.java    From archiva with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: DavResourceTest.java    From archiva with Apache License 2.0 6 votes vote down vote up
@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 );
}
 
Example #3
Source File: DavResourceTest.java    From archiva with Apache License 2.0 6 votes vote down vote up
@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 );
}
 
Example #4
Source File: DavResourceTest.java    From archiva with Apache License 2.0 6 votes vote down vote up
@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 );
}
 
Example #5
Source File: DavResourceTest.java    From archiva with Apache License 2.0 5 votes vote down vote up
@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 );
}
 
Example #6
Source File: DavResourceTest.java    From archiva with Apache License 2.0 5 votes vote down vote up
@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 ) );
}
 
Example #7
Source File: DavResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @see DavResource#refreshLock(LockInfo, String)
 */
public ActiveLock refreshLock(LockInfo lockInfo, String lockToken) throws DavException {
	return new DefaultActiveLock();
}
 
Example #8
Source File: DavResourceBase.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public ActiveLock lock(LockInfo reqLockInfo) throws DavException {
    // nothing is lockable at the moment
    throw new PreconditionFailedException("Resource not lockable");
}
 
Example #9
Source File: DavResourceBase.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public ActiveLock refreshLock(LockInfo reqLockInfo, String lockToken) throws DavException {
    // nothing is lockable at the moment
    throw new PreconditionFailedException("Resource not lockable");
}
 
Example #10
Source File: ArchivaVirtualDavResource.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveLock lock( LockInfo arg0 )
    throws DavException
{
    return null;
}
 
Example #11
Source File: ArchivaVirtualDavResource.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveLock refreshLock( LockInfo arg0, String arg1 )
    throws DavException
{
    return null;
}
 
Example #12
Source File: DavResourceTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@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 );
}
 
Example #13
Source File: DavResourceTest.java    From archiva with Apache License 2.0 4 votes vote down vote up
@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 );
}
 
Example #14
Source File: DavResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * @see DavResource#lock(LockInfo)
 * 
 * @return the active lock
 */
public ActiveLock lock(LockInfo lockInfo) throws DavException {
	throw new UnsupportedOperationException();
}