org.uberfire.java.nio.file.DirectoryStream类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(158)

本文整理了Java中org.uberfire.java.nio.file.DirectoryStream类的一些代码示例,展示了DirectoryStream类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DirectoryStream类的具体详情如下:
包路径:org.uberfire.java.nio.file.DirectoryStream
类名称:DirectoryStream

DirectoryStream介绍

暂无

代码示例

代码示例来源:origin: org.kie.workbench.services/kie-wb-common-data-modeller-core

public boolean isEmpty(final IOService ioService, Path dirPath) throws IOException {
  if (dirPath == null) return true;
  final DirectoryStream<Path> children = ioService.newDirectoryStream(dirPath);
  if (children == null) return true;
  Iterator<Path> iterator = children.iterator();
  return iterator == null || !iterator.hasNext();
}

代码示例来源:origin: org.uberfire/uberfire-project-backend

private void lookForModulesFromFolders(final Path folderPath) {
  final DirectoryStream<Path> nioRepositoryPaths = ioService.newDirectoryStream(folderPath);
  try {
    for (final Path nioRepositoryPath : nioRepositoryPaths) {
      if (Files.isDirectory(nioRepositoryPath)) {
        findModule(nioRepositoryPath,
              false);
      }
    }
  } finally {
    nioRepositoryPaths.close();
  }
}

代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-datasource-mgmt-backend

private Collection<DriverDefInfo> resolveDrivers(final Path path) {
  final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
  final List<DriverDefInfo> result = new ArrayList<>();
  try {
    final DirectoryStream<org.uberfire.java.nio.file.Path> stream = ioService.newDirectoryStream(nioPath,
                                                   entry -> Files.isRegularFile(entry) &&
                                                       !entry.getFileName().toString().startsWith(".") &&
                                                       entry.getFileName().toString().endsWith(DRIVER_FILE_TYPE));
    stream.forEach(file -> {
      result.add(createDriverInfo(file));
    });
    stream.close();
    return result;
  } catch (Exception e) {
    logger.error("It was not possible read drivers info from: " + path,
           e);
    throw ExceptionUtilities.handleException(e);
  }
}

代码示例来源:origin: org.uberfire/uberfire-nio2-fs

assertThatThrownBy(() -> stream.iterator().next())
    .isInstanceOf(NoSuchElementException.class);
final Iterator<Path> iterator = stream2.iterator();
iterator.next();
assertThatThrownBy(() -> iterator.remove())
    .isInstanceOf(UnsupportedOperationException.class);
stream2.close();
assertThatThrownBy(() -> stream2.close())
    .isInstanceOf(org.uberfire.java.nio.IOException.class)
    .hasMessage("This stream is closed.");
                    path2);
stream3.close();
assertThatThrownBy(() -> stream3.iterator().next())
    .isInstanceOf(org.uberfire.java.nio.IOException.class)
    .hasMessage("This stream is closed.");

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@Override
  public ProjectType getProjectType(Path projectRootPath) {
    try (DirectoryStream<org.uberfire.java.nio.file.Path> paths =
           ioService.newDirectoryStream(Paths.convert(projectRootPath), f -> f.getFileName().toString().startsWith("."))) {
      return ProjectType.fromFileName(StreamSupport.stream(paths.spliterator(), false)
                          .map(Paths::convert)
                          .map(Path::getFileName)
                          .findFirst()
      ).orElse(null);
    }
  }
}

代码示例来源:origin: kiegroup/drools-wb

@Override
public void postProcess(final Path source,
            final Path destination) {
  try (DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream =
         ioService.newDirectoryStream(getParentFolder(source),
                       new FileExtensionFilter(dtableGraphType.getSuffix()))) {
    directoryStream.forEach((path) -> updateGraphElementPath(source,
                                 destination,
                                 Paths.convert(path)));
  }
}

代码示例来源:origin: kiegroup/appformer

assertThatThrownBy(() -> stream.iterator().next())
    .isInstanceOf(NoSuchElementException.class);
final Iterator<Path> iterator = stream2.iterator();
iterator.next();
assertThatThrownBy(() -> iterator.remove())
    .isInstanceOf(UnsupportedOperationException.class);
stream2.close();
assertThatThrownBy(() -> stream2.close())
    .isInstanceOf(org.uberfire.java.nio.IOException.class)
    .hasMessage("This stream is closed.");
                    path2);
stream3.close();
assertThatThrownBy(() -> stream3.iterator().next())
    .isInstanceOf(org.uberfire.java.nio.IOException.class)
    .hasMessage("This stream is closed.");

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@Before
public void setUp() throws Exception {
  ArgumentCaptor<DirectoryStream.Filter> filter = ArgumentCaptor.forClass(DirectoryStream.Filter.class);
  when(ioService.newDirectoryStream(any(), filter.capture())).thenReturn(directoryStream);
  when(directoryStream.spliterator()).thenReturn(Arrays.asList(fsPath).spliterator());
  when(projectPath.toURI()).thenReturn(DIR_URI);
  when(fsPath.getFileName()).thenReturn(fileName);
  when(fsPath.toUri()).thenReturn(new URI(FILE_URI));
  when(fsPath.getFileSystem()).thenReturn(fs);
  when(fileName.toString()).thenReturn(FILE_NAME);
  tested = new BPMNDiagramServiceImpl(ioService);
}

代码示例来源:origin: kiegroup/drools-wb

@Override
public void postProcess(final Path path) {
  try (final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream =
         ioService.newDirectoryStream(getParentFolder(path),
                       new FileExtensionFilter(dtableGraphType.getSuffix()))) {
    directoryStream.forEach((p) -> updateGraphReferences(path,
                               Paths.convert(p)));
  }
}

代码示例来源:origin: kiegroup/jbpm-wb

protected boolean isCaseProject(Path rootProjectPath) {

    org.uberfire.java.nio.file.DirectoryStream<Path> found = ioService.newDirectoryStream(rootProjectPath,
                                               f -> f.endsWith(CASE_PROJECT_DOT_FILE));
    return found.iterator().hasNext();
  }
}

代码示例来源:origin: kiegroup/appformer

private void lookForModulesFromFolders(final Path folderPath) {
  final DirectoryStream<Path> nioRepositoryPaths = ioService.newDirectoryStream(folderPath);
  try {
    for (final Path nioRepositoryPath : nioRepositoryPaths) {
      if (Files.isDirectory(nioRepositoryPath)) {
        findModule(nioRepositoryPath,
              false);
      }
    }
  } finally {
    nioRepositoryPaths.close();
  }
}

代码示例来源:origin: org.kie.workbench.screens/kie-wb-common-datasource-mgmt-backend

private Collection<DataSourceDefInfo> resolveDataSources(final Path path) {
  final org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
  final List<DataSourceDefInfo> result = new ArrayList<>();
  try {
    final DirectoryStream<org.uberfire.java.nio.file.Path> stream = ioService.newDirectoryStream(nioPath,
                                                   entry -> Files.isRegularFile(entry) &&
                                                       !entry.getFileName().toString().startsWith(".") &&
                                                       entry.getFileName().toString().endsWith(DS_FILE_TYPE));
    stream.forEach(file -> {
      result.add(createDataSourceDefInfo(file));
    });
    stream.close();
    return result;
  } catch (Exception e) {
    logger.error("It was not possible read data sources info from: " + path,
           e);
    throw ExceptionUtilities.handleException(e);
  }
}

代码示例来源:origin: org.kie.workbench.stunner/kie-wb-common-stunner-bpmn-backend

@Test
  public void getProjectTypeNull() {
    when(directoryStream.spliterator()).thenReturn(Collections.<Path>emptyList().spliterator());
    final ProjectType projectType = tested.getProjectType(projectPath);
    assertEquals(projectType, null);
  }
}

代码示例来源:origin: kiegroup/drools-wb

private void updateGraphElementPaths(final Path source,
                   final Path destination) {
  try (final DirectoryStream<org.uberfire.java.nio.file.Path> directoryStream =
         ioService.newDirectoryStream(getParentFolder(source),
                       new FileExtensionFilter(dtableGraphType.getSuffix()))) {
    directoryStream.forEach((path) -> updateGraphElementPath(source,
                                 destination,
                                 Paths.convert(path)));
  }
}

代码示例来源:origin: org.uberfire/uberfire-metadata-commons-io

private boolean hasContent(Path dir) {
  // TODO remove this filter when AF-1073 is resolved
  try (DirectoryStream<Path> children = newDirectoryStream(dir, path -> !path.endsWith("readme.md"))) {
    return children.iterator().hasNext();
  }
}

代码示例来源:origin: org.guvnor/guvnor-project-backend

public Set<Project> getProjects(final Repository repository,
                String branch,
                boolean secure) {
  final Set<Project> authorizedProjects = new HashSet<Project>();
  if (repository == null) {
    return authorizedProjects;
  }
  final Path repositoryRoot = repository.getBranchRoot(branch);
  final DirectoryStream<org.uberfire.java.nio.file.Path> nioRepositoryPaths = ioService.newDirectoryStream(Paths.convert(repositoryRoot));
  try {
    for (org.uberfire.java.nio.file.Path nioRepositoryPath : nioRepositoryPaths) {
      if (Files.isDirectory(nioRepositoryPath)) {
        final org.uberfire.backend.vfs.Path projectPath = Paths.convert(nioRepositoryPath);
        final Project project = resourceResolver.resolveProject(projectPath);
        if (project != null) {
          if (!secure || authorizationManager.authorize(project,
                                 sessionInfo.getIdentity())) {
            POM projectPom = pomService.load(project.getPomXMLPath());
            project.setPom(projectPom);
            authorizedProjects.add(project);
          }
        }
      }
    }
  } finally {
    nioRepositoryPaths.close();
  }
  return authorizedProjects;
}

代码示例来源:origin: org.jbpm/jbpm-wb-integration-backend

protected boolean isCaseProject(Path rootProjectPath) {

    org.uberfire.java.nio.file.DirectoryStream<Path> found = ioService.newDirectoryStream(rootProjectPath,
                                               f -> f.endsWith(CASE_PROJECT_DOT_FILE));
    return found.iterator().hasNext();
  }
}

代码示例来源:origin: org.uberfire/vfs-api

stream.close();
} catch (IOException ex) {
  if (postException == null) {

代码示例来源:origin: kiegroup/appformer

@Override
public List<Path> listFiles() {
  final DirectoryStream<org.uberfire.java.nio.file.Path> stream = ioService.newDirectoryStream(root,
                                                 new DirectoryStream.Filter<org.uberfire.java.nio.file.Path>() {
                                                   @Override
                                                   public boolean accept(org.uberfire.java.nio.file.Path entry) throws IOException {
                                                     return typeDefinition.accept(Paths.convert(entry));
                                                   }
                                                 });
  final List<Path> files = new ArrayList<Path>();
  final Iterator<org.uberfire.java.nio.file.Path> itr = stream.iterator();
  while (itr.hasNext()) {
    files.add(Paths.convert(itr.next()));
  }
  return files;
}

代码示例来源:origin: org.uberfire/uberfire-nio2-api

stream.close();
} catch (IOException ex) {
  if (postException == null) {

相关文章