private String loadTemplate()

in geronimo-microprofile-reporter/src/main/java/org/apache/geronimo/microprofile/reporter/storage/front/HtmlWriter.java [79:95]


    private String loadTemplate(final String template) {
        return Stream.of("geronimo/microprofile/reporter/" + template, template)
                .flatMap(it -> Stream.of(it, '/' + it))
                .map(it -> {
                    try (final InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(it)) {
                        if (stream == null) {
                            return null;
                        }
                        return new BufferedReader(new InputStreamReader(stream)).lines().collect(joining("\n"));
                    } catch (final IOException e) {
                        throw new InternalServerErrorException(e);
                    }
                })
                .filter(Objects::nonNull)
                .findFirst()
                .orElseThrow(() -> new InternalServerErrorException("Missing template: " + template));
    }