Search in sources :

Example 1 with LinkedMetaInfFolderFilter

use of org.guvnor.common.services.backend.file.LinkedMetaInfFolderFilter in project drools-wb by kiegroup.

the class ScenarioLoader method loadScenarioPaths.

private List<Path> loadScenarioPaths(final Path path) {
    // Check Path exists
    final List<Path> items = new ArrayList<Path>();
    if (!Files.exists(Paths.convert(path))) {
        return items;
    }
    // Ensure Path represents a Folder
    org.uberfire.java.nio.file.Path pPath = Paths.convert(path);
    if (!Files.isDirectory(pPath)) {
        pPath = pPath.getParent();
    }
    LinkedFilter filter = new LinkedDotFileFilter();
    LinkedFilter metaInfFolderFilter = new LinkedMetaInfFolderFilter();
    filter.setNextFilter(metaInfFolderFilter);
    FileExtensionFilter fileExtensionFilter = new FileExtensionFilter(".scenario");
    // Get list of immediate children
    final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream = ioService.newDirectoryStream(pPath);
    for (final org.uberfire.java.nio.file.Path p : directoryStream) {
        if (filter.accept(p) && fileExtensionFilter.accept(p)) {
            if (Files.isRegularFile(p)) {
                items.add(Paths.convert(p));
            } else if (Files.isDirectory(p)) {
                items.add(Paths.convert(p));
            }
        }
    }
    return items;
}
Also used : Path(org.uberfire.backend.vfs.Path) ArrayList(java.util.ArrayList) LinkedDotFileFilter(org.guvnor.common.services.backend.file.LinkedDotFileFilter) LinkedMetaInfFolderFilter(org.guvnor.common.services.backend.file.LinkedMetaInfFolderFilter) LinkedFilter(org.guvnor.common.services.backend.file.LinkedFilter) FileExtensionFilter(org.guvnor.common.services.backend.file.FileExtensionFilter)

Aggregations

ArrayList (java.util.ArrayList)1 FileExtensionFilter (org.guvnor.common.services.backend.file.FileExtensionFilter)1 LinkedDotFileFilter (org.guvnor.common.services.backend.file.LinkedDotFileFilter)1 LinkedFilter (org.guvnor.common.services.backend.file.LinkedFilter)1 LinkedMetaInfFolderFilter (org.guvnor.common.services.backend.file.LinkedMetaInfFolderFilter)1 Path (org.uberfire.backend.vfs.Path)1