From 15252c777904d7e0a4e5664911e921e6410c12ae Mon Sep 17 00:00:00 2001 From: Github Action Date: Mon, 25 Nov 2024 13:21:32 +0000 Subject: [PATCH 1/4] Version 1.0.4-SNAPSHOT [skip ci] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d755965..03c6633 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ fr.abes kbart2kafka - 1.0.3 + 1.0.4-SNAPSHOT jar kbart2kafka chargement d'un fichier kbart dans kafka From 1f7a6316b3a5e34bf898aa4f1a8b343e380b2b01 Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Thu, 28 Nov 2024 09:48:06 +0100 Subject: [PATCH 2/4] fix detect tab sur last ligne --- .../java/fr/abes/kbart2kafka/utils/CheckFiles.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java b/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java index 668840f..9cdad80 100644 --- a/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java +++ b/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java @@ -11,6 +11,7 @@ import java.nio.charset.CharacterCodingException; import java.nio.charset.CharsetDecoder; import java.nio.charset.StandardCharsets; +import java.util.List; @Slf4j public class CheckFiles { @@ -54,10 +55,12 @@ public static void isFileWithTSVExtension(File file) throws IllegalFileFormatExc */ public static void detectTabulations(File file) throws IOException, IllegalFileFormatException { try (BufferedReader reader = new BufferedReader(new FileReader(file))) { - String line; - while ((line = reader.readLine()) != null) { - if (!line.contains("\t")) - throw new IllegalFileFormatException("Le fichier ne contient pas de tabulation"); + List lines = reader.lines().toList(); + + if(lines.stream().anyMatch(line -> + (!line.contains("\t") && !(line.isBlank() && lines.lastIndexOf(line) == lines.size() -1)) // && isNotLast and blank + )){ + throw new IllegalFileFormatException("Le fichier ne contient pas de tabulation"); } } } From 6c2ea92c2111a875e9d3b78d256dc3c32be7f25a Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Tue, 3 Dec 2024 09:33:01 +0100 Subject: [PATCH 3/4] Change color log4j timestamp log --- src/main/resources/log4j2-all.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/log4j2-all.xml b/src/main/resources/log4j2-all.xml index 4fab3ba..8045e85 100644 --- a/src/main/resources/log4j2-all.xml +++ b/src/main/resources/log4j2-all.xml @@ -15,7 +15,7 @@ + pattern="%style{%d{ISO8601}}{white} %highlight{%-5level }[%style{%t}{bright,blue}] %style{%C{1.}}{dark,yellow}: %msg%n%throwable" /> From 4309fe201f5c468e6228d185150701c9b2afc6d2 Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Tue, 7 Jan 2025 14:37:38 +0100 Subject: [PATCH 4/4] Ajout controle sur publication title --- .../java/fr/abes/kbart2kafka/utils/CheckFiles.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java b/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java index 9cdad80..4b46c34 100644 --- a/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java +++ b/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java @@ -48,6 +48,18 @@ public static void isFileWithTSVExtension(File file) throws IllegalFileFormatExc throw new IllegalFileFormatException("le fichier n'est pas au format tsv"); } + public static void checkPublicationTitle(File file) throws IllegalFileFormatException, IOException { + try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + List lines = reader.lines().toList(); + + if(lines.stream().anyMatch(line -> + line.split("\t")[0] == null || line.split("\t")[0].isEmpty() + )){ + throw new IllegalFileFormatException("Le fichier a une ligne qui ne contient pas de publication_title"); + } + } + } + /** * Détecte si le fichier présente des tabulations * @param file fichier en entrée @@ -99,6 +111,7 @@ public static void verifyFile(File file, String header) throws IllegalFileFormat isFileWithTSVExtension(file); detectTabulations(file); detectHeaderPresence(header, file, isBypassOptionPresent); + checkPublicationTitle(file); } public static void isValidUtf8(String input) throws IllegalFileFormatException {