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
diff --git a/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java b/src/main/java/fr/abes/kbart2kafka/utils/CheckFiles.java
index 668840f..4b46c34 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 {
@@ -47,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
@@ -54,10 +67,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");
}
}
}
@@ -96,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 {
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" />