Search in sources :

Example 61 with VersionManager

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

the class VersionableTest method testRecreateVersionableNodeWithRemovedProperty.

// Oak-1272
public void testRecreateVersionableNodeWithRemovedProperty() throws Exception {
    Node node = testRootNode.addNode(nodeName1, ntUnstructured);
    node.addMixin(mixVersionable);
    node.setProperty(propertyName1, "foo");
    superuser.save();
    VersionManager vm = superuser.getWorkspace().getVersionManager();
    vm.checkin(node.getPath());
    // re-create node
    node.remove();
    node = testRootNode.addNode(nodeName1, ntUnstructured);
    node.addMixin(mixVersionable);
    superuser.save();
}
Also used : Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 62 with VersionManager

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

the class VersionableTest method testSuccessorsPredecessorsMergedOnRemove.

// OAK-5193
public void testSuccessorsPredecessorsMergedOnRemove() throws Exception {
    Node node = testRootNode.addNode(nodeName1, ntUnstructured);
    node.addMixin(mixVersionable);
    superuser.save();
    VersionManager vm = superuser.getWorkspace().getVersionManager();
    VersionHistory history = vm.getVersionHistory(node.getPath());
    // 1.0
    vm.checkpoint(node.getPath());
    Version v11 = vm.checkpoint(node.getPath());
    // 1.2
    vm.checkpoint(node.getPath());
    // 1.3
    vm.checkpoint(node.getPath());
    vm.restore(v11, true);
    // 1.1
    vm.checkpoint(node.getPath());
    // 1.1.0
    vm.checkpoint(node.getPath());
    assertSuccessors(history, of("1.1.0", "1.2"), "1.1");
    // 1.1.1
    vm.checkpoint(node.getPath());
    history.removeVersion("1.2");
    assertSuccessors(history, of("1.1.0", "1.3"), "1.1");
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager) VersionHistory(javax.jcr.version.VersionHistory)

Example 63 with VersionManager

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

the class VersionableTest method testRecreateVersionableNodeWithChangedProperty.

// Oak-1272
public void testRecreateVersionableNodeWithChangedProperty() throws Exception {
    Node node = testRootNode.addNode(nodeName1, ntUnstructured);
    node.addMixin(mixVersionable);
    node.setProperty(propertyName1, "foo");
    superuser.save();
    VersionManager vm = superuser.getWorkspace().getVersionManager();
    vm.checkin(node.getPath());
    // re-create node
    node.remove();
    node = testRootNode.addNode(nodeName1, ntUnstructured);
    node.addMixin(mixVersionable);
    node.setProperty(propertyName1, "bar");
    superuser.save();
}
Also used : Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 64 with VersionManager

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

the class VersionableTest method testRemoveAndCreateSameVersionableChildNode.

// OAK-1272
public void testRemoveAndCreateSameVersionableChildNode() throws Exception {
    // create parent
    Node parentNode = testRootNode.addNode("parent");
    parentNode.setPrimaryType(ntUnstructured);
    parentNode.setProperty("name", "sample");
    // create a versionable child
    Node createdNode = parentNode.addNode("versionablechild", "nt:unstructured");
    createdNode.addMixin(mixVersionable);
    superuser.save();
    VersionManager vm = superuser.getWorkspace().getVersionManager();
    vm.checkin(testRootNode.getPath() + "/parent/versionablechild");
    // delete and create exact same node
    Node parent = testRootNode.getNode("parent");
    // remove children
    NodeIterator nodes = parent.getNodes();
    while (nodes.hasNext()) {
        Node childNode = nodes.nextNode();
        childNode.remove();
    }
    // create again versionable child node
    Node recreatedNode = parent.addNode("versionablechild", ntUnstructured);
    recreatedNode.addMixin(mixVersionable);
    superuser.save();
}
Also used : NodeIterator(javax.jcr.NodeIterator) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 65 with VersionManager

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

the class VersionableTest method testGetTypeOfPredecessors.

public void testGetTypeOfPredecessors() throws RepositoryException {
    Node node = testRootNode.addNode(nodeName1, testNodeType);
    node.addMixin(mixVersionable);
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    vMgr.checkin(node.getPath());
    assertEquals(PropertyType.nameFromValue(PropertyType.REFERENCE), PropertyType.nameFromValue(node.getProperty(jcrPredecessors).getType()));
}
Also used : 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