Search in sources :

Example 1 with DefaultPathFilter

use of org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter 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;
}
Also used : PathFilterSet(org.apache.jackrabbit.vault.fs.api.PathFilterSet) UserManager(org.apache.jackrabbit.api.security.user.UserManager) ArrayList(java.util.ArrayList) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) RepositoryException(javax.jcr.RepositoryException) DefaultPathFilter(org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter)

Example 2 with DefaultPathFilter

use of org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter in project sling by apache.

the class VltUtils method createFilter.

public static WorkspaceFilter createFilter(DistributionRequest distributionRequest, NavigableMap<String, List<String>> nodeFilters, NavigableMap<String, List<String>> propertyFilters) {
    DefaultWorkspaceFilter filter = new DefaultWorkspaceFilter();
    for (String path : distributionRequest.getPaths()) {
        // Set node path filters
        List<String> patterns = new ArrayList<String>();
        patterns.addAll(Arrays.asList(distributionRequest.getFilters(path)));
        boolean deep = distributionRequest.isDeep(path);
        PathFilterSet nodeFilterSet = new PathFilterSet(path);
        if (!deep) {
            nodeFilterSet.addInclude(new DefaultPathFilter(path));
        }
        initFilterSet(nodeFilterSet, nodeFilters, patterns);
        filter.add(nodeFilterSet);
        // Set property path filters
        PathFilterSet propertyFilterSet = new PathFilterSet("/");
        initFilterSet(propertyFilterSet, propertyFilters, new ArrayList<String>());
        filter.addPropertyFilterSet(propertyFilterSet);
    }
    return filter;
}
Also used : DefaultWorkspaceFilter(org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter) PathFilterSet(org.apache.jackrabbit.vault.fs.api.PathFilterSet) ArrayList(java.util.ArrayList) DefaultPathFilter(org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter)

Example 3 with DefaultPathFilter

use of org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter in project acs-aem-commons by Adobe-Consulting-Services.

the class ACLPackagerServletImpl method getPrincipalResources.

/**
 * Gets the resources for the param principals.
 *
 * @param resourceResolver the ResourceResolver obj to get the principal resources;
 *                         Must have read access to the principal resources.
 * @param principalNames   the principals to get
 * @return a list of PathFilterSets covering the selectes principal names (if they exist)
 * @throws RepositoryException
 */
private List<PathFilterSet> getPrincipalResources(final ResourceResolver resourceResolver, final String[] principalNames) throws RepositoryException {
    final UserManager userManager = resourceResolver.adaptTo(UserManager.class);
    final List<PathFilterSet> pathFilterSets = new ArrayList<PathFilterSet>();
    for (final String principalName : principalNames) {
        final Authorizable authorizable = userManager.getAuthorizable(principalName);
        if (authorizable != null) {
            final Resource resource = resourceResolver.getResource(authorizable.getPath());
            if (resource != null) {
                final PathFilterSet principal = new PathFilterSet(resource.getPath());
                // Exclude tokens as they are not vlt installable in AEM6/Oak
                principal.addExclude(new DefaultPathFilter(resource.getPath() + "/\\.tokens"));
                pathFilterSets.add(principal);
            }
        }
    }
    return pathFilterSets;
}
Also used : PathFilterSet(org.apache.jackrabbit.vault.fs.api.PathFilterSet) UserManager(org.apache.jackrabbit.api.security.user.UserManager) ArrayList(java.util.ArrayList) Resource(org.apache.sling.api.resource.Resource) Authorizable(org.apache.jackrabbit.api.security.user.Authorizable) DefaultPathFilter(org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter)

Aggregations

ArrayList (java.util.ArrayList)3 PathFilterSet (org.apache.jackrabbit.vault.fs.api.PathFilterSet)3 DefaultPathFilter (org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter)3 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)2 UserManager (org.apache.jackrabbit.api.security.user.UserManager)2 RepositoryException (javax.jcr.RepositoryException)1 DefaultWorkspaceFilter (org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter)1 Resource (org.apache.sling.api.resource.Resource)1