Search in sources :

Example 61 with VersionHistory

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

the class VersionHistoryTest method testGetVersionHistory.

public void testGetVersionHistory() throws Exception {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(JcrConstants.MIX_VERSIONABLE);
    superuser.save();
    VersionHistory vh = versionManager.getVersionHistory(n.getPath());
    assertNotNull(vh);
}
Also used : Node(javax.jcr.Node) VersionHistory(javax.jcr.version.VersionHistory)

Example 62 with VersionHistory

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

the class VersionHistoryTest method testGetVersionHistory2.

public void testGetVersionHistory2() throws Exception {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(JcrConstants.MIX_VERSIONABLE);
    superuser.save();
    Session s = getHelper().getSuperuserSession();
    try {
        VersionHistory vh = s.getWorkspace().getVersionManager().getVersionHistory(n.getPath());
        assertNotNull(vh);
    } finally {
        s.logout();
    }
}
Also used : Node(javax.jcr.Node) VersionHistory(javax.jcr.version.VersionHistory) Session(javax.jcr.Session)

Example 63 with VersionHistory

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

the class VersionHistoryTest method testGetVersionHistoryFromNode.

public void testGetVersionHistoryFromNode() throws Exception {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(JcrConstants.MIX_VERSIONABLE);
    superuser.save();
    VersionHistory vh = n.getVersionHistory();
    assertNotNull(vh);
}
Also used : Node(javax.jcr.Node) VersionHistory(javax.jcr.version.VersionHistory)

Example 64 with VersionHistory

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

the class VersionHistoryTest method testGetNodeByIdentifier.

public void testGetNodeByIdentifier() throws RepositoryException {
    Node n = testRootNode.addNode(nodeName1, testNodeType);
    n.addMixin(mixVersionable);
    superuser.save();
    VersionManager vMgr = superuser.getWorkspace().getVersionManager();
    String id = vMgr.getVersionHistory(n.getPath()).getIdentifier();
    assertTrue("Session.getNodeByIdentifier() did not return VersionHistory object for a nt:versionHistory node.", superuser.getNodeByIdentifier(id) instanceof VersionHistory);
}
Also used : Node(javax.jcr.Node) VersionManager(javax.jcr.version.VersionManager) VersionHistory(javax.jcr.version.VersionHistory)

Example 65 with VersionHistory

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

the class BrokenVersionableTest method verifyNoVersionable.

@Test
public void verifyNoVersionable() throws RepositoryException {
    Session session = createAdminSession();
    VersionManager vMgr = session.getWorkspace().getVersionManager();
    try {
        assertFalse(session.getNode("/versionable1").isNodeType(MIX_VERSIONABLE));
        Node versionable2 = session.getNode("/versionable2");
        assertTrue(versionable2.isNodeType(MIX_VERSIONABLE));
        VersionHistory history = vMgr.getVersionHistory(versionable2.getPath());
        VersionIterator versions = history.getAllVersions();
        assertEquals("jcr:rootVersion", versions.nextVersion().getName());
        assertFalse(versions.hasNext());
    } finally {
        session.logout();
    }
}
Also used : Node(javax.jcr.Node) VersionIterator(javax.jcr.version.VersionIterator) VersionManager(javax.jcr.version.VersionManager) VersionHistory(javax.jcr.version.VersionHistory) Session(javax.jcr.Session) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Test(org.junit.Test)

Aggregations

VersionHistory (javax.jcr.version.VersionHistory)73 Node (javax.jcr.Node)45 Version (javax.jcr.version.Version)29 Test (org.junit.Test)25 RepositoryException (javax.jcr.RepositoryException)17 VersionManager (javax.jcr.version.VersionManager)17 Session (javax.jcr.Session)12 VersionIterator (javax.jcr.version.VersionIterator)12 Property (javax.jcr.Property)7 DavException (org.apache.jackrabbit.webdav.DavException)7 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)7 JcrDavException (org.apache.jackrabbit.webdav.jcr.JcrDavException)7 ArrayList (java.util.ArrayList)6 DavResource (org.apache.jackrabbit.webdav.DavResource)6 ItemNotFoundException (javax.jcr.ItemNotFoundException)5 VersionHistoryResource (org.apache.jackrabbit.webdav.version.VersionHistoryResource)4 Workspace (javax.jcr.Workspace)3 VersionException (javax.jcr.version.VersionException)3 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)3 PathNotFoundException (javax.jcr.PathNotFoundException)2