use of org.apache.jackrabbit.vault.fs.api.PathFilterSet 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"));
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project sling by apache.
the class VltUtils method getPaths.
public static String[] getPaths(MetaInf metaInf) {
if (metaInf == null) {
return null;
}
WorkspaceFilter filter = metaInf.getFilter();
if (filter == null) {
filter = new DefaultWorkspaceFilter();
}
List<PathFilterSet> filterSets = filter.getFilterSets();
String[] paths = new String[filterSets.size()];
for (int i = 0; i < paths.length; i++) {
paths[i] = filterSets.get(i).getRoot();
}
return paths;
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project acs-aem-commons by Adobe-Consulting-Services.
the class PackageHelperImplTest method testGetPathFilterSetPreviewJSON.
@Test
public void testGetPathFilterSetPreviewJSON() throws Exception {
final List<PathFilterSet> pathFilterSets = new ArrayList<PathFilterSet>();
pathFilterSets.add(new PathFilterSet("/a/b/c"));
pathFilterSets.add(new PathFilterSet("/d/e/f"));
pathFilterSets.add(new PathFilterSet("/g/h/i"));
final String actual = packageHelper.getPathFilterSetPreviewJSON(pathFilterSets);
final JSONObject json = new JSONObject(actual);
assertEquals("preview", json.getString("status"));
assertEquals("Not applicable (Preview)", json.getString("path"));
final String[] expectedFilterSets = new String[] { "/a/b/c", "/d/e/f", "/g/h/i" };
JSONArray actualArray = json.getJSONArray("filterSets");
for (int i = 0; i < actualArray.length(); i++) {
JSONObject tmp = actualArray.getJSONObject(i);
assertTrue(ArrayUtils.contains(expectedFilterSets, tmp.get("rootPath")));
}
assertEquals(expectedFilterSets.length, actualArray.length());
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project acs-aem-commons by Adobe-Consulting-Services.
the class AuthorizablePackagerServletImpl method findPaths.
private List<PathFilterSet> findPaths(final ResourceResolver resourceResolver, final String[] authorizableIds) throws RepositoryException {
final UserManager userManager = resourceResolver.adaptTo(UserManager.class);
final List<PathFilterSet> pathFilterSets = new ArrayList<PathFilterSet>();
for (final String authorizableId : authorizableIds) {
try {
final Authorizable authorizable = userManager.getAuthorizable(authorizableId);
if (authorizable != null) {
final String path = authorizable.getPath();
final PathFilterSet principal = new PathFilterSet(path);
// Exclude tokens as they are not vlt installable in AEM6/Oak
principal.addExclude(new DefaultPathFilter(path + "/\\.tokens"));
pathFilterSets.add(principal);
}
} catch (RepositoryException e) {
log.warn("Unable to find path for authorizable " + authorizableId, e);
}
}
return pathFilterSets;
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project acs-aem-commons by Adobe-Consulting-Services.
the class PackageHelperImpl method getSuccessJSON.
/**
* {@inheritDoc}
*/
public String getSuccessJSON(final JcrPackage jcrPackage) throws JSONException, RepositoryException {
final JSONObject json = new JSONObject();
json.put(KEY_STATUS, "success");
json.put(KEY_PATH, jcrPackage.getNode().getPath());
json.put(KEY_FILTER_SETS, new JSONArray());
final List<PathFilterSet> filterSets = jcrPackage.getDefinition().getMetaInf().getFilter().getFilterSets();
for (final PathFilterSet filterSet : filterSets) {
final JSONObject jsonFilterSet = new JSONObject();
jsonFilterSet.put(KEY_IMPORT_MODE, filterSet.getImportMode().name());
jsonFilterSet.put(KEY_ROOT_PATH, filterSet.getRoot());
json.accumulate(KEY_FILTER_SETS, jsonFilterSet);
}
return json.toString();
}
Aggregations