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

The following examples show how to use org.apache.jackrabbit.webdav.lock.ActiveLock. 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 void unlock( String lockToken )
    throws DavException
{
    ActiveLock lock = getLock( Type.WRITE, Scope.EXCLUSIVE );
    if ( lock == null )
    {
        throw new DavException( HttpServletResponse.SC_PRECONDITION_FAILED );
    }
    else if ( lock.isLockedByToken( lockToken ) )
    {
        lockManager.releaseLock( lockToken, this );
    }
    else
    {
        throw new DavException( DavServletResponse.SC_LOCKED );
    }
}
 
Example #2
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 #3
Source File: ArchivaDavResource.java    From archiva with Apache License 2.0 5 votes vote down vote up
@Override
public ActiveLock getLock( Type type, Scope scope )
{
    ActiveLock lock = null;
    if ( exists() && Type.WRITE.equals( type ) && Scope.EXCLUSIVE.equals( scope ) )
    {
        lock = lockManager.getLock( type, scope, this );
    }
    return lock;
}
 
Example #4
Source File: ArchivaVirtualDavResource.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveLock[] getLocks()
{
    return null;
}
 
Example #5
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 #6
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 #7
Source File: ArchivaDavResource.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveLock[] getLocks()
{
    ActiveLock writeLock = getLock( Type.WRITE, Scope.EXCLUSIVE );
    return ( writeLock != null ) ? new ActiveLock[]{ writeLock } : new ActiveLock[0];
}
 
Example #8
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 #9
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 #10
Source File: ArchivaVirtualDavResource.java    From archiva with Apache License 2.0 4 votes vote down vote up
@Override
public ActiveLock getLock( Type arg0, Scope arg1 )
{
    return null;
}
 
Example #11
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 #12
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 #13
Source File: DavResourceBase.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public ActiveLock[] getLocks() {
    // nothing is lockable at the moment
    throw new UnsupportedOperationException();
}
 
Example #14
Source File: DavResourceBase.java    From cosmo with Apache License 2.0 4 votes vote down vote up
public ActiveLock getLock(Type type, Scope scope) {
    // nothing is lockable at the moment
    throw new UnsupportedOperationException();
}
 
Example #15
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 #16
Source File: DavResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * @see DavResource#getLock(Type, Scope)
 * 
 * @return the active lock
 */
public ActiveLock getLock(Type type, Scope scope) {
	return new DefaultActiveLock();
}
 
Example #17
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();
}
 
Example #18
Source File: DavResourceImpl.java    From document-management-software with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * @see org.apache.jackrabbit.webdav.DavResource#getLocks()
 * 
 * @return the active locks
 */
public ActiveLock[] getLocks() {
	return new ActiveLock[] {};
}