From e4dff08cb6353def23718b7484d10a6bd27c493f Mon Sep 17 00:00:00 2001 From: SamuelQuetin Date: Tue, 8 Oct 2024 11:31:57 +0200 Subject: [PATCH] remise du email --- .../fr/abes/logskbart/kafka/LogsListener.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/fr/abes/logskbart/kafka/LogsListener.java b/src/main/java/fr/abes/logskbart/kafka/LogsListener.java index 355c266..2e21a79 100644 --- a/src/main/java/fr/abes/logskbart/kafka/LogsListener.java +++ b/src/main/java/fr/abes/logskbart/kafka/LogsListener.java @@ -57,11 +57,12 @@ public void listenInfoKbart2KafkaAndErrorKbart2Kafka(ConsumerRecord 1) ? message.key().split(";")[1] : ""; - logKbart.setNbLine(Integer.parseInt((nbLineOrigine.isEmpty() ? "-1" : nbLineOrigine) )); + logKbart.setPackageName(key[0]); + logKbart.setNbLine(Integer.parseInt(((key.length > 1) ? key[1] : "-1") )); Integer nbRun = service.getLastNbRun(logKbart.getPackageName()); if(logKbart.getMessage().contains("Debut envois kafka de :")){ @@ -91,9 +92,8 @@ public void deleteOldLocalTempLog() throws IOException { Date dateOfLastModification = new Date(basicFileAttributes.lastModifiedTime().toMillis()); Date dateNow = Date.from(LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant()); long interval = dateNow.getTime() - dateOfLastModification.getTime(); - if (interval > 600000) { - Files.deleteIfExists(fileToCheck.toPath()); - log.debug("Fichier obsolète supprimé : " + nameFile); + if (interval > 600000 && Files.deleteIfExists(fileToCheck.toPath())) { + log.debug("Fichier obsolète supprimé : {}", nameFile); } } } @@ -143,12 +143,13 @@ private void createFileBad(String filename, Integer nbRun) throws IOException { // Suppression du .log car Useless si cas là Path pathOfLog = Path.of("tempLog" + File.separator + filename.replace(".tsv", ".log")); - log.info("Suppression de " + pathOfLog.toString()); + log.info("Suppression de " + pathOfLog); Files.deleteIfExists(pathOfLog); + + emailService.sendMailWithAttachment(filename, pathOfBadLocal); + log.info("Suppression de " + pathOfBadLocal + " en local"); Files.deleteIfExists(pathOfBadLocal); - -// emailService.sendMailWithAttachment(filename, pathOfBadLocal); } }