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 sur main #115

Merged
merged 5 commits into from
Oct 3, 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
14 changes: 1 addition & 13 deletions src/main/java/fr/abes/bestppn/kafka/TopicConsumer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void kbartFromkafkaListener(ConsumerRecord<String, String> ligneKbart) {
LigneKbartDto ligneKbartDto = mapper.readValue(ligneKbart.value(), LigneKbartDto.class);
String providerName = Utils.extractProvider(filename);
try {
log.info("Partition;" + ligneKbart.partition() + ";offset;" + ligneKbart.offset() + ";fichier;" + filename + ";" + Thread.currentThread().getName());
log.debug("Partition;" + ligneKbart.partition() + ";offset;" + ligneKbart.offset() + ";fichier;" + filename + ";" + Thread.currentThread().getName());
int origineNbCurrentLine = ligneKbartDto.getNbCurrentLines();
ThreadContext.put("package", (filename + ";" + origineNbCurrentLine)); //Ajoute le nom de fichier dans le contexte du thread pour log4j
service.processConsumerRecord(ligneKbartDto, providerName, workInProgress.get(filename).isForced(), workInProgress.get(filename).isBypassed(), filename);
Expand Down Expand Up @@ -127,18 +127,6 @@ private void handleFichier(String filename) {
}
}

@KafkaListener(topics = {"${topic.name.source.kbart.errors}"}, groupId = "${topic.groupid.source.errors}", containerFactory = "kafkaKbartListenerContainerFactory")
public void errorsListener(ConsumerRecord<String, String> error) {
log.error(error.value());
String filename = extractFilenameFromKey(error.key());
if (workInProgress.containsKey(filename)) {
emailService.sendProductionErrorEmail(filename, error.value());
logFileService.createExecutionReport(filename, workInProgress.get(filename).getExecutionReport(), workInProgress.get(filename).isForced());
workInProgress.get(filename).setIsOnError(true);
handleFichier(filename);
}
}

private String extractFilenameFromKey (String key) {
return key.substring(0, key.lastIndexOf('_'));
}
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/fr/abes/bestppn/service/EmailService.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void sendMailWithAttachment(String packageName, PackageKbartDto mailAttac
createAttachment(mailAttachment, csvPath);

// Création du mail
String requestJson = mailToJSON(this.recipient, "[CONVERGENCE]["+env.toUpperCase()+"] Rapport de traitement BestPPN " + packageName + ".csv", "");
String requestJson = mailToJSON(this.recipient, "[KBART2BACON : Rapport BestPPN]" + getTag() + " " + packageName, "");

// Récupération du fichier
File file = csvPath.toFile();
Expand Down Expand Up @@ -175,9 +175,17 @@ protected String mailToJSON(String to, String subject, String text) {

public void sendProductionErrorEmail(String packageName, String message) {
// Création du mail
String requestJson = mailToJSON(this.recipient, "[CONVERGENCE]["+env.toUpperCase()+"] Rapport de traitement BestPPN " + packageName, message);
String requestJson = mailToJSON(this.recipient, "[KBART2BACON : erreurs]" + getTag() + " " + packageName, message);

// Envoi du message par mail
sendMail(requestJson);
}

private String getTag(){
if(env.equalsIgnoreCase("PROD")){
return "";
} else {
return "[" + env.toUpperCase() + "]";
}
}
}
16 changes: 8 additions & 8 deletions src/main/java/fr/abes/bestppn/service/WsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ public ResultWsSudocDto callDoi2Ppn(String doi, @Nullable String provider) throw
params.put("doi", doi.toUpperCase());
params.put("provider", provider);
ResultWsSudocDto result = new ResultWsSudocDto();
String resultCall = getCall(urlDoi2Ppn, params);
if (!resultCall.isEmpty()) {
result = mapper.readValue(resultCall, ResultWsSudocDto.class);
result.setUrl(urlDoi2Ppn + "?provider=" + provider + "&doi=" + doi);
}
else {
log.info("doi : " + doi + " / provider " + provider + " : aucun ppn ne correspond à la recherche");
}
String resultCall = getCall(urlDoi2Ppn, params);
result.setUrl(urlDoi2Ppn + "?provider=" + provider + "&doi=" + doi);
if (!resultCall.isEmpty()) {
result = mapper.readValue(resultCall, ResultWsSudocDto.class);
}
else {
log.info("doi : " + doi + " / provider " + provider + " : aucun ppn ne correspond à la recherche");
}
return result;
}

Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ topic.name.target.kbart=bacon.kbart.withppn.toload
topic.name.target.noticeimprime=bacon.kbart.sudoc.imprime.tocreate
topic.name.target.ppnFromKbart=bacon.kbart.sudoc.tocreate.exnihilo
topic.name.source.kbart=bacon.kbart.toload
topic.name.source.kbart.errors=bacon.kbart.toload.errors
topic.name.source.nbLines=bacon.kbart.toload.nbLines
topic.name.target.kbart.bypass.toload=bacon.kbart.bypass.toload

spring.jpa.open-in-view=false
Expand Down
Loading