Search in sources :

Example 56 with VersionHistory

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

the class VersionManagementTest method testRemoveVersionLabel.

/**
     * @since oak
     */
@Test
public void testRemoveVersionLabel() throws Exception {
    Node n = createVersionableNode(superuser.getNode(path));
    allow(n.getPath(), versionPrivileges);
    Node testNode = testSession.getNode(n.getPath());
    Version v = testNode.checkin();
    testNode.checkout();
    Version v2 = testNode.checkin();
    testNode.checkout();
    // -> VersionHistory.addVersionLabel must be allowed
    VersionHistory history = testNode.getVersionHistory();
    history.addVersionLabel(v.getName(), "testLabel", false);
    history.addVersionLabel(v2.getName(), "testLabel", true);
    VersionManager vMgr = testSession.getWorkspace().getVersionManager();
    history = vMgr.getVersionHistory(testNode.getPath());
    history.removeVersionLabel("testLabel");
}
Also used : Version(javax.jcr.version.Version) Node(javax.jcr.Node) VersionHistory(javax.jcr.version.VersionHistory) VersionManager(javax.jcr.version.VersionManager) Test(org.junit.Test)

Example 57 with VersionHistory

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

the class ReadVersionContentTest method testGetVersionHistory.

/**
     * @since oak
     */
@Test
public void testGetVersionHistory() throws Exception {
    // accessing the version history must be allowed if the versionable node
    // is readable to the editing test session.
    Node testNode = testSession.getNode(versionablePath);
    VersionHistory vh = testNode.getVersionHistory();
    VersionHistory vh2 = testSession.getWorkspace().getVersionManager().getVersionHistory(versionablePath);
}
Also used : Node(javax.jcr.Node) VersionHistory(javax.jcr.version.VersionHistory) Test(org.junit.Test)

Example 58 with VersionHistory

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

the class ReadVersionContentTest method testVersionHistoryParent.

/**
     * @since oak
     */
@Test
public void testVersionHistoryParent() throws Exception {
    // accessing the version history must be allowed if the versionable node
    // is readable to the editing test session.
    Node testNode = testSession.getNode(versionablePath);
    VersionHistory testVh = testNode.getVersionHistory();
    try {
        testVh.getParent();
        fail("version storage intermediate node must not be accessible");
    } catch (AccessDeniedException e) {
    // success
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) Node(javax.jcr.Node) VersionHistory(javax.jcr.version.VersionHistory) Test(org.junit.Test)

Example 59 with VersionHistory

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

the class ReadVersionContentTest method testAccessVersionHistoryVersionableNodeNotAccessible.

/**
     * @since oak
     */
@Test
public void testAccessVersionHistoryVersionableNodeNotAccessible() throws Exception {
    // revert read permission on the versionable node
    modify(versionablePath, Privilege.JCR_READ, false);
    // versionable node is not readable any more for test session.
    assertFalse(testSession.nodeExists(versionablePath));
    // access version history directly => should fail
    try {
        VersionHistory history = (VersionHistory) testSession.getNode(vh.getPath());
        fail("Access to version history should be denied if versionable node is not accessible");
    } catch (PathNotFoundException e) {
    // success
    }
    try {
        VersionHistory history = (VersionHistory) testSession.getNodeByIdentifier(vh.getIdentifier());
        fail("Access to version history should be denied if versionable node is not accessible");
    } catch (ItemNotFoundException e) {
    // success
    }
    try {
        VersionHistory history = (VersionHistory) testSession.getNodeByUUID(vh.getUUID());
        fail("Access to version history should be denied if versionable node is not accessible");
    } catch (ItemNotFoundException e) {
    // success
    }
}
Also used : PathNotFoundException(javax.jcr.PathNotFoundException) VersionHistory(javax.jcr.version.VersionHistory) ItemNotFoundException(javax.jcr.ItemNotFoundException) Test(org.junit.Test)

Example 60 with VersionHistory

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

the class ReadVersionContentTest method testGetAllLinearVersions.

/**
     * @since oak
     */
@Test
public void testGetAllLinearVersions() throws Exception {
    // accessing the version history must be allowed if the versionable node
    // is readable to the editing test session.
    Node testNode = testSession.getNode(versionablePath);
    VersionHistory vh = testNode.getVersionHistory();
    VersionIterator versionIterator = vh.getAllLinearVersions();
}
Also used : Node(javax.jcr.Node) VersionIterator(javax.jcr.version.VersionIterator) VersionHistory(javax.jcr.version.VersionHistory) 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