Package javax.jcr.lock

Examples of javax.jcr.lock.Lock


            throw new DavException(DavServletResponse.SC_PRECONDITION_FAILED, "No lock with the given scope/type present on this resource.");
        }

        if (Type.WRITE.equals(lock.getType())) {
            try {
                Lock jcrLock = ((Node) item).getLock();
                jcrLock.refresh();
                return new JcrActiveLock(jcrLock);
            } catch (RepositoryException e) {
                /*
                  NOTE: LockException is only thrown by Lock.refresh()
                        the lock exception thrown by Node.getLock() was circumvented
View Full Code Here


        assertTrue("Session must be lock owner", lockedNode.getLock().isLockOwningSession());
        assertTrue("Session must be lock owner", lockMgr.getLock(lockedNode.getPath()).isLockOwningSession());

        Session otherSession = getHelper().getReadOnlySession();
        try {
            Lock lck = otherSession.getNode(lockedNode.getPath()).getLock();
            assertFalse("Session must not be lock owner", lck.isLockOwningSession());

            Lock lck2 = getLockManager(otherSession).getLock(lockedNode.getPath());
            assertFalse("Session must not be lock owner", lck2.isLockOwningSession());
        } finally {
            otherSession.logout();
        }

        Session otherAdmin = getHelper().getSuperuserSession();
        try {
            Lock lck = otherAdmin.getNode(lockedNode.getPath()).getLock();
            assertFalse("Other Session for the same userID must not be lock owner", lck.isLockOwningSession());

            Lock lck2 = getLockManager(otherAdmin).getLock(lockedNode.getPath());
            assertFalse("Other Session for the same userID must not be lock owner", lck2.isLockOwningSession());

        } finally {
            otherAdmin.logout();
        }
    }
View Full Code Here

    }

    public void testGetLockOnChild() throws RepositoryException {
        if (isDeep()) {
            // get lock must succeed even if child is not lockable.
            Lock lock = childNode.getLock();
            assertNotNull(lock);
            assertTrue("Lock.getNode() must return the lock holding node", lockedNode.isSame(lock.getNode()));

            Lock lock2 = lockMgr.getLock(childNode.getPath());
            assertNotNull(lock2);
            assertTrue("Lock.getNode() must return the lock holding node", lockedNode.isSame(lock2.getNode()));
        } else {
            try {
                childNode.getLock();
                fail("Node.getLock() must throw if node is not locked.");
            } catch (LockException e) {
View Full Code Here

    public void testGetLockOnNewChild() throws RepositoryException {
        Node newChild = lockedNode.addNode(nodeName3, testNodeType);
        if (isDeep()) {
            // get lock must succeed even if child is not lockable.
            Lock lock = newChild.getLock();
            assertNotNull(lock);
            assertTrue("Lock.getNode() must return the lock holding node", lockedNode.isSame(lock.getNode()));

            Lock lock2 = lockMgr.getLock(newChild.getPath());
            assertNotNull(lock2);
            assertTrue("Lock.getNode() must return the lock holding node", lockedNode.isSame(lock2.getNode()));
        } else {
            try {
                newChild.getLock();
                fail("Node.getLock() must throw if node is not locked.");
            } catch (LockException e) {
View Full Code Here

        utx = new UserTransactionImpl(superuser);
        utx.begin();
       
        n = superuser.getNodeByUUID(uuid);
        // lock this new node
        Lock lock = n.lock(true, false);
       
        // verify node is locked
        assertTrue("Node not locked", n.isLocked());
       
        String lockToken = lock.getLockToken();
        // assert: session must get a non-null lock token
        assertNotNull("session must get a non-null lock token", lockToken);
        // assert: session must hold lock token
        assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));

        n.save();

        superuser.removeLockToken(lockToken);
        assertNull("session must get a null lock token", lock.getLockToken());
        assertFalse("session must not hold lock token", containsLockToken(superuser, lockToken));
       
        // commit
        utx.commit();

        assertFalse("session must not hold lock token", containsLockToken(superuser, lockToken));
        assertNull("session must get a null lock token", lock.getLockToken());

        // start new Transaction and try to unlock
        utx = new UserTransactionImpl(superuser);
        utx.begin();
View Full Code Here

        rootNode.save();

        String uuid = n.getUUID();

        // lock this new node
        Lock lock = n.lock(true, false);
        String lockToken = lock.getLockToken();

        // assert: session must get a non-null lock token
        assertNotNull("session must get a non-null lock token", lockToken);

        // assert: session must hold lock token
        assertTrue("session must hold lock token", containsLockToken(superuser, lockToken));

        superuser.removeLockToken(lockToken);
        assertNull("session must get a null lock token", lock.getLockToken());

        // commit
        utx.commit();

        // refresh Lock Info
        lock = n.getLock();

        assertNull("session must get a null lock token", lock.getLockToken());

        Session other = getHelper().getSuperuserSession();
        try {
            // start new Transaction and try to add lock token
            utx = new UserTransactionImpl(other);
            utx.begin();

            Node otherNode = other.getNodeByUUID(uuid);
            assertTrue("Node not locked", otherNode.isLocked());
            try {
                otherNode.setProperty(propertyName1, "foo");
                fail("Lock exception should be thrown");
            } catch (LockException e) {
                // expected
            }

            // add lock token
            other.addLockToken(lockToken);

            // refresh Lock Info
            lock = otherNode.getLock();

            // assert: session must hold lock token
            assertTrue("session must hold lock token", containsLockToken(other, lock.getLockToken()));

            otherNode.unlock();

            assertFalse("Node is locked", otherNode.isLocked());
View Full Code Here

        testRootNode.save();

        // get user transaction object, start and lock node
        UserTransaction utx = new UserTransactionImpl(superuser);
        utx.begin();
        Lock lock = n.lock(false, true);

        // verify lock is live
        assertTrue("Lock live", lock.isLive());

        // rollback
        utx.rollback();

        // verify lock is not live anymore
        assertFalse("Lock not live", lock.isLive());
    }
View Full Code Here

        Node n = testRootNode.addNode(nodeName1);
        n.addMixin(mixLockable);
        n.addMixin(mixReferenceable);
        testRootNode.save();

        Lock lock = n.lock(false, true);

        // get user transaction object, start
        UserTransaction utx = new UserTransactionImpl(superuser);
        utx.begin();

        // verify lock is live
        assertTrue("Lock live", lock.isLive());

        // unlock
        n.unlock();

        // verify lock is no longer live
        assertFalse("Lock not live", lock.isLive());

        // rollback
        utx.rollback();

        // verify lock is live again
        assertTrue("Lock live", lock.isLive());
    }
View Full Code Here

        testRootNode.save();

        // get user transaction object, start and lock node
        UserTransaction utx = new UserTransactionImpl(superuser);
        utx.begin();
        Lock lock = n.lock(false, true);

        // verify that the lock properties have been created and are neither
        // NEW nor MODIFIED.
        assertTrue(n.hasProperty(jcrLockOwner));
        Property lockOwner = n.getProperty(jcrLockOwner);
View Full Code Here

        Node n = testRootNode.addNode(nodeName1);
        n.addMixin(mixLockable);
        n.addMixin(mixReferenceable);
        testRootNode.save();

        Lock lock = n.lock(false, true);
        try {
            // get user transaction object, start
            UserTransaction utx = new UserTransactionImpl(superuser);
            utx.begin();
View Full Code Here

TOP

Related Classes of javax.jcr.lock.Lock

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.