From 5ca7f96371619fd82f8dca19f02fa9c068db63ec Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 10 Dec 2020 00:17:28 +0100 Subject: [PATCH] Fixed service not found in cache. --- src/fr/devinsy/statoolinfos/core/Factory.java | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Factory.java b/src/fr/devinsy/statoolinfos/core/Factory.java index 06873b8..bd5841d 100644 --- a/src/fr/devinsy/statoolinfos/core/Factory.java +++ b/src/fr/devinsy/statoolinfos/core/Factory.java @@ -259,9 +259,12 @@ public class Factory { URL serviceInputURL = new URL(property.getValue()); Service service = loadService(serviceInputURL, cache); - service.setOrganization(result); - service.setLogoFileName(result.getTechnicalName() + "-" + service.getLogoFileName()); - result.getServices().add(service); + if (service != null) + { + service.setOrganization(result); + service.setLogoFileName(result.getTechnicalName() + "-" + service.getLogoFileName()); + result.getServices().add(service); + } } } } @@ -282,11 +285,19 @@ public class Factory File inputFile = cache.restoreFile(inputURL); - PathProperties properties = PathPropertyUtils.load(inputFile); - result = new Service(properties); - result.setInputFile(inputFile); - result.setInputURL(inputURL); - result.setLogoFileName(result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png")); + if (inputFile == null) + { + logger.warn("WARNING: service not found in cache [{}]", inputURL); + result = null; + } + else + { + PathProperties properties = PathPropertyUtils.load(inputFile); + result = new Service(properties); + result.setInputFile(inputFile); + result.setInputURL(inputURL); + result.setLogoFileName(result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png")); + } // return result;