From 5a33b439d9a894dde40c504259bc29ee3e3048bb Mon Sep 17 00:00:00 2001 From: Benaissa BENARBIA Date: Thu, 9 Nov 2023 17:03:33 +0100 Subject: [PATCH] feature/vas-11915: update log level in the case of not found file --- .../commons/api/utils/OntologyServiceReader.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/utils/OntologyServiceReader.java b/commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/utils/OntologyServiceReader.java index fe77824f924..903d81931ed 100644 --- a/commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/utils/OntologyServiceReader.java +++ b/commons/commons-api/src/main/java/fr/gouv/vitamui/commons/api/utils/OntologyServiceReader.java @@ -41,7 +41,6 @@ import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -55,13 +54,13 @@ public class OntologyServiceReader { private static final ObjectMapper objectMapper = new ObjectMapper(); - public static List readExternalOntologiesFromFile(Integer tenantId, String ontologiesFilePath) + public static List readExternalOntologiesFromFile(Integer tenantId, String ontologiesFilePath) throws IOException { - List ontologyDtoList = new ArrayList<>(); + List ontologyDtoList; LOGGER.debug("Read ontologies list from file {} for tenant {}", ontologiesFilePath, tenantId); - File file = new File( ontologiesFilePath); + File file = new File(ontologiesFilePath); StringBuilder resultStringBuilder = new StringBuilder(); try (BufferedReader bufferedReader @@ -71,18 +70,19 @@ public static List readExternalOntologiesFromFile(Integer te resultStringBuilder.append(line).append("\n"); } } catch (FileNotFoundException notFoundException) { - LOGGER.error("Can not find the ontologies list file {} ", notFoundException); + LOGGER.info("No external ontologies file provided "); return Collections.emptyList(); } try { ontologyDtoList = objectMapper.readValue(resultStringBuilder.toString(), new TypeReference<>() { }); } catch (JsonProcessingException exception) { - LOGGER.error("Can not parse the ontologies file{}", exception); + LOGGER.error("Can not parse the ontologies file {}", ontologiesFilePath); return Collections.emptyList(); } - return ontologyDtoList.stream().filter(ontologyDto -> ontologyDto.getTenantIds().contains(DEFAULT_TENANT_IDENTIFIER) || + return ontologyDtoList.stream() + .filter(ontologyDto -> ontologyDto.getTenantIds().contains(DEFAULT_TENANT_IDENTIFIER) || ontologyDto.getTenantIds().contains(tenantId)) .collect(Collectors.toList()); } @@ -94,7 +94,7 @@ public static List readInternalOntologyFromFile(String inter List internalOntologyDtoList; LOGGER.debug("Read internal ontology fields list from file : {} ", internalOntologyFilePath); - File file = new File( internalOntologyFilePath); + File file = new File(internalOntologyFilePath); StringBuilder resultStringBuilder = new StringBuilder(); try (BufferedReader bufferedReader