class ImageService {

    public Image getImage(ImageSettingsRequest imageSettings, String region, String platform) {
        String imageId = imageSettings.getId();
        String catalogUrl = Objects.nonNull(imageSettings.getCatalog()) ? imageSettings.getCatalog() : defaultCatalogUrl;
        String imageOs = Objects.nonNull(imageSettings.getOs()) ? imageSettings.getOs() : defaultOs;

        ImageCatalog cachedImageCatalog = imageCatalogProvider.getImageCatalog(catalogUrl);
        return findImageForAppVersion(region, platform, imageId, imageOs, cachedImageCatalog)
                .or(() -> retryAfterEvictingCache(region, platform, imageId, catalogUrl, imageOs))
                .orElseThrow(() -> throwImageNotFoundException(region, imageId, imageOs));
    }

}