Search in sources :

Example 1 with DefaultWorkspaceFilter

use of org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter 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;
}
Also used : DefaultWorkspaceFilter(org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter) PathFilterSet(org.apache.jackrabbit.vault.fs.api.PathFilterSet) DefaultWorkspaceFilter(org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter) WorkspaceFilter(org.apache.jackrabbit.vault.fs.api.WorkspaceFilter)

Example 2 with DefaultWorkspaceFilter

use of org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter in project sling by apache.

the class VaultFsLocatorImpl method getFileSystem.

@Override
public VaultFileSystem getFileSystem(RepositoryAddress repositoryAddress, File contentSyncRoot, Session session) throws RepositoryException, IOException, ConfigurationException {
    // TODO - should not use File to read from FS, rather input streams
    VaultFsConfig config = null;
    DefaultWorkspaceFilter filter = null;
    File filterFile = findFilterFile(contentSyncRoot);
    if (filterFile != null) {
        filter = new DefaultWorkspaceFilter();
        filter.load(filterFile);
    }
    File metaInfDir = new File(contentSyncRoot.getParent(), Constants.META_INF);
    if (metaInfDir.isDirectory()) {
        File vaultDir = new File(metaInfDir, Constants.VAULT_DIR);
        if (vaultDir.isDirectory()) {
            File configFile = new File(vaultDir, Constants.CONFIG_XML);
            if (configFile.exists()) {
                config = AbstractVaultFsConfig.load(configFile);
            }
        }
    }
    return Mounter.mount(config, filter, repositoryAddress, "/", session);
}
Also used : DefaultWorkspaceFilter(org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter) VaultFsConfig(org.apache.jackrabbit.vault.fs.api.VaultFsConfig) AbstractVaultFsConfig(org.apache.jackrabbit.vault.fs.config.AbstractVaultFsConfig) File(java.io.File)

Example 3 with DefaultWorkspaceFilter

use of org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter in project sling by apache.

the class FileVaultResourceMapper method getWorkspaceFilter.

/**
     * @return Workspace filter or null if none found.
     */
private WorkspaceFilter getWorkspaceFilter() {
    if (filterXmlFile != null && filterXmlFile.exists()) {
        try {
            DefaultWorkspaceFilter workspaceFilter = new DefaultWorkspaceFilter();
            workspaceFilter.load(filterXmlFile);
            return workspaceFilter;
        } catch (IOException | ConfigurationException ex) {
            log.error("Unable to parse workspace filter: " + filterXmlFile.getPath(), ex);
        }
    } else {
        log.debug("Workspace filter not found: " + filterXmlFile.getPath());
    }
    return null;
}
Also used : DefaultWorkspaceFilter(org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter) ConfigurationException(org.apache.jackrabbit.vault.fs.config.ConfigurationException) IOException(java.io.IOException)

Example 4 with DefaultWorkspaceFilter

use of org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter 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 5 with DefaultWorkspaceFilter

use of org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter in project sling by apache.

the class FileVaultXmlMounter method getWorkspaceFilter.

private WorkspaceFilter getWorkspaceFilter(final File filterXmlFile) throws MojoExecutionException {
    try {
        DefaultWorkspaceFilter workspaceFilter = new DefaultWorkspaceFilter();
        workspaceFilter.load(filterXmlFile);
        return workspaceFilter;
    } catch (IOException | ConfigurationException ex) {
        throw new MojoExecutionException("Unable to parse workspace filter: " + filterXmlFile.getPath(), ex);
    }
}
Also used : DefaultWorkspaceFilter(org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ConfigurationException(org.apache.jackrabbit.vault.fs.config.ConfigurationException) IOException(java.io.IOException)

Aggregations

DefaultWorkspaceFilter (org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter)5 IOException (java.io.IOException)2 PathFilterSet (org.apache.jackrabbit.vault.fs.api.PathFilterSet)2 ConfigurationException (org.apache.jackrabbit.vault.fs.config.ConfigurationException)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 VaultFsConfig (org.apache.jackrabbit.vault.fs.api.VaultFsConfig)1 WorkspaceFilter (org.apache.jackrabbit.vault.fs.api.WorkspaceFilter)1 AbstractVaultFsConfig (org.apache.jackrabbit.vault.fs.config.AbstractVaultFsConfig)1 DefaultPathFilter (org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1