use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class ReadVersionContentTest method testGetVersion.
/**
* @since oak
*/
@Test
public void testGetVersion() 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();
Version version = vh.getVersion(v.getName());
assertTrue(v.isSame(version));
assertTrue(vh.isSame(version.getContainingHistory()));
version = vh.getVersion(v2.getName());
assertTrue(v2.isSame(version));
assertTrue(vh.isSame(version.getContainingHistory()));
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class ReadVersionContentTest method testGetAllVersions.
/**
* @since oak
*/
@Test
public void testGetAllVersions() 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.getAllVersions();
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class VersionManagementTest method testAddVersionLabel.
/**
* @since oak
*/
@Test
public void testAddVersionLabel() 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.addVersionLabel(v.getName(), "testLabel", true);
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class VersionManagementTest method testVersionableChildNode2.
/**
* @since oak
*/
@Test
public void testVersionableChildNode2() throws Exception {
Node testNode = superuser.getNode(path).addNode("n1").addNode("n2").addNode("n3").addNode("jcr:content");
testNode.addMixin("mix:versionable");
superuser.save();
testNode.remove();
testNode = superuser.getNode(path).getNode("n1").getNode("n2").getNode("n3").addNode("jcr:content");
testNode.addMixin("mix:versionable");
superuser.save();
assertTrue(testNode.isNodeType("mix:versionable"));
VersionHistory vh = testNode.getVersionHistory();
Property versionablePath = vh.getProperty(superuser.getWorkspace().getName());
assertEquals(testNode.getPath(), versionablePath.getString());
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class VersionManagementTest method testAccessVersionHistoryVersionableNodeNotAccessible.
/**
* @since oak (DIFF: jr required jcr:versionManagement privilege on the version store)
*/
@Test
public void testAccessVersionHistoryVersionableNodeNotAccessible() throws Exception {
Node n = createVersionableNode(superuser.getNode(path));
allow(n.getPath(), versionPrivileges);
Node testNode = testSession.getNode(n.getPath());
testNode.checkin();
testNode.checkout();
VersionHistory vh = testNode.getVersionHistory();
String vhPath = vh.getPath();
String vhUUID = vh.getIdentifier();
// revert read permission on the versionable node
modify(n.getPath(), Privilege.JCR_READ, false);
// versionable node is not readable any more for test session.
assertFalse(testSession.nodeExists(n.getPath()));
// access version history directly => should fail
try {
VersionHistory history = (VersionHistory) testSession.getNode(vhPath);
fail("Access to version history should be denied if versionable node is not accessible");
} catch (PathNotFoundException e) {
// success
}
try {
VersionHistory history = (VersionHistory) testSession.getNodeByIdentifier(vhUUID);
fail("Access to version history should be denied if versionable node is not accessible");
} catch (ItemNotFoundException e) {
// success
}
try {
VersionHistory history = (VersionHistory) testSession.getNodeByUUID(vhUUID);
fail("Access to version history should be denied if versionable node is not accessible");
} catch (ItemNotFoundException e) {
// success
}
}
Aggregations