use of javax.jcr.version.VersionHistory in project jackrabbit by apache.
the class CopyTest method testCopy.
public void testCopy() throws RepositoryException {
Workspace wsp = superuser.getWorkspace();
VersionManager vMgr = wsp.getVersionManager();
String srcPath = versionableNode.getPath();
String dstPath = getProperty("destination");
wsp.copy(srcPath, dstPath);
// check versionable
Node v = superuser.getNode(dstPath);
assertTrue("Copied Node.isNodeType(mix:cersionable) must return true.", v.isNodeType(mixVersionable));
// check different version history
VersionHistory vh1 = vMgr.getVersionHistory(srcPath);
VersionHistory vh2 = vMgr.getVersionHistory(dstPath);
assertFalse("Copied node needs a new version history.", vh1.isSame(vh2));
// check if 1 version
assertEquals("Copied node must have 1 version.", 1, getNumberOfVersions(vh2));
// check if jcr:copiedFrom is set correctly
assertTrue("Version history of desination must have a jcr:copiedFrom property", vh2.hasProperty(jcrCopiedFrom));
Node ref = vh2.getProperty(jcrCopiedFrom).getNode();
Version base = vMgr.getBaseVersion(srcPath);
assertTrue("jcr:copiedFrom must point to the base version of the original.", ref.isSame(base));
}
use of javax.jcr.version.VersionHistory in project jackrabbit by apache.
the class RemoveVersionByLabel method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String path = (String) ctx.get(this.pathKey);
String label = (String) ctx.get(this.labelKey);
if (log.isDebugEnabled()) {
log.debug("Remove version with label " + label + " from node " + path);
}
VersionHistory vh = CommandHelper.getNode(ctx, path).getVersionHistory();
Version v = vh.getVersionByLabel(label);
vh.removeVersion(v.getName());
return false;
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class L5_SpecialPermissionsTest method testReadVersionInformation.
@Test
public void testReadVersionInformation() throws RepositoryException {
Node childNode = superuser.getNode(childPath);
childNode.addMixin(JcrConstants.MIX_VERSIONABLE);
superuser.save();
childNode.checkin();
childNode.checkout();
// EXERCISE: uncomment the following permission setup and test the impact it has!
// EXERCISE: discuss and explain your findings
// AccessControlUtils.addAccessControlEntry(superuser, "/jcr:system", testGroupPrincipal, new String[] {Privilege.JCR_READ}, false);
// paths.add("/jcr:system");
// superuser.save();
//
Session s = createTestSession();
// EXERCISE: uncomment to verify the permission setup is as expected
//assertFalse(s.nodeExists(VersionConstants.VERSION_STORE_PATH));
VersionManager versionManager = s.getWorkspace().getVersionManager();
VersionHistory vh = versionManager.getVersionHistory(childPath);
Version rootVersion = vh.getRootVersion();
Version baseVersion = versionManager.getBaseVersion(childPath);
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class VersionManagerImpl method restore.
@Override
public void restore(final String absPath, final String versionName, final boolean removeExisting) throws RepositoryException {
VersionHistory history = getVersionHistory(absPath);
restore(new Version[] { history.getVersion(versionName) }, removeExisting);
}
use of javax.jcr.version.VersionHistory in project jackrabbit-oak by apache.
the class ReadVersionContentTest method testVersionHistoryGetIdentifier.
/**
* @since oak
*/
@Test
public void testVersionHistoryGetIdentifier() throws Exception {
VersionHistory testVh = testSession.getNode(versionablePath).getVersionHistory();
testVh.getIdentifier();
}
Aggregations