public Enumeration entries()

in src/main/java/com/googlesource/gerrit/plugins/web/WebPluginScanner.java [99:127]


  public Enumeration<PluginEntry> entries() {
    final List<PluginEntry> resourcesList = Lists.newArrayList();
    try {
      Files.walkFileTree(
          staticResourcesPath,
          EnumSet.of(FileVisitOption.FOLLOW_LINKS),
          Integer.MAX_VALUE,
          new SimpleFileVisitor<Path>() {
            private int basicPathLength = staticResourcesPath.toAbsolutePath().toString().length();

            @Override
            public FileVisitResult visitFile(Path path, BasicFileAttributes attrs)
                throws IOException {
              Optional<PluginEntry> resource = resourceOf(relativePathOf(path));
              if (resource.isPresent()) {
                resourcesList.add(resource.get());
              }
              return FileVisitResult.CONTINUE;
            }

            private String relativePathOf(Path path) {
              return path.toFile().getAbsolutePath().substring(basicPathLength);
            }
          });
    } catch (IOException e) {
      throw new IllegalArgumentException("Cannot scan resource files in plugin", e);
    }
    return Collections.enumeration(resourcesList);
  }