use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class RetentionRegistryImplTest method testRemoveHold.
public void testRemoveHold() throws RepositoryException {
SessionImpl s = (SessionImpl) getHelper().getSuperuserSession();
RetentionRegistry re = s.getRetentionRegistry();
try {
Hold[] holds = retentionMgr.getHolds(childNPath);
for (int i = 0; i < holds.length; i++) {
retentionMgr.removeHold(childNPath, holds[i]);
// hold must still be in effect.
assertTrue(re.hasEffectiveHold(s.getQPath(childNPath), false));
}
superuser.save();
assertFalse(re.hasEffectiveHold(s.getQPath(childNPath), false));
} finally {
s.logout();
}
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class RetentionManagerImpl method getHolds.
//---------------------------------------------------< RetentionManager >---
/**
* @see RetentionManager#getHolds(String)
*/
public Hold[] getHolds(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException {
NodeImpl n = (NodeImpl) session.getNode(absPath);
session.getAccessManager().checkPermission(session.getQPath(absPath), Permission.RETENTION_MNGMT);
Hold[] holds;
if (n.isNodeType(REP_RETENTION_MANAGEABLE) && n.hasProperty(REP_HOLD)) {
holds = HoldImpl.createFromProperty(n.getProperty(REP_HOLD), n.getNodeId());
} else {
holds = new Hold[0];
}
return holds;
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testAddHoldOnCheckedInNode.
public void testAddHoldOnCheckedInNode() throws NotExecutableException, RepositoryException {
Node child = getVersionableChildNode();
child.checkout();
child.checkin();
// get another session.
javax.jcr.Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
rmgr.addHold(child.getPath(), getHoldName(), false);
otherS.save();
fail("Adding hold on a checked-in node must throw VersionException.");
} catch (VersionException e) {
// success
} finally {
otherS.logout();
// clear holds (in case of test failure)
child.checkout();
Hold[] holds = retentionMgr.getHolds(child.getPath());
for (int i = 0; i < holds.length; i++) {
retentionMgr.removeHold(child.getPath(), holds[i]);
}
superuser.save();
}
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testAddHold2.
public void testAddHold2() throws RepositoryException, NotExecutableException {
Hold[] holdsBefore = retentionMgr.getHolds(testNodePath);
Hold hold = retentionMgr.addHold(testNodePath, getHoldName(), false);
assertFalse("The hold added must not have been present before.", containsHold(holdsBefore, hold));
}
use of javax.jcr.retention.Hold in project jackrabbit by apache.
the class HoldTest method testRemoveHoldIsTransient.
public void testRemoveHoldIsTransient() throws RepositoryException, NotExecutableException {
Hold hold = retentionMgr.addHold(testNodePath, getHoldName(), false);
superuser.save();
try {
Hold[] holds = retentionMgr.getHolds(testNodePath);
retentionMgr.removeHold(testNodePath, hold);
superuser.refresh(false);
Hold[] holds2 = retentionMgr.getHolds(testNodePath);
assertEquals("Reverting transient hold removal must restore the original state.", Arrays.asList(holds), Arrays.asList(holds2));
} finally {
// clear the hold that was permanently added before.
retentionMgr.removeHold(testNodePath, hold);
superuser.save();
}
}
Aggregations