use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project sling by apache.
the class FileVaultXmlMounter method mount.
/**
* Add configurations to a running OSGi instance for FileVault XML
* @param targetUrl The web console base url
* @param jcrRootFile jcr_root directory
* @param filterXmlFile FileVault Filter XML file
* @throws MojoExecutionException
*/
public void mount(final String targetUrl, final File jcrRootFile, final File filterXmlFile) throws MojoExecutionException {
log.info("Trying to configure file system provider...");
// create config for each path defined in filter
final List<FsResourceConfiguration> cfgs = new ArrayList<>();
WorkspaceFilter workspaceFilter = getWorkspaceFilter(filterXmlFile);
for (PathFilterSet filterSet : workspaceFilter.getFilterSets()) {
cfgs.add(new FsResourceConfiguration().fsMode(FsMode.FILEVAULT_XML).contentRootDir(jcrRootFile.getAbsolutePath()).providerRootPath(filterSet.getRoot()).fileVaultFilterXml(filterXmlFile.getAbsolutePath()));
}
if (!cfgs.isEmpty()) {
helper.addConfigurations(targetUrl, cfgs);
}
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet 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;
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project sling by apache.
the class VltUtilsTest method testEmptyFilter.
@Test
public void testEmptyFilter() throws Exception {
DistributionRequest request = new SimpleDistributionRequest(ADD, true, "/foo");
NavigableMap<String, List<String>> nodeFilters = new TreeMap<String, List<String>>();
NavigableMap<String, List<String>> propFilters = new TreeMap<String, List<String>>();
WorkspaceFilter filter = VltUtils.createFilter(request, nodeFilters, propFilters);
assertNotNull(filter);
assertNotNull(filter.getPropertyFilterSets());
List<PathFilterSet> propFilterSet = filter.getPropertyFilterSets();
assertEquals(1, propFilterSet.size());
PathFilterSet propFilter = propFilterSet.get(0);
assertTrue(propFilter.getEntries().isEmpty());
assertEquals("/", propFilter.getRoot());
assertNotNull(filter.getFilterSets());
List<PathFilterSet> nodeFilterSet = filter.getFilterSets();
assertEquals(1, nodeFilterSet.size());
PathFilterSet nodeFilter = nodeFilterSet.get(0);
assertTrue(nodeFilter.getEntries().isEmpty());
assertEquals("/foo", nodeFilter.getRoot());
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project acs-aem-commons by Adobe-Consulting-Services.
the class AbstractPackagerServlet method getPackagerPageResource.
/**
* Gets the Packager Page resource.
*
* @param request the Sling HTTP Servlet Request object
* @return a the PathFilterSet wrapping the cq:Page or null
*/
protected PathFilterSet getPackagerPageResource(final SlingHttpServletRequest request) {
final ResourceResolver resourceResolver = request.getResourceResolver();
final PageManager pageManager = resourceResolver.adaptTo(PageManager.class);
final Page page = pageManager.getContainingPage(request.getResource());
if (page != null) {
return new PathFilterSet(page.getPath());
}
return null;
}
use of org.apache.jackrabbit.vault.fs.api.PathFilterSet in project acs-aem-commons by Adobe-Consulting-Services.
the class AbstractPackagerServlet method doPackaging.
protected void doPackaging(SlingHttpServletRequest request, SlingHttpServletResponse response, boolean preview, ValueMap properties, List<PathFilterSet> packageResources) throws IOException, JSONException, RepositoryException {
// Add the ACL Packager Configuration page
if (properties.get(INCLUDE_CONFIGURATION, DEFAULT_INCLUDE_CONFIGURATION)) {
final PathFilterSet tmp = this.getPackagerPageResource(request);
if (tmp != null) {
packageResources.add(tmp);
}
}
final Map<String, String> packageDefinitionProperties = new HashMap<String, String>();
// ACL Handling
packageDefinitionProperties.put(JcrPackageDefinition.PN_AC_HANDLING, properties.get(PACKAGE_ACL_HANDLING, AccessControlHandling.OVERWRITE.toString()));
// Package Description
packageDefinitionProperties.put(JcrPackageDefinition.PN_DESCRIPTION, properties.get(PACKAGE_DESCRIPTION, getDefaultPackageDescription()));
if (preview) {
// Handle preview mode
response.getWriter().print(getPackageHelper().getPathFilterSetPreviewJSON(packageResources));
} else if (packageResources == null || packageResources.isEmpty()) {
// Do not create empty packages; This will only clutter up CRX Package Manager
response.getWriter().print(getPackageHelper().getErrorJSON("Refusing to create a package with no filter " + "set rules."));
} else {
// Create JCR Package; Defaults should always be passed in via Request Parameters, but just in case
final JcrPackage jcrPackage = getPackageHelper().createPackageFromPathFilterSets(packageResources, request.getResourceResolver().adaptTo(Session.class), properties.get(PACKAGE_GROUP_NAME, getDefaultPackageGroupName()), properties.get(PACKAGE_NAME, getDefaultPackageName()), properties.get(PACKAGE_VERSION, DEFAULT_PACKAGE_VERSION), PackageHelper.ConflictResolution.valueOf(properties.get(CONFLICT_RESOLUTION, PackageHelper.ConflictResolution.IncrementVersion.toString())), packageDefinitionProperties);
String thumbnailPath = getPackageThumbnailPath();
if (thumbnailPath != null) {
// Add thumbnail to the package definition
getPackageHelper().addThumbnail(jcrPackage, request.getResourceResolver().getResource(thumbnailPath));
}
log.debug("Successfully created JCR package");
response.getWriter().print(getPackageHelper().getSuccessJSON(jcrPackage));
}
}
Aggregations