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

Merge develop dans main #91

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ RUN cp /app/*.jar /app/run
RUN chmod 777 /app/run/*
ENV TZ=Europe/Paris
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENTRYPOINT ["tail", "-f", "/dev/null"]

4 changes: 2 additions & 2 deletions src/main/java/fr/abes/kbart2kafka/Kbart2kafkaApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public void run(String... args) throws IOException {
if (args.length == 0 || args[0] == null || args[0].trim().isEmpty()) {
log.error("Message envoyé : {}", "Le chemin d'accès au fichier tsv n'a pas été trouvé dans les paramètres de l'application");
} else {
log.info("Debut envois kafka de : " + args[0]);
ThreadContext.put("package", args[0]);
log.info("Debut envois kafka de : " + Utils.extractFilename(args[0]));
ThreadContext.put("package", Utils.extractFilename(args[0]));
// Récupération du chemin d'accès au fichier
File tsvFile = new File(args[0]);
try {
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/fr/abes/kbart2kafka/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileSystems;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -59,5 +60,11 @@ public static Date extractDate(String filename) throws IllegalDateException {
}
}

public static String extractFilename(String path) {
if (path.contains(FileSystems.getDefault().getSeparator()))
return path.substring(path.lastIndexOf(FileSystems.getDefault().getSeparator()) + 1);
return path;
}


}
12 changes: 12 additions & 0 deletions src/test/java/fr/abes/kbart2kafka/utils/UtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.junit.jupiter.api.Test;

import java.net.URISyntaxException;
import java.nio.file.FileSystems;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
Expand Down Expand Up @@ -60,4 +61,15 @@ void testExtractProvider() throws IllegalProviderException {
String filename2 = "test";
Assertions.assertThrows(IllegalProviderException.class, () -> Utils.extractProvider(filename2));
}

@Test
@DisplayName("test extraction nom de fichier")
void extractFilename() {
String sep = FileSystems.getDefault().getSeparator();
String path = "SPRINGER_GLOBAL_ALLEBOOKS_2023-05-01_FORCE.tsv";
Assertions.assertEquals("SPRINGER_GLOBAL_ALLEBOOKS_2023-05-01_FORCE.tsv", Utils.extractFilename(path));

path = sep + "app" + sep + "local" + sep + "SPRINGER_GLOBAL_ALLEBOOKS_2023-05-01_FORCE.tsv";
Assertions.assertEquals("SPRINGER_GLOBAL_ALLEBOOKS_2023-05-01_FORCE.tsv", Utils.extractFilename(path));
}
}
Loading