use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class VersionManagementTest method testVersionableChildNode.
/**
* @since oak
*/
@Test
public void testVersionableChildNode() throws Exception {
Node testNode = superuser.getNode(path).addNode("n1").addNode("n2").addNode("n3").addNode("jcr:content");
superuser.save();
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 testAccessVersionHistoryVersionableNodeRemoved.
/**
* @since oak
*/
@Test
public void testAccessVersionHistoryVersionableNodeRemoved() throws Exception {
Node n = createVersionableNode(superuser.getNode(path));
allow(n.getPath(), versionPrivileges);
n.checkin();
n.checkout();
String versionablePath = n.getPath();
VersionHistory vh = n.getVersionHistory();
String vhPath = vh.getPath();
String vhUUID = vh.getIdentifier();
// remove the versionable node
n.remove();
superuser.save();
testSession.refresh(false);
assertTrue(testSession.nodeExists(path));
assertFalse(testSession.nodeExists(versionablePath));
// accessing the version history directly should still succeed as
// read permission is still granted on the tree defined by the parent.
VersionHistory history = (VersionHistory) testSession.getNode(vhPath);
history = (VersionHistory) testSession.getNodeByIdentifier(vhUUID);
history = (VersionHistory) testSession.getNodeByUUID(vhUUID);
// revoking read permission on the parent node -> version history
// must no longer be accessible
modify(path, Privilege.JCR_READ, false);
assertFalse(testSession.nodeExists(vhPath));
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class VersionManagementTest method testVersionablePath.
/**
* @since oak
*/
@Test
public void testVersionablePath() throws Exception {
Node n = createVersionableNode(superuser.getNode(path));
VersionHistory vh = n.getVersionHistory();
Property versionablePath = vh.getProperty(superuser.getWorkspace().getName());
assertEquals(n.getPath(), versionablePath.getString());
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class CopyVersionHistoryTest method assertMissingHistories.
private static void assertMissingHistories(final Session session, final String... names) throws RepositoryException {
for (final String mixin : MIXINS) {
final String pathPrefix = VERSIONABLES_PATH_PREFIX + mixin + "/";
for (final String name : names) {
final String path = pathPrefix + name;
final VersionHistory history = getVersionHistoryForPath(session, path);
assertNull("Should not have found history for " + path, history);
}
}
}
use of javax.jcr.version.VersionHistory in project jackrabbit by apache.
the class VersionControlledResourceImpl method getVersionHistory.
/**
* Returns the {@link javax.jcr.version.VersionHistory} associated with the repository node.
* If the node is not versionable an exception is thrown.
*
* @return the {@link VersionHistoryResource} associated with this resource.
* @throws org.apache.jackrabbit.webdav.DavException
* @see org.apache.jackrabbit.webdav.version.VersionControlledResource#getVersionHistory()
* @see javax.jcr.Node#getVersionHistory()
*/
public VersionHistoryResource getVersionHistory() throws DavException {
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
if (!isVersionControlled()) {
throw new DavException(DavServletResponse.SC_FORBIDDEN);
}
try {
VersionHistory vh = getNode().getVersionHistory();
DavResourceLocator loc = getLocatorFromNode(vh);
DavResource vhr = createResourceFromLocator(loc);
if (vhr instanceof VersionHistoryResource) {
return (VersionHistoryResource) vhr;
} else {
// severe error since resource factory doesn't behave correctly.
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
}
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
}
Aggregations