Search in sources :

Example 56 with VersionManager

use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.

the class VersionTest method testFrozenUUID.

// OAK-1009 & OAK-1346
public void testFrozenUUID() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(mixVersionable);
    Node child = n.addNode(nodeName2, "nt:folder");
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    Version v = vMgr.checkpoint(n.getPath());
    vMgr.checkpoint(n.getPath());
    Version baseVersion = vMgr.getBaseVersion(n.getPath());
    Node frozenChild = baseVersion.getFrozenNode().getNode(child.getName());
    assertEquals(child.getIdentifier(), frozenChild.getProperty(Property.JCR_FROZEN_UUID).getString());
    vMgr.restore(v, true);
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 57 with VersionManager

use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.

the class VersionTest method testGetNodeByUUID.

@SuppressWarnings("deprecation")
public void testGetNodeByUUID() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(mixVersionable);
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    String uuid = vMgr.getBaseVersion(n.getPath()).getUUID();
    assertTrue("Session.getNodeByUUID() did not return Version object for a nt:version node.", superuser.getNodeByUUID(uuid) instanceof Version);
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 58 with VersionManager

use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.

the class VersionTest method testRemoveVersion.

// OAK-3130
public void testRemoveVersion() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(mixVersionable);
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    vMgr.checkin(n.getPath());
    Version v = vMgr.getBaseVersion(n.getPath());
    try {
        v.getContainingHistory().removeVersion(v.getName());
        fail("removeVersion() must fail with ReferentialIntegrityException");
    } catch (ReferentialIntegrityException e) {
    // expected
    }
    vMgr.checkout(n.getPath());
    v = vMgr.getBaseVersion(n.getPath());
    try {
        v.getContainingHistory().removeVersion(v.getName());
        fail("removeVersion() must fail with ReferentialIntegrityException");
    } catch (ReferentialIntegrityException e) {
    // expected
    }
}
Also used : Version(javax.jcr.version.Version) ReferentialIntegrityException(javax.jcr.ReferentialIntegrityException) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 59 with VersionManager

use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.

the class OpvIgnoreTest method testWritePropertyWithIgnoreOPVAfterCheckIn.

//OAK-3328
public void testWritePropertyWithIgnoreOPVAfterCheckIn() throws RepositoryException {
    Node ignoreTestNode = testRootNode.addNode("ignoreTestNode", JcrConstants.NT_UNSTRUCTURED);
    String ignoredPropertyName = "ignoredProperty";
    NodeTypeTemplate mixinWithIgnoreProperty = createNodeTypeWithIgnoreOPVProperty(ignoredPropertyName);
    Node node = ignoreTestNode.addNode("testNode", testNodeType);
    node.addMixin(mixinWithIgnoreProperty.getName());
    node.setProperty(ignoredPropertyName, "initial value");
    node.addMixin(mixVersionable);
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    if (!node.isCheckedOut()) {
        vMgr.checkout(node.getPath());
    }
    vMgr.checkin(node.getPath());
    node.setProperty(ignoredPropertyName, "next value");
    superuser.save();
    Property ignoreProperty = node.getProperty(ignoredPropertyName);
    assertEquals("next value", ignoreProperty.getString());
}
Also used : NodeTypeTemplate(javax.jcr.nodetype.NodeTypeTemplate) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager) Property(javax.jcr.Property)

Example 60 with VersionManager

use of javax.jcr.version.VersionManager in project jackrabbit-oak by apache.

the class OpvIgnoreTest method testRemovePropertyWithIgnoreOPVAfterCheckIn.

//OAK-3328
public void testRemovePropertyWithIgnoreOPVAfterCheckIn() throws RepositoryException {
    Node ignoreTestNode = testRootNode.addNode("ignoreTestNode", JcrConstants.NT_UNSTRUCTURED);
    String ignoredPropertyName = "test:ignoredProperty";
    NodeTypeTemplate mixinWithIgnoreProperty = createNodeTypeWithIgnoreOPVProperty(ignoredPropertyName);
    Node node = ignoreTestNode.addNode("testNode", testNodeType);
    node.addMixin(mixinWithIgnoreProperty.getName());
    node.setProperty(ignoredPropertyName, "initial value");
    node.addMixin(mixVersionable);
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    if (!node.isCheckedOut()) {
        vMgr.checkout(node.getPath());
    }
    vMgr.checkin(node.getPath());
    node.getProperty(ignoredPropertyName).remove();
    superuser.save();
    assertFalse(node.hasProperty(ignoredPropertyName));
}
Also used : NodeTypeTemplate(javax.jcr.nodetype.NodeTypeTemplate) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Aggregations

VersionManager (javax.jcr.version.VersionManager)154 Node (javax.jcr.Node)97 Version (javax.jcr.version.Version)65 VersionHistory (javax.jcr.version.VersionHistory)17 RepositoryException (javax.jcr.RepositoryException)11 Value (javax.jcr.Value)10 Test (org.junit.Test)9 Property (javax.jcr.Property)8 Session (javax.jcr.Session)8 NodeIterator (javax.jcr.NodeIterator)7 VersionException (javax.jcr.version.VersionException)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 MergeException (javax.jcr.MergeException)4 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)4 VersionIterator (javax.jcr.version.VersionIterator)4 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 NodeDefinitionTemplate (javax.jcr.nodetype.NodeDefinitionTemplate)3 InvalidItemStateException (javax.jcr.InvalidItemStateException)2