public ClassPathCatalogReader()

in log4j-catalog/log4j-catalog-api/src/main/java/org/apache/logging/log4j/catalog/api/dao/ClassPathCatalogReader.java [51:79]


    public ClassPathCatalogReader(Map<String, String> attributes) throws IOException {
        String catalogFile = attributes != null ?
            attributes.getOrDefault(CATALOG_ATTRIBUTE_NAME, DEFAULT_CATALOG_FILE) : DEFAULT_CATALOG_FILE;
        Collection<URL> catalogs = LoaderUtil.findResources(catalogFile);
        if (catalogs.isEmpty()) {
            LOGGER.error("No catalog named {} could be found on the class path", catalogFile);
            throw new FileNotFoundException("No catalog named " + catalogFile + " could be found");
        }

        URL catalogURL = catalogs.iterator().next();
        if (catalogs.size() > 1) {
            LOGGER.warn("Multiple catalogs named {} were found. Using {}", catalogFile, catalogURL.toString());
        }

        catalog = readCatalog(catalogURL);
        LocalDateTime localDateTime = null;
        try {
            URLConnection connection = catalogURL.openConnection();
            localDateTime = LocalDateTime.ofInstant(Instant.ofEpochMilli(connection.getLastModified()),
                    ZoneId.systemDefault());
        } catch (IOException ioe) {
            LOGGER.warn("Unable to open connection to {}", catalogURL.toString());
        }
        lastUpdated = localDateTime;
        JsonFactory factory = new JsonFactory();
        factory.enable(JsonParser.Feature.ALLOW_COMMENTS);
        ObjectMapper objectMapper = new ObjectMapper(factory);
        catalogData = objectMapper.readValue(catalog, CatalogData.class);
    }