Search in sources :

Example 66 with VersionManager

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

the class VersionableTest method testReferenceableChild.

public void testReferenceableChild() throws RepositoryException {
    Node node = testRootNode.addNode(nodeName1, ntUnstructured);
    node.addMixin(mixVersionable);
    Node child = node.addNode(nodeName2, ntUnstructured);
    child.addMixin(mixReferenceable);
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    vMgr.checkin(node.getPath());
}
Also used : Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 67 with VersionManager

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

the class VersionableTest method testRecreateVersionableNodeWithAddedChild.

// Oak-1272
public void testRecreateVersionableNodeWithAddedChild() throws Exception {
    Node node = testRootNode.addNode(nodeName1, ntUnstructured);
    node.addMixin(mixVersionable);
    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.addNode(nodeName2, ntUnstructured).setProperty(propertyName1, "bar");
    superuser.save();
}
Also used : Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager)

Example 68 with VersionManager

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

the class ReferencesTest method testVersionReferencesVH.

public void testVersionReferencesVH() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(mixVersionable);
    superuser.save();
    String p = n.getPath();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    VersionHistory vh = vMgr.getVersionHistory(p);
    // check if versionable node has references to root version
    assertEquals("Version History", vh.getIdentifier(), n.getProperty(Property.JCR_VERSION_HISTORY).getString());
    checkReferences("Version History", vh.getReferences(), p + "/jcr:versionHistory");
}
Also used : Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager) VersionHistory(javax.jcr.version.VersionHistory)

Example 69 with VersionManager

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

the class ReferencesTest method testVersionedReferences.

// OAK-1196 - Node.getReferences() should not show references in frozen nodes
public void testVersionedReferences() throws RepositoryException {
    Node ref = testRootNode.addNode(nodeName2, testNodeType);
    ref.addMixin(mixReferenceable);
    superuser.save();
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(mixVersionable);
    n.setProperty("myref", ref);
    superuser.save();
    String p = n.getPath();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    Version v1 = vMgr.checkpoint(p);
    Node frozen = v1.getFrozenNode();
    assertEquals("ref", ref.getPath(), frozen.getProperty("myref").getNode().getPath());
    checkReferences("ref in version store", ref.getReferences(), n.getPath() + "/myref");
    // also test what happens if node is removed
    n.remove();
    ref.remove();
    superuser.save();
    try {
        frozen.getProperty("myref").getNode();
        fail("removed reference should not be accessible");
    } catch (ItemNotFoundException e) {
    // ok
    }
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 70 with VersionManager

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

the class ReferencesTest method testVersionReferencesV0.

public void testVersionReferencesV0() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(mixVersionable);
    superuser.save();
    String p = n.getPath();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    Version v0 = vMgr.getVersionHistory(p).getRootVersion();
    // check if versionable node has references to root version
    assertEquals("Root Version", v0.getIdentifier(), n.getProperty(Property.JCR_BASE_VERSION).getString());
    assertEquals("Root Version", v0.getIdentifier(), n.getProperty(Property.JCR_PREDECESSORS).getValues()[0].getString());
    checkReferences("Root Version", v0.getReferences(), p + "/jcr:baseVersion", p + "/jcr:predecessors");
}
Also used : Version(javax.jcr.version.Version) 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