Search in sources :

Example 1 with RetentionPolicy

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
    }
}
Also used : RepositoryException(javax.jcr.RepositoryException) RetentionPolicy(javax.jcr.retention.RetentionPolicy)

Example 2 with RetentionPolicy

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.
    }
}
Also used : RepositoryException(javax.jcr.RepositoryException) RetentionPolicy(javax.jcr.retention.RetentionPolicy)

Example 3 with RetentionPolicy

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();
    }
}
Also used : RetentionPolicy(javax.jcr.retention.RetentionPolicy)

Example 4 with RetentionPolicy

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;
}
Also used : NodeImpl(org.apache.jackrabbit.core.NodeImpl) RetentionPolicy(javax.jcr.retention.RetentionPolicy)

Example 5 with RetentionPolicy

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);
}
Also used : RetentionPolicy(javax.jcr.retention.RetentionPolicy)

Aggregations

RetentionPolicy (javax.jcr.retention.RetentionPolicy)10 RepositoryException (javax.jcr.RepositoryException)2 NodeImpl (org.apache.jackrabbit.core.NodeImpl)1 PathMap (org.apache.jackrabbit.spi.commons.name.PathMap)1