Search in sources :

Example 1 with RetentionRegistryImpl

use of org.apache.jackrabbit.core.retention.RetentionRegistryImpl in project jackrabbit by apache.

the class RetentionRegistryImplTest method testReadRetentionFromFile.

public void testReadRetentionFromFile() throws RepositoryException {
    SessionImpl s = (SessionImpl) getHelper().getSuperuserSession();
    RetentionRegistryImpl re = new RetentionRegistryImpl(s, createFileSystem());
    try {
        assertTrue(re.hasEffectiveRetention(s.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveRetention(s.getQPath(childNPath + "/somechild"), true));
        assertFalse(re.hasEffectiveRetention(s.getQPath(testNodePath), false));
        assertFalse(re.hasEffectiveRetention(s.getQPath(childNPath + "/somechild"), false));
        assertFalse(re.hasEffectiveRetention(s.getQPath(childNPath + "/somechild/deepchild"), true));
        assertFalse(re.hasEffectiveRetention(s.getQPath(childP.getPath()), false));
    } finally {
        re.close();
        s.logout();
    }
}
Also used : RetentionRegistryImpl(org.apache.jackrabbit.core.retention.RetentionRegistryImpl)

Example 2 with RetentionRegistryImpl

use of org.apache.jackrabbit.core.retention.RetentionRegistryImpl in project jackrabbit by apache.

the class RetentionRegistryImplTest method testReadHoldFromFile.

public void testReadHoldFromFile() throws RepositoryException {
    PathResolver resolver = (SessionImpl) superuser;
    RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, createFileSystem());
    try {
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3.getPath()), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/somechild"), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/hold/is/deep"), false));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(testNodePath), false));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(childN2.getPath()), false));
    } finally {
        re.close();
    }
}
Also used : PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) RetentionRegistryImpl(org.apache.jackrabbit.core.retention.RetentionRegistryImpl)

Example 3 with RetentionRegistryImpl

use of org.apache.jackrabbit.core.retention.RetentionRegistryImpl in project jackrabbit by apache.

the class RetentionRegistryImplTest method testWriteFileWithChanges.

public void testWriteFileWithChanges() throws RepositoryException, NotExecutableException {
    PathResolver resolver = (SessionImpl) superuser;
    FileSystem fs = createFileSystem();
    RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
    String childN3Path = childN3.getPath();
    try {
        retentionMgr.removeRetentionPolicy(childNPath);
        retentionMgr.removeHold(childNPath, retentionMgr.getHolds(childNPath)[0]);
        superuser.save();
        retentionMgr.setRetentionPolicy(childN3Path, getApplicableRetentionPolicy("retentionOnChild2"));
        retentionMgr.addHold(childNPath, "holdOnChild", false);
        superuser.save();
        // write the changes to the fs
        re.close();
        // create a new dummy registry again.
        re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
        // test holds
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), true));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3Path), true));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path), false));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), false));
        assertFalse(re.hasEffectiveHold(resolver.getQPath(childN3Path + "/child"), true));
        // test policies
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path), false));
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child"), true));
        assertFalse(re.hasEffectiveRetention(resolver.getQPath(childN3Path + "/child/more"), true));
        assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), true));
        assertFalse(re.hasEffectiveRetention(resolver.getQPath(childNPath), false));
    } finally {
        re.close();
        // remove the extra policy that is not cleared upon teardown
        if (retentionMgr.getRetentionPolicy(childN3Path) != null) {
            retentionMgr.removeRetentionPolicy(childN3.getPath());
        }
        superuser.save();
    }
}
Also used : FileSystem(org.apache.jackrabbit.core.fs.FileSystem) MemoryFileSystem(org.apache.jackrabbit.core.fs.mem.MemoryFileSystem) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) RetentionRegistryImpl(org.apache.jackrabbit.core.retention.RetentionRegistryImpl)

Example 4 with RetentionRegistryImpl

use of org.apache.jackrabbit.core.retention.RetentionRegistryImpl in project jackrabbit by apache.

the class RetentionRegistryImplTest method testWriteFile.

public void testWriteFile() throws RepositoryException {
    PathResolver resolver = (SessionImpl) superuser;
    FileSystem fs = createFileSystem();
    RetentionRegistryImpl re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
    try {
        // write the changes to the fs
        re.close();
        // create a new dummy registry again.
        re = new RetentionRegistryImpl((SessionImpl) superuser, fs);
        // test holds
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childN3.getPath()), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/somechild"), false));
        assertTrue(re.hasEffectiveHold(resolver.getQPath(childNPath + "/hold/is/deep"), false));
        // test policies
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childNPath), false));
        assertTrue(re.hasEffectiveRetention(resolver.getQPath(childNPath + "/somechild"), true));
    } finally {
        re.close();
    }
}
Also used : FileSystem(org.apache.jackrabbit.core.fs.FileSystem) MemoryFileSystem(org.apache.jackrabbit.core.fs.mem.MemoryFileSystem) PathResolver(org.apache.jackrabbit.spi.commons.conversion.PathResolver) RetentionRegistryImpl(org.apache.jackrabbit.core.retention.RetentionRegistryImpl)

Aggregations

RetentionRegistryImpl (org.apache.jackrabbit.core.retention.RetentionRegistryImpl)4 PathResolver (org.apache.jackrabbit.spi.commons.conversion.PathResolver)3 FileSystem (org.apache.jackrabbit.core.fs.FileSystem)2 MemoryFileSystem (org.apache.jackrabbit.core.fs.mem.MemoryFileSystem)2