Search in sources :

Example 76 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class RestoreTest method testRestoreChild1Jcr2.

public void testRestoreChild1Jcr2() throws RepositoryException {
    versionableNode.addNode("child1");
    versionableNode.getSession().save();
    Version v1 = versionManager.checkin(versionableNode.getPath());
    versionManager.checkout(versionableNode.getPath());
    Version v2 = versionManager.checkin(versionableNode.getPath());
    versionManager.restore(v1, true);
    assertTrue("Node.restore('1.2') must not remove child node.", versionableNode.hasNode("child1"));
    versionManager.restore(version, true);
    assertFalse("Node.restore('1.0') must remove child node.", versionableNode.hasNode("child1"));
    try {
        versionManager.restore(v2, true);
    } catch (RepositoryException e) {
        fail("Node.restore('1.3') must fail.");
    }
}
Also used : Version(javax.jcr.version.Version) RepositoryException(javax.jcr.RepositoryException)

Example 77 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class LabelTest method testMoveLabel2.

public void testMoveLabel2() throws RepositoryException {
    vHistory.addVersionLabel(version.getName(), versionLabel, false);
    versionableNode.checkout();
    Version v = versionableNode.checkin();
    vHistory.addVersionLabel(v.getName(), versionLabel, true);
    List<String> labels = Arrays.asList(vHistory.getVersionLabels(v));
    assertTrue(labels.contains(versionLabel));
}
Also used : Version(javax.jcr.version.Version)

Example 78 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class LabelTest method testMoveLabel3.

public void testMoveLabel3() throws RepositoryException {
    versionableNode.checkout();
    Version v = versionableNode.checkin();
    vHistory.addVersionLabel(version.getName(), versionLabel, false);
    vHistory.addVersionLabel(v.getName(), versionLabel, true);
    List<String> labels = Arrays.asList(vHistory.getVersionLabels(version));
    assertFalse(labels.contains(versionLabel));
}
Also used : Version(javax.jcr.version.Version)

Example 79 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class LabelTest method testMoveLabel4.

public void testMoveLabel4() throws RepositoryException {
    versionableNode.checkout();
    Version v = versionableNode.checkin();
    vHistory.addVersionLabel(version.getName(), versionLabel, false);
    vHistory.addVersionLabel(v.getName(), versionLabel, true);
    Version v2 = vHistory.getVersionByLabel(versionLabel);
    assertTrue(v2.isSame(v));
}
Also used : Version(javax.jcr.version.Version)

Example 80 with Version

use of javax.jcr.version.Version in project jackrabbit by apache.

the class BackwardsCompatibilityIT method assertVersionable.

@SuppressWarnings("deprecation")
private Node assertVersionable(Node test) throws RepositoryException {
    assertTrue(test.hasNode("versionable"));
    Node versionable = test.getNode("versionable");
    assertTrue(versionable.isNodeType("nt:myversionable"));
    assertTrue(versionable.isNodeType("nt:unstructured"));
    assertTrue(versionable.isNodeType("mix:versionable"));
    assertFalse(versionable.isCheckedOut());
    VersionHistory history = versionable.getVersionHistory();
    Version versionB = versionable.getBaseVersion();
    String[] labels = history.getVersionLabels(versionB);
    assertEquals(1, labels.length);
    assertEquals("labelB", labels[0]);
    Version versionA = history.getVersionByLabel("labelA");
    versionable.restore(versionA, true);
    assertEquals("A", versionable.getProperty("foo").getString());
    versionable.restore(versionB, true);
    assertEquals("B", versionable.getProperty("foo").getString());
    return versionable;
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionHistory(javax.jcr.version.VersionHistory)

Aggregations

Version (javax.jcr.version.Version)265 Node (javax.jcr.Node)155 VersionManager (javax.jcr.version.VersionManager)65 RepositoryException (javax.jcr.RepositoryException)45 VersionHistory (javax.jcr.version.VersionHistory)29 VersionException (javax.jcr.version.VersionException)25 NodeIterator (javax.jcr.NodeIterator)23 Session (javax.jcr.Session)19 Test (org.junit.Test)19 Property (javax.jcr.Property)16 VersionIterator (javax.jcr.version.VersionIterator)16 Value (javax.jcr.Value)14 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)14 ItemExistsException (javax.jcr.ItemExistsException)13 HashSet (java.util.HashSet)12 NodeDefinition (javax.jcr.nodetype.NodeDefinition)12 ArrayList (java.util.ArrayList)11 Set (java.util.Set)7 DavException (org.apache.jackrabbit.webdav.DavException)7 UserTransaction (javax.transaction.UserTransaction)6