Package javax.jcr.version

Examples of javax.jcr.version.Version


    }

    public void testRestoreChild1() throws RepositoryException {
        versionableNode.addNode("child1");
        versionableNode.save();
        Version v1 = versionableNode.checkin();
        versionableNode.checkout();
        Version v2 = versionableNode.checkin();

        versionableNode.restore(v1, true);
        assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));

        versionableNode.restore(version, true);
View Full Code Here


        if (!child1.isNodeType(mixVersionable)) {
            child1.addMixin(mixVersionable);
        }
        versionableNode.save();
        // create v1.0 of child
        Version v1Child = child1.checkin();

        // V1 of versionable node has child1
        Version v1 = versionableNode.checkin();
        String v1Name = v1.getName();

        // mark V1 with label test and foo
        versionableNode.getVersionHistory().addVersionLabel(v1Name, "test", true);
        versionableNode.getVersionHistory().addVersionLabel(v1Name, "foo", true);

        // create V1.1 of child
        child1.checkout();
        Version v11Child = child1.checkin();
        child1.getVersionHistory().addVersionLabel(v11Child.getName(), "foo", true);

        // restore 1.0 of versionable node --> no child
        versionableNode.restore(version, true);
        assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode(nodeName4));

        // restore V1 via label. since child has no label, initial version should
        // be restored
        versionableNode.restoreByLabel("test", true);
        assertTrue("Node.restore('test') must restore child node.", versionableNode.hasNode(nodeName4));
        child1 = versionableNode.getNode(nodeName4);
        assertEquals("Node.restore('test') must restore child node version 1.0.", v1Child.getName(), child1.getBaseVersion().getName());

        // restore V1 via label 'foo'. since child has foo, 1.1 version should
        // be restored
        versionableNode.restoreByLabel("foo", true);
        child1 = versionableNode.getNode(nodeName4);
        assertEquals("Node.restore('foo') must restore child node version 1.1.", v11Child.getName(), child1.getBaseVersion().getName());
    }
View Full Code Here

        if (!child1.isNodeType(mixVersionable)) {
            child1.addMixin(mixVersionable);
        }
        versionableNode.save();
        // create v1.0 of child
        Version v1Child = child1.checkin();

        // V1 of versionable node has child1
        String v1 = versionableNode.checkin().getName();

        // create V1.1 of child
        child1.checkout();
        Version v11Child = child1.checkin();

        // V2 of versionable node has child1
        versionableNode.checkout();
        String v2 = versionableNode.checkin().getName();

        // restore 1.0 of versionable node --> no child
        versionableNode.restore(version, true);
        assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode(nodeName4));

        // restore V1 via name. since child was checkin first, 1.0 should be restored
        versionableNode.restore(v1, true);
        assertTrue("Node.restore('test') must restore child node.", versionableNode.hasNode(nodeName4));
        child1 = versionableNode.getNode(nodeName4);
        assertEquals("Node.restore('test') must restore child node version 1.0.", v1Child.getName(), child1.getBaseVersion().getName());

        // restore V2 via name. child should be 1.1
        versionableNode.restore(v2, true);
        child1 = versionableNode.getNode(nodeName4);
        assertEquals("Node.restore('foo') must restore child node version 1.1.", v11Child.getName(), child1.getBaseVersion().getName());
    }
View Full Code Here

            child2.addMixin(mixVersionable);
        }
        testRoot.save();
        child1.checkin();
        child2.checkin();
        Version v1 = testRoot.checkin();

        // remove node 1
        testRoot.checkout();
        child1.remove();
        testRoot.save();
View Full Code Here

            child2.addMixin(mixVersionable);
        }
        testRoot.save();
        child1.checkin();
        child2.checkin();
        Version v1 = testRoot.checkin();

        // reoder nodes
        testRoot.checkout();
        testRoot.orderBefore(nodeName2, nodeName1);
        testRoot.save();
View Full Code Here

        try {
            // modify node without calling save()
            versionableNode.setProperty(propertyName1, propertyValue);

            // create version in second workspace
            Version v = wVersionableNode.checkin();
            // try to restore that version
            superuser.getWorkspace().restore(new Version[]{v}, false);

            fail("InvalidItemStateException must be thrown on attempt to call Workspace.restore(Version[], boolean) in a session having any unsaved changes pending.");
        } catch (InvalidItemStateException e) {
View Full Code Here

     * </ul>
     */
    public void testWorkspaceRestoreWithParent() throws RepositoryException {

        try {
            Version parentV = wVersionableNode.checkin();
            superuser.getWorkspace().restore(new Version[]{parentV, wChildVersion}, false);
        } catch (RepositoryException e) {
            fail("Workspace.restore(Version[], boolean) with a version that has no corresponding node must succeed if a version of a parent with correspondance is present in the version array.");
        }
    }
View Full Code Here

     * Test if the removeExisting-flag removes an existing node in case of uuid conflict.
     */
    public void testWorkspaceRestoreWithRemoveExisting() throws NotExecutableException, RepositoryException {
        // create version for parentNode of childNode
        superuser.getWorkspace().clone(workspaceName, wVersionableChildNode.getPath(), wVersionableChildNode.getPath(), false);
        Version parentV = versionableNode.checkin();

        // move child node in order to produce the uuid conflict
        String newChildPath = wVersionableNode2.getPath() + "/" + wVersionableChildNode.getName();
        wSuperuser.move(wVersionableChildNode.getPath(), newChildPath);
        wSuperuser.save();
View Full Code Here

            NodeDefinition nd = wVersionableNode.getDefinition();
            if (nd.getOnParentVersion() != OnParentVersionAction.COPY && nd.getOnParentVersion() != OnParentVersionAction.VERSION) {
                throw new NotExecutableException("Nodes must be versionable in order to run this test.");
            }

            Version v = wVersionableNode.checkin();
            wVersionableNode.checkout();
            wSuperuser.move(wVersionableChildNode.getPath(), wVersionableNode2.getPath() + "/" + wVersionableChildNode.getName());
            wSuperuser.save();
            wSuperuser.getWorkspace().restore(new Version[]{v}, false);
View Full Code Here

        // reference node in other session
        Node nOther = otherSuperuser.getNodeByUUID(n.getUUID());

        // create two versions, reference first version in other session
        n.checkin();
        Version vOther = nOther.getBaseVersion();
        n.checkout();
        n.checkin();

        // start transaction
        utx.begin();

        // remove version and commit
        n.getVersionHistory().removeVersion(vOther.getName());

        // commit
        utx.commit();

        // assert: version has become invalid
        try {
            vOther.getPredecessors();
            fail("Removed version still operational.");
        } catch (RepositoryException e) {
            // expected
        }
    }
View Full Code Here

TOP

Related Classes of javax.jcr.version.Version

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.