Package javax.jcr.lock

Examples of javax.jcr.lock.Lock


      if (dataManager.hasPendingChanges(getInternalPath()))
      {
         throw new InvalidItemStateException("Node has pending unsaved changes " + getPath());
      }

      Lock newLock = session.getLockManager().addLock(this, isDeep, false, timeOut);

      PlainChangesLog changesLog = new PlainChangesLogImpl(new ArrayList<ItemState>(), session, ExtendedEvent.LOCK);

      PropertyData propData =
         TransientPropertyData.createPropertyData(nodeData(), Constants.JCR_LOCKOWNER, PropertyType.STRING, false,
View Full Code Here


        ActiveLock lock = null;
        if (exists() && Type.WRITE.equals(type) && Scope.EXCLUSIVE.equals(scope)) {
            // try to retrieve the repository lock information first
            try {
                if (node.isLocked()) {
                    Lock jcrLock = node.getLock();
                    if (jcrLock != null && jcrLock.isLive()) {
                        lock = new JcrActiveLock(jcrLock);
                    }
                }
            } catch (RepositoryException e) {
                // LockException (no lock applies) >> should never occur
View Full Code Here

        if (isLockable(lockInfo.getType(), lockInfo.getScope())) {
            // TODO: deal with existing locks, that may have been created, before the node was jcr-lockable...
            if (isJsrLockable()) {
                try {
                    // try to execute the lock operation
                    Lock jcrLock = node.lock(lockInfo.isDeep(), false);
                    if (jcrLock != null) {
                        lock = new JcrActiveLock(jcrLock);
                    }
                } catch (RepositoryException e) {
                    throw new JcrDavException(e);
View Full Code Here

        checkLockable();

        LockManager lockMgr = session.getLockManager();
        synchronized (lockMgr) {
            Lock lock = lockMgr.lock(this, isDeep, isSessionScoped);

            boolean succeeded = false;

            try {
                // add properties to content
View Full Code Here

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

        // lock node and get lock token
        Lock lock = n.lock(false, true);

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

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

        // remove lock token
        String lockToken = lock.getLockToken();
        superuser.removeLockToken(lockToken);

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

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

        // assert: session unable to modify node
        try {
            n.addNode(nodeName2, testNodeType);
            fail("session unable to modify node");
        } catch (LockException e) {
            // expected
        }

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

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

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

        // assert: session able to modify node
        n.addNode(nodeName2, testNodeType);
    }
View Full Code Here

        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
        n1.addMixin(mixLockable);
        testRootNode.save();

        // lock node
        Lock lock = n1.lock(false, true);

        // assert: isLive must return true
        assertTrue("Lock must be live", lock.isLive());

        // create new session
        Session otherSuperuser = helper.getSuperuserSession();

        try {
View Full Code Here

        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
        n1.addMixin(mixLockable);
        testRootNode.save();

        // lock node
        Lock lock = n1.lock(false, true);

        if (n1.getSession().getUserID() == null) {
            assertFalse("jcr:lockOwner must not exist if Session.getUserId() returns null",
                    n1.hasProperty(jcrLockOwner));
        } else {
            assertEquals("getLockOwner() must return the same value as stored " +
                    "in property " + jcrLockOwner + " of the lock holding " +
                    "node",
                    n1.getProperty(jcrLockOwner).getString(),
                    lock.getLockOwner());
        }
        n1.unlock();
    }
View Full Code Here

        Node n1 = testRootNode.addNode(nodeName1, testNodeType);
        n1.addMixin(mixLockable);
        testRootNode.save();

        // lock node
        Lock lock = n1.lock(false, true);

        assertEquals("getLockOwner() must return the same value as returned " +
                "by Session.getUserId at the time that the lock was placed",
                testRootNode.getSession().getUserID(),
                lock.getLockOwner());

        n1.unlock();
    }
View Full Code Here

        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
        n2.addMixin(mixLockable);
        testRootNode.save();

        // lock node 1 "undeeply"
        Lock lock1 = n1.lock(false, true);
        assertFalse("Lock.isDeep() must be false if the lock has not been set " +
                "as not deep",
                lock1.isDeep());

        // lock node 2 "deeply"
        Lock lock2 = n2.lock(true, true);
        assertTrue("Lock.isDeep() must be true if the lock has been set " +
                "as deep",
                lock2.isDeep());
    }
View Full Code Here

        Node n2 = testRootNode.addNode(nodeName2, testNodeType);
        n2.addMixin(mixLockable);
        testRootNode.save();

        // lock node 1 session-scoped
        Lock lock1 = n1.lock(false, true);
        assertTrue("Lock.isSessionScoped() must be true if the lock " +
                "is session-scoped",
                lock1.isSessionScoped());

        // lock node 2 open-scoped
        Lock lock2 = n2.lock(false, false);
        assertFalse("Lock.isSessionScoped() must be false if the lock " +
                "is open-scoped",
                lock2.isSessionScoped());

        n2.unlock();
    }
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.