Search in sources :

Example 1 with Hold

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

Example 2 with Hold

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

Example 3 with Hold

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();
    }
}
Also used : RetentionManager(javax.jcr.retention.RetentionManager) Node(javax.jcr.Node) Hold(javax.jcr.retention.Hold) VersionException(javax.jcr.version.VersionException)

Example 4 with Hold

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

Example 5 with 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();
    }
}
Also used : Hold(javax.jcr.retention.Hold)

Aggregations

Hold (javax.jcr.retention.Hold)26 RepositoryException (javax.jcr.RepositoryException)9 Node (javax.jcr.Node)4 RetentionManager (javax.jcr.retention.RetentionManager)4 RetentionRegistry (org.apache.jackrabbit.core.retention.RetentionRegistry)3 PathNotFoundException (javax.jcr.PathNotFoundException)2 LockException (javax.jcr.lock.LockException)2 VersionException (javax.jcr.version.VersionException)2 ArrayList (java.util.ArrayList)1 PropertyIterator (javax.jcr.PropertyIterator)1 NodeImpl (org.apache.jackrabbit.core.NodeImpl)1 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)1