Search in sources :

Example 1 with PathFilter

use of org.apache.jackrabbit.vault.fs.api.PathFilter in project sling by apache.

the class VltUtilsTest method testDeepFilter.

@Test
public void testDeepFilter() throws Exception {
    DistributionRequest request = new SimpleDistributionRequest(ADD, true, "/foo");
    NavigableMap<String, List<String>> nodeFilters = new TreeMap<String, List<String>>();
    nodeFilters.put("/foo", Arrays.asList("/foo/bar", "/foo/bar1"));
    NavigableMap<String, List<String>> propFilters = new TreeMap<String, List<String>>();
    propFilters.put("/", Arrays.asList("^.*/prop1", "^.*/prop2"));
    WorkspaceFilter wsFilter = VltUtils.createFilter(request, nodeFilters, propFilters);
    assertNotNull(wsFilter);
    assertNotNull(wsFilter.getPropertyFilterSets());
    List<PathFilterSet> propFilterSet = wsFilter.getPropertyFilterSets();
    assertEquals(1, propFilterSet.size());
    PathFilterSet propFilter = propFilterSet.get(0);
    assertEquals(2, propFilter.getEntries().size());
    PathFilter filter = propFilter.getEntries().get(0).getFilter();
    assertTrue(filter.matches("/foo/bar/prop1"));
    assertTrue(filter.matches("/foo/prop1"));
}
Also used : SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) DistributionRequest(org.apache.sling.distribution.DistributionRequest) SimpleDistributionRequest(org.apache.sling.distribution.SimpleDistributionRequest) PathFilter(org.apache.jackrabbit.vault.fs.api.PathFilter) PathFilterSet(org.apache.jackrabbit.vault.fs.api.PathFilterSet) List(java.util.List) WorkspaceFilter(org.apache.jackrabbit.vault.fs.api.WorkspaceFilter) TreeMap(java.util.TreeMap) Test(org.junit.Test)

Aggregations

List (java.util.List)1 TreeMap (java.util.TreeMap)1 PathFilter (org.apache.jackrabbit.vault.fs.api.PathFilter)1 PathFilterSet (org.apache.jackrabbit.vault.fs.api.PathFilterSet)1 WorkspaceFilter (org.apache.jackrabbit.vault.fs.api.WorkspaceFilter)1 DistributionRequest (org.apache.sling.distribution.DistributionRequest)1 SimpleDistributionRequest (org.apache.sling.distribution.SimpleDistributionRequest)1 Test (org.junit.Test)1