use of org.apache.jackrabbit.vault.fs.api.WorkspaceFilter 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.WorkspaceFilter 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.WorkspaceFilter in project sling by apache.
the class FileVaultContentSerializer method exportToStream.
@Override
public void exportToStream(ResourceResolver resourceResolver, DistributionExportOptions exportOptions, OutputStream outputStream) throws DistributionException {
Session session = null;
try {
session = getSession(resourceResolver);
String packageGroup = PACKAGE_GROUP;
String packageName = TYPE + "_" + System.currentTimeMillis() + "_" + UUID.randomUUID();
WorkspaceFilter filter = VltUtils.createFilter(exportOptions.getRequest(), nodeFilters, propertyFilters);
ExportOptions opts = VltUtils.getExportOptions(filter, packageRoots, packageGroup, packageName, VERSION, useBinaryReferences);
log.debug("assembling package {} user {}", packageGroup + '/' + packageName + "-" + VERSION, resourceResolver.getUserID());
packaging.getPackageManager().assemble(session, opts, outputStream);
} catch (Exception e) {
throw new DistributionException(e);
} finally {
ungetSession(session);
}
}
use of org.apache.jackrabbit.vault.fs.api.WorkspaceFilter 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.WorkspaceFilter 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);
}
}
Aggregations