From bff804e5cf93ca1ddb29558004cbc42ac4a8041a Mon Sep 17 00:00:00 2001 From: QDIBYS Date: Wed, 31 Jul 2024 13:19:54 +0200 Subject: [PATCH] Fix file on error moved in done + add multiple inputed syntaxes --- .../controller/rest/ResponseController.java | 14 +++++++++++--- .../sources/xml/LunaticXmlDataParser.java | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/fr/insee/genesis/controller/rest/ResponseController.java b/src/main/java/fr/insee/genesis/controller/rest/ResponseController.java index 814a827d..992d45e5 100644 --- a/src/main/java/fr/insee/genesis/controller/rest/ResponseController.java +++ b/src/main/java/fr/insee/genesis/controller/rest/ResponseController.java @@ -28,6 +28,8 @@ import io.swagger.v3.oas.annotations.Operation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.HttpStatusCode; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.DeleteMapping; @@ -355,13 +357,18 @@ private void treatCampaignWithMode(String campaignName, Mode mode, List response; if (filepath.toFile().length() / 1024 / 1024 <= Constants.MAX_FILE_SIZE_UNTIL_SEQUENTIAL) { - treatXmlFileWithMemory(filepath, mode, variablesMap); + response = treatXmlFileWithMemory(filepath, mode, variablesMap); } else { - treatXmlFileSequentially(filepath, mode, variablesMap); + response = treatXmlFileSequentially(filepath, mode, variablesMap); } log.debug("File {} saved", fileName); - fileUtils.moveDataFile(campaignName, mode.getFolder(), filepath); + if(response.getStatusCode() == HttpStatus.OK){ + fileUtils.moveDataFile(campaignName, mode.getFolder(), filepath); + }else{ + log.error("Error on file {}", fileName); + } } } } @@ -377,6 +384,7 @@ private ResponseEntity treatXmlFileWithMemory(Path filepath, Mode modeSp try { campaign = parser.parseDataFile(filepath); } catch (GenesisException e) { + log.error(e.toString()); return ResponseEntity.status(e.getStatus()).body(e.getMessage()); } diff --git a/src/main/java/fr/insee/genesis/controller/sources/xml/LunaticXmlDataParser.java b/src/main/java/fr/insee/genesis/controller/sources/xml/LunaticXmlDataParser.java index f6ef069f..3c17d58e 100644 --- a/src/main/java/fr/insee/genesis/controller/sources/xml/LunaticXmlDataParser.java +++ b/src/main/java/fr/insee/genesis/controller/sources/xml/LunaticXmlDataParser.java @@ -236,7 +236,7 @@ private static void setValues(LunaticXmlCollectedData varData, Node value, List< case "EDITED": varData.setEdited(valueTypes); break; - case "INPUTED": + case "INPUTED", "INPUTTED", "IMPUTED": varData.setInputed(valueTypes); break; case "FORCED":