org.apache.jackrabbit.webdav.lock.Scope Java Examples
The following examples show how to use
org.apache.jackrabbit.webdav.lock.Scope.
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: DavResourceTest.java From archiva with Apache License 2.0 | 6 votes |
@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 #2
Source File: DavResourceTest.java From archiva with Apache License 2.0 | 6 votes |
@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 #3
Source File: DavResourceTest.java From archiva with Apache License 2.0 | 6 votes |
@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 #4
Source File: ArchivaDavResource.java From archiva with Apache License 2.0 | 6 votes |
@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 #5
Source File: DavResourceTest.java From archiva with Apache License 2.0 | 5 votes |
@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 #6
Source File: DavResourceTest.java From archiva with Apache License 2.0 | 5 votes |
@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 #7
Source File: VersionControlledResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * Fill the property set for this resource. * * @see DavResourceImpl#initProperties() */ protected void initProperties() { if (!propsInitialized) { super.initProperties(); properties.add(new HrefProperty(VERSION_HISTORY, locator.getResourcePath(), true)); // DAV:auto-version property: there is no auto version, explicit // EVENT_CHECKEDOUT is required. properties.add(new DefaultDavProperty(AUTO_VERSION, null, false)); if(resource==null) return; properties.add(new DefaultDavProperty(DavPropertyName.DISPLAYNAME, resource.getName(), false)); properties.add(new DefaultDavProperty(DavPropertyName.GETCONTENTTYPE, AbstractWebdavServlet.getContext().getMimeType(resource.getName()), false)); if (resource.isFolder()) return; SupportedLock supportedLock = new SupportedLock(); supportedLock.addEntry(Type.WRITE, Scope.EXCLUSIVE); properties.add(new DefaultDavProperty(DavPropertyName.SUPPORTEDLOCK, supportedLock, false)); String baseVHref = getLocatorFromResource(resource).getHref(false); if (resource.isCheckedOut() || resource.isLocked()) { log.debug("{} is checkedout", resource.getName()); properties.add(new HrefProperty(CHECKED_OUT, baseVHref, true)); properties.add(new HrefProperty(VersionResource.PREDECESSOR_SET, locator.getResourcePath(), false)); DefaultActiveLock activeLock = new DefaultActiveLock(); activeLock.setOwner(resource.getLockUser()); properties.add(new DefaultDavProperty(DavPropertyName.LOCKDISCOVERY, activeLock, false)); properties.add(new DefaultDavProperty("activelock", activeLock, Namespace.XMLNS_NAMESPACE)); } else { properties.add(new HrefProperty(CHECKED_IN, locator.getResourcePath(), true)); } } }
Example #8
Source File: ArchivaDavResource.java From archiva with Apache License 2.0 | 5 votes |
@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 #9
Source File: ArchivaDavResource.java From archiva with Apache License 2.0 | 4 votes |
@Override public boolean hasLock( Type type, Scope scope ) { return getLock( type, scope ) != null; }
Example #10
Source File: DavResourceTest.java From archiva with Apache License 2.0 | 4 votes |
@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 #11
Source File: DavResourceTest.java From archiva with Apache License 2.0 | 4 votes |
@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 #12
Source File: DavResourceTest.java From archiva with Apache License 2.0 | 4 votes |
@Test public void testIsLockable() { assertTrue( resource.isLockable( Type.WRITE, Scope.EXCLUSIVE ) ); assertFalse( resource.isLockable( Type.WRITE, Scope.SHARED ) ); }
Example #13
Source File: ArchivaDavResource.java From archiva with Apache License 2.0 | 4 votes |
@Override public ActiveLock[] getLocks() { ActiveLock writeLock = getLock( Type.WRITE, Scope.EXCLUSIVE ); return ( writeLock != null ) ? new ActiveLock[]{ writeLock } : new ActiveLock[0]; }
Example #14
Source File: ArchivaDavResource.java From archiva with Apache License 2.0 | 4 votes |
@Override public boolean isLockable( Type type, Scope scope ) { return Type.WRITE.equals( type ) && Scope.EXCLUSIVE.equals( scope ); }
Example #15
Source File: ArchivaVirtualDavResource.java From archiva with Apache License 2.0 | 4 votes |
@Override public boolean isLockable( Type arg0, Scope arg1 ) { return false; }
Example #16
Source File: ArchivaVirtualDavResource.java From archiva with Apache License 2.0 | 4 votes |
@Override public boolean hasLock( Type arg0, Scope arg1 ) { return false; }
Example #17
Source File: ArchivaVirtualDavResource.java From archiva with Apache License 2.0 | 4 votes |
@Override public ActiveLock getLock( Type arg0, Scope arg1 ) { return null; }
Example #18
Source File: DavResourceBase.java From cosmo with Apache License 2.0 | 4 votes |
public ActiveLock getLock(Type type, Scope scope) { // nothing is lockable at the moment throw new UnsupportedOperationException(); }
Example #19
Source File: DavResourceBase.java From cosmo with Apache License 2.0 | 4 votes |
public boolean hasLock(Type type, Scope scope) { // nothing is lockable at the moment throw new UnsupportedOperationException(); }
Example #20
Source File: DavResourceBase.java From cosmo with Apache License 2.0 | 4 votes |
public boolean isLockable(Type type, Scope scope) { // nothing is lockable at the moment return false; }
Example #21
Source File: DavResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 2 votes |
/** * @see DavResource#getLock(Type, Scope) * * @return the active lock */ public ActiveLock getLock(Type type, Scope scope) { return new DefaultActiveLock(); }
Example #22
Source File: DavResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 2 votes |
/** * @see DavResource#hasLock(org.apache.jackrabbit.webdav.lock.Type, * org.apache.jackrabbit.webdav.lock.Scope) * * @return if there is a lock */ public boolean hasLock(Type type, Scope scope) { return resource.isCheckedOut() == true; }
Example #23
Source File: DavResourceImpl.java From document-management-software with GNU Lesser General Public License v3.0 | 2 votes |
/** * Checks if a resource can be locked * * @param type the type * @param scope the scope * * @return true if type is {@link Type#WRITE} and scope is * {@link Scope#EXCLUSIVE} * @see DavResource#isLockable(org.apache.jackrabbit.webdav.lock.Type, * org.apache.jackrabbit.webdav.lock.Scope) */ public boolean isLockable(Type type, Scope scope) { return (resource.isCheckedOut() == false); }