Package javax.jcr

Examples of javax.jcr.Node.lock()


        if (isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
            //A LockException is thrown if a lock prevents the addition of the subtree.
            Node lNode = testRootNode.addNode(nodeName1);
            lNode.addMixin(mixLockable);
            testRootNode.save();
            Lock lock = lNode.lock(true, true);
            session.removeLockToken(lock.getLockToken());   //remove the token, so the lock is for me, too
            FileInputStream in = new FileInputStream(file);
            try {
                doImport(lNode.getPath(), in, useWorkspace, useHandler);
            } catch (LockException e) {
View Full Code Here


        // access node through another session to lock it
        Session session2 = helper.getSuperuserSession();
        try {
            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
            node2.lock(true, true);

            // test fails if a LockException is thrown when removing the node
            // (remove must be possible since the parent is not locked)
            node.remove();
        } finally {
View Full Code Here

        String pathRelToRoot = node.getPath().substring(1);
        // access node through another session to lock it
        Session session2 = helper.getSuperuserSession();
        try {
            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
            node2.lock(true, true);

            try {
                subNode.remove();
                fail("Node.remove() must throw a LockException if the parent " +
                        "of the node is locked");
View Full Code Here

        // access node through another session to lock it
        Session session2 = helper.getSuperuserSession();
        try {
            Node node2 = session2.getRootNode().getNode(pathRelToRoot);
            node2.lock(true, true);

            try {
                node.removeMixin(mixinName);
                fail("Node.removeMixin(String mixinName) must throw a " +
                        "LockException if the node is locked.");
View Full Code Here

        testRootNode.save();
        EventResult result = new EventResult(log);
        addEventListener(result, Event.PROPERTY_ADDED);

        // now lock node. no save needed
        lockable.lock(false,true);

        removeEventListener(result);
        Event[] events = result.getEvents(DEFAULT_WAIT_TIMEOUT);

        assertEquals("Wrong number of events.", 2, events.length);
View Full Code Here

     */
    public void testRemoveLockFromNode() throws RepositoryException {
        Node lockable = createLockable(nodeName1, testNodeType);
        testRootNode.save();
        // lock the node
        lockable.lock(false, true);

        EventResult result = new EventResult(log);
        addEventListener(result, Event.PROPERTY_REMOVED);
        lockable.unlock();
        removeEventListener(result);
View Full Code Here

            } else {
                fail("Node " + nodeName1 + " is not lockable and does not allow to add mix:lockable");
            }
        }
        testRootNode.save();
        lockable.lock(false, true);

        Session readWrite = helper.getReadWriteSession();
        try {
            Query query = readWrite.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
            query.storeAsNode(testRoot + "/" + nodeName1 + "/" + nodeName2);
View Full Code Here

        // add mixin "lockable" to be able to lock the node
        ensureMixinType(lockTarget, mixLockable);
        lockTarget.getParent().save();

        // lock dst parent node using other session
        lockTarget.lock(true, true);

        try {
            workspaceW2.clone(workspace.getName(), node1.getPath(), dstAbsPath, true);
            fail("LockException was expected.");
        } catch (LockException e) {
View Full Code Here

        if (isSupported(Repository.OPTION_LOCKING_SUPPORTED)) {
            //A LockException is thrown if a lock prevents the addition of the subtree.
            Node lNode = testRootNode.addNode(nodeName1);
            ensureMixinType(lNode, mixLockable);
            testRootNode.save();
            Lock lock = lNode.lock(true, true);
            session.removeLockToken(lock.getLockToken());   //remove the token, so the lock is for me, too
            FileInputStream in = new FileInputStream(file);
            try {
                doImport(lNode.getPath(), in, useWorkspace, useHandler);
            } catch (LockException e) {
View Full Code Here

        // add mixin "lockable" to be able to lock the node
        ensureMixinType(lockTarget, mixLockable);
        lockTarget.getParent().save();

        // lock dst parent node using other session
        lockTarget.lock(true, true);

        try {
            workspaceW2.copy(workspace.getName(), node1.getPath(), dstAbsPath);
            fail("LockException was expected.");
        } catch (LockException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.