use of javax.jcr.retention.RetentionPolicy in project jackrabbit by apache.
the class RetentionPolicyTest method testSetInvalidRetentionPolicy.
public void testSetInvalidRetentionPolicy() {
try {
RetentionPolicy invalidRPolicy = new RetentionPolicy() {
public String getName() throws RepositoryException {
return "anyName";
}
};
retentionMgr.setRetentionPolicy(testNodePath, invalidRPolicy);
fail("Setting an invalid retention policy must fail.");
} catch (RepositoryException e) {
// success
}
}
use of javax.jcr.retention.RetentionPolicy in project jackrabbit by apache.
the class RetentionPolicyTest method testInvalidName.
public void testInvalidName() {
try {
RetentionPolicy rp = new RetentionPolicy() {
public String getName() throws RepositoryException {
return "*.[y]";
}
};
retentionMgr.setRetentionPolicy(testNodePath, rp);
fail("Setting a policy with an invalid JCR name must fail.");
} catch (RepositoryException e) {
// success
} catch (IllegalArgumentException e) {
// fine as well.
}
}
use of javax.jcr.retention.RetentionPolicy in project jackrabbit by apache.
the class RetentionPolicyTest method setUp.
protected void setUp() throws Exception {
super.setUp();
// make sure there is no retention policy defined at testNodePath.
RetentionPolicy p = retentionMgr.getRetentionPolicy(testNodePath);
if (p != null) {
retentionMgr.removeRetentionPolicy(testNodePath);
superuser.save();
}
}
use of javax.jcr.retention.RetentionPolicy in project jackrabbit by apache.
the class RetentionManagerImpl method getRetentionPolicy.
/**
* @see RetentionManager#getRetentionPolicy(String)
*/
public RetentionPolicy getRetentionPolicy(String absPath) throws PathNotFoundException, AccessDeniedException, RepositoryException {
NodeImpl n = (NodeImpl) session.getNode(absPath);
session.getAccessManager().checkPermission(session.getQPath(absPath), Permission.RETENTION_MNGMT);
RetentionPolicy rPolicy = null;
if (n.isNodeType(REP_RETENTION_MANAGEABLE) && n.hasProperty(REP_RETENTION_POLICY)) {
String jcrName = n.getProperty(REP_RETENTION_POLICY).getString();
rPolicy = new RetentionPolicyImpl(jcrName, n.getNodeId(), session);
}
return rPolicy;
}
use of javax.jcr.retention.RetentionPolicy in project jackrabbit by apache.
the class TestContentLoader method addRetentionTestData.
/**
* Creates a node with a RetentionPolicy
*/
private void addRetentionTestData(Node node) throws RepositoryException {
RetentionPolicy rp = RetentionPolicyImpl.createRetentionPolicy("testRetentionPolicy", node.getSession());
node.getSession().getRetentionManager().setRetentionPolicy(node.getPath(), rp);
}
Aggregations