Skip to content

Commit

Permalink
remise du email
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQuetin committed Oct 8, 2024
1 parent 0fa7159 commit e4dff08
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/main/java/fr/abes/logskbart/kafka/LogsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ public void listenInfoKbart2KafkaAndErrorKbart2Kafka(ConsumerRecord<String, Stri
LogKbart logKbart = logsMapper.map(dto, LogKbart.class);

// recuperation de l'heure a laquelle le message a ete envoye
String[] key = message.key().split(";");

Timestamp currentTimestamp = new Timestamp(message.timestamp());
logKbart.setTimestamp(new Date(currentTimestamp.getTime()));
logKbart.setPackageName(message.key().split(";")[0]);
String nbLineOrigine = (message.key().split(";").length > 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 :")){
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);
}

}
Expand Down

0 comments on commit e4dff08

Please sign in to comment.