Skip to content

Commit

Permalink
supp envoi mail
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelQuetin committed Oct 24, 2024
1 parent a3851a9 commit f0fd3e7
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 175 deletions.
20 changes: 4 additions & 16 deletions src/main/java/fr/abes/logskbart/kafka/LogsListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import fr.abes.logskbart.dto.LogKbartDto;
import fr.abes.logskbart.entity.LogKbart;
import fr.abes.logskbart.service.EmailService;
import fr.abes.logskbart.service.LogsService;
import fr.abes.logskbart.utils.UtilsMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.io.File;
Expand All @@ -23,10 +20,10 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
import java.util.stream.IntStream;


Expand All @@ -42,17 +39,14 @@ public class LogsListener {

private final LogsService service;

private final EmailService emailService;

private final Map<String, WorkInProgress> workInProgressMap;

private final Executor executor;

public LogsListener(ObjectMapper mapper, UtilsMapper logsMapper, LogsService service, EmailService emailService, Map<String, WorkInProgress> workInProgressMap, Executor executor) {
public LogsListener(ObjectMapper mapper, UtilsMapper logsMapper, LogsService service, Map<String, WorkInProgress> workInProgressMap, Executor executor) {
this.mapper = mapper;
this.logsMapper = logsMapper;
this.service = service;
this.emailService = emailService;
this.workInProgressMap = workInProgressMap;
this.executor = executor;
}
Expand Down Expand Up @@ -170,12 +164,6 @@ private void createFileBad(String filename) throws IOException {
Path pathOfLog = Path.of("tempLog" + File.separator + filename.replace(".tsv", ".log"));
log.info("Suppression de " + pathOfLog);
Files.deleteIfExists(pathOfLog);
long tailleDixMo = 10 * 1024 * 1024;
if (pathOfBadFinal.toFile().length() < tailleDixMo) {
emailService.sendMailWithAttachment(filename, pathOfBadLocal);
} else {
emailService.sendEmail(filename, "Le fichier est trop volumineux, retrouvez le sur le chemin : /applis/bacon/toLoad/" + filename.replace(".tsv", ".bad"));
}

log.info("Suppression de " + pathOfBadLocal + " en local");
Files.deleteIfExists(pathOfBadLocal);
Expand Down
149 changes: 0 additions & 149 deletions src/main/java/fr/abes/logskbart/service/EmailService.java

This file was deleted.

3 changes: 0 additions & 3 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ logging.level.fr.abes=DEBUG

topic.groupid.source=logskbartConsumer

# Mailing
mail.ws.url=
mail.ws.recipient=
5 changes: 1 addition & 4 deletions src/main/resources/application-prod.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
abes.kafka.bootstrap-servers=
abes.nbThread=

# Base Postgres
# Properties defined from .env on server #ignore resolution error
spring.elasticsearch.uris=

Expand All @@ -12,6 +11,4 @@ logging.level.fr.abes=ERROR

topic.groupid.source=logskbartConsumer

# Mailing
mail.ws.url=
mail.ws.recipient=

3 changes: 0 additions & 3 deletions src/main/resources/application-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ logging.level.fr.abes=INFO

topic.groupid.source=logskbartConsumer

# Mailing
mail.ws.url=
mail.ws.recipient=

0 comments on commit f0fd3e7

Please sign in to comment.