From 2017cc42a3fa6c2a45d742c356c51a432ff770ac Mon Sep 17 00:00:00 2001 From: QDIBYS Date: Wed, 31 Jul 2024 14:57:18 +0200 Subject: [PATCH] Fix genesis not getting in default directory --- .gitignore | 1 + .../java/fr/insee/kraftwerk/api/client/GenesisClient.java | 2 ++ .../insee/kraftwerk/api/configuration/ConfigProperties.java | 4 ++-- .../fr/insee/kraftwerk/api/process/MainProcessingGenesis.java | 2 +- .../fr/insee/kraftwerk/api/services/HealthcheckService.java | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 7bfe1e36..72285495 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ src/test/resources/unit_tests/out/* !src/test/resources/unit_tests/out/.gitkeep kraftwerk-core/src/test/resources/unit_tests/out/* qodana.yaml +kraftwerk-api/src/main/resources/kraftwerk.properties diff --git a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/client/GenesisClient.java b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/client/GenesisClient.java index 743929be..f9a66318 100644 --- a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/client/GenesisClient.java +++ b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/client/GenesisClient.java @@ -7,6 +7,7 @@ import fr.insee.kraftwerk.core.data.model.Mode; import fr.insee.kraftwerk.core.data.model.SurveyUnitId; import fr.insee.kraftwerk.core.data.model.SurveyUnitUpdateLatest; +import lombok.Getter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.http.HttpEntity; @@ -24,6 +25,7 @@ public class GenesisClient { private final RestTemplate restTemplate; + @Getter private final ConfigProperties configProperties; diff --git a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/configuration/ConfigProperties.java b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/configuration/ConfigProperties.java index 70baa08b..187cb2aa 100644 --- a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/configuration/ConfigProperties.java +++ b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/configuration/ConfigProperties.java @@ -16,11 +16,11 @@ public class ConfigProperties { private String genesisUrl; @Value("${fr.insee.postcollecte.files}") - private String specDirectory; + private String defaultDirectory; @PostConstruct public void setTempDirectory() { - System.setProperty("java.io.tmpdir", Paths.get(specDirectory,"temp","currentExecution").toString()); + System.setProperty("java.io.tmpdir", Paths.get(defaultDirectory,"temp","currentExecution").toString()); } } diff --git a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java index 1410032c..13224c3c 100644 --- a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java +++ b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/process/MainProcessingGenesis.java @@ -67,7 +67,7 @@ public MainProcessingGenesis(ConfigProperties config, FileUtilsInterface fileUti public void init(String idCampaign) throws KraftwerkException { log.info("Kraftwerk main service started for campaign: " + idCampaign); - this.controlInputSequenceGenesis = new ControlInputSequenceGenesis("", fileUtilsInterface); + this.controlInputSequenceGenesis = new ControlInputSequenceGenesis(client.getConfigProperties().getDefaultDirectory(), fileUtilsInterface); this.executionDateTime = LocalDateTime.now(); inDirectory = controlInputSequenceGenesis.getInDirectory(idCampaign); //First we check the modes present in database for the given questionnaire diff --git a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/services/HealthcheckService.java b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/services/HealthcheckService.java index 9ea54933..bf09ccf3 100644 --- a/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/services/HealthcheckService.java +++ b/kraftwerk-api/src/main/java/fr/insee/kraftwerk/api/services/HealthcheckService.java @@ -57,14 +57,14 @@ public ResponseEntity healthcheck() { status, projectVersion, client.pingGenesis().split("\n")[0], - configProperties.getSpecDirectory(), + configProperties.getDefaultDirectory(), fileStorageStatus )); } private String fileStorageExists() { try{ - Files.exists(Paths.get(configProperties.getSpecDirectory())); + Files.exists(Paths.get(configProperties.getDefaultDirectory())); }catch (Exception e){ return "Disconnected " +e.getMessage(); }