use of javax.jcr.retention.RetentionManager in project jackrabbit by apache.
the class HoldTest method testRemoveHoldOnCheckedInNode.
public void testRemoveHoldOnCheckedInNode() throws NotExecutableException, RepositoryException {
Node vn = getVersionableChildNode();
vn.checkout();
Node n = vn.addNode(nodeName2);
Hold h = retentionMgr.addHold(n.getPath(), getHoldName(), false);
superuser.save();
// checkin on the parent node make the hold-containing node checked-in.
vn.checkin();
javax.jcr.Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
Hold[] holds = rmgr.getHolds(n.getPath());
if (holds.length > 0) {
rmgr.removeHold(n.getPath(), holds[0]);
otherS.save();
fail("Removing a hold on a checked-in node must throw VersionException.");
}
} catch (VersionException e) {
// success
} finally {
otherS.logout();
// clear hold added before
vn.checkout();
try {
retentionMgr.removeHold(n.getPath(), h);
superuser.save();
} catch (RepositoryException e) {
// should not get here if test is correctly executed.
}
}
}
use of javax.jcr.retention.RetentionManager in project jackrabbit by apache.
the class RetentionPolicyTest method testRemoveRetentionPolicyOnLockedNode.
public void testRemoveRetentionPolicyOnLockedNode() throws NotExecutableException, RepositoryException {
String childPath = getLockedChildNode().getPath();
retentionMgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
testRootNode.getSession().save();
Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
rmgr.removeRetentionPolicy(childPath);
fail("Removing a retention policy on a locked node must throw LockException.");
} catch (LockException e) {
// success
} finally {
otherS.logout();
// clear retention policy added before
try {
retentionMgr.removeRetentionPolicy(childPath);
superuser.save();
} catch (RepositoryException e) {
// should not get here if test is correctly executed.
}
}
}
use of javax.jcr.retention.RetentionManager in project jackrabbit by apache.
the class RetentionPolicyTest method testSetRetentionPolicyOnCheckedInNode.
public void testSetRetentionPolicyOnCheckedInNode() throws NotExecutableException, RepositoryException {
Node child = getVersionableChildNode();
child.checkout();
child.checkin();
String childPath = child.getPath();
// get another session.
Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
rmgr.setRetentionPolicy(childPath, getApplicableRetentionPolicy());
otherS.save();
fail("Setting a retention policy on a checked-in node must throw VersionException.");
} catch (VersionException e) {
// success
} finally {
otherS.logout();
// clear policies (in case of test failure)
try {
retentionMgr.removeRetentionPolicy(childPath);
superuser.save();
} catch (RepositoryException e) {
// ignore.
}
}
}
use of javax.jcr.retention.RetentionManager in project jackrabbit by apache.
the class RetentionPolicyTest method testReadOnlySession.
public void testReadOnlySession() throws NotExecutableException, RepositoryException {
Session s = getHelper().getReadOnlySession();
try {
RetentionManager rmgr = getRetentionManager(s);
try {
rmgr.getRetentionPolicy(testNodePath);
fail("Read-only session doesn't have sufficient privileges to retrieve retention policy.");
} catch (AccessDeniedException e) {
// success
}
try {
rmgr.setRetentionPolicy(testNodePath, getApplicableRetentionPolicy());
fail("Read-only session doesn't have sufficient privileges to retrieve retention policy.");
} catch (AccessDeniedException e) {
// success
}
} finally {
s.logout();
}
}
use of javax.jcr.retention.RetentionManager in project jackrabbit by apache.
the class HoldTest method testRemoveHoldOnLockedNode.
public void testRemoveHoldOnLockedNode() throws NotExecutableException, RepositoryException {
Node child = getLockedChildNode();
Hold h = retentionMgr.addHold(child.getPath(), getHoldName(), false);
testRootNode.getSession().save();
javax.jcr.Session otherS = getHelper().getSuperuserSession();
try {
RetentionManager rmgr = getRetentionManager(otherS);
Hold[] holds = rmgr.getHolds(child.getPath());
if (holds.length > 0) {
rmgr.removeHold(child.getPath(), holds[0]);
otherS.save();
fail("Removing a hold on a locked node must throw LockException.");
}
} catch (LockException e) {
// success
} finally {
otherS.logout();
// clear hold added before
try {
retentionMgr.removeHold(child.getPath(), h);
superuser.save();
} catch (RepositoryException e) {
// should not get here if test is correctly executed.
}
}
}
Aggregations