class ImageCatalogProvider {

    @Cacheable(cacheNames = "imageCatalogCache", key = "#catalogUrl")
    public ImageCatalog getImageCatalog(String catalogUrl)  {
        ImageCatalog catalog;
        if (catalogUrl == null) {
            LOGGER.info("No image catalog was defined!");
            return null;
        }

        try {
            long started = System.currentTimeMillis();
            String content;
            if (catalogUrl.startsWith("http")) {
                Client client = RestClientUtil.get();
                WebTarget target = client.target(catalogUrl);
                Response response = target.request().get();
                content = readResponse(target, response);
            } else {
                content = readCatalogFromFile(catalogUrl);
            }
            catalog = filterImagesByOsType(objectMapper.readValue(content, ImageCatalog.class));
            long timeOfParse = System.currentTimeMillis() - started;
            LOGGER.debug("ImageCatalog was fetched and parsed from '{}' and took '{}' ms.", catalogUrl, timeOfParse);
        } catch (RuntimeException e) {
            throw new ImageCatalogException(String.format("Failed to get image catalog: %s from %s", e.getCause(), catalogUrl), e);
        } catch (JsonMappingException e) {
            throw new ImageCatalogException(String.format("Invalid json format for image catalog with error: %s", e.getMessage()), e);
        } catch (IOException e) {
            throw new ImageCatalogException(String.format("Failed to read image catalog from file: '%s'", catalogUrl), e);
        }
        return catalog;
    }

}