Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/vas-11915: update log level in the case of not found file #1532

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -55,13 +54,13 @@ public class OntologyServiceReader {

private static final ObjectMapper objectMapper = new ObjectMapper();

public static List<VitamUiOntologyDto> readExternalOntologiesFromFile(Integer tenantId, String ontologiesFilePath)
public static List<VitamUiOntologyDto> readExternalOntologiesFromFile(Integer tenantId, String ontologiesFilePath)
throws IOException {

List<VitamUiOntologyDto> ontologyDtoList = new ArrayList<>();
List<VitamUiOntologyDto> 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
Expand All @@ -71,18 +70,19 @@ public static List<VitamUiOntologyDto> 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());
}
Expand All @@ -94,7 +94,7 @@ public static List<VitamUiOntologyDto> readInternalOntologyFromFile(String inter
List<VitamUiOntologyDto> 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
Expand Down