public FileCatalogReader()

in log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/dao/FileCatalogReader.java [49:83]


    public FileCatalogReader(Map<String, String> attributes) throws IOException {
        StringBuilder catalogPath = new StringBuilder();
        String basePath = attributes.get(BASEDIR);
        String catalogFile = attributes.getOrDefault(CATALOG_ATTRIBUTE_NAME, DEFAULT_CATALOG_FILE);
        if (basePath != null) {
            catalogPath.append(attributes.get(BASEDIR));
            if (basePath.endsWith("/")) {
                if (catalogFile.startsWith("/")) {
                    catalogPath.append(catalogFile.substring(1));
                } else {
                    catalogPath.append(catalogFile);
                }
            } else {
                if (catalogFile.startsWith("/")) {
                    catalogPath.append(catalogFile);
                } else {
                    catalogPath.append("/").append(catalogFile);
                }
            }
        } else if (catalogFile != null){
            catalogPath.append(catalogFile);
        } else {
            LOGGER.warn("No catalogFile attribute was provided. Using {}", DEFAULT_CATALOG_FILE);
            catalogPath.append(DEFAULT_CATALOG_FILE);
        }
        Path path = Paths.get(catalogPath.toString());
        lastUpdated = LocalDateTime.ofInstant(Instant.ofEpochMilli(path.toFile().lastModified()),
                ZoneId.systemDefault());
        byte[] encoded = Files.readAllBytes(path);
        catalog = new String(encoded, StandardCharsets.UTF_8);
        JsonFactory factory = new JsonFactory();
        factory.enable(JsonParser.Feature.ALLOW_COMMENTS);
        ObjectMapper objectMapper = new ObjectMapper(factory);
        catalogData = objectMapper.readValue(catalog, CatalogData.class);
    }