From 78753404b5c2220874f6f9c18c0025bfd8a60901 Mon Sep 17 00:00:00 2001 From: George Kalampokis Date: Mon, 30 Mar 2020 18:24:19 +0300 Subject: [PATCH] Add temp folder for downloading DMP exported files --- .../eu/eudat/logic/managers/DataManagementPlanManager.java | 6 +++--- .../web/src/main/resources/config/application.properties | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index 8a997753a..86842a3cf 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -358,7 +358,7 @@ public class DataManagementPlanManager { fileName = dmpEntity.getLabel(); } fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); - File exportFile = new File(fileName + ".docx"); + File exportFile = new File(this.environment.getProperty("temp.temp") + fileName + ".docx"); FileOutputStream out = new FileOutputStream(exportFile); document.write(out); out.close(); @@ -1001,7 +1001,7 @@ public class DataManagementPlanManager { List datasets = dmp.getDataset().stream().collect(Collectors.toList()); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); - File xmlFile = new File(fileName + ".xml"); + File xmlFile = new File(this.environment.getProperty("temp.temp") + fileName + ".xml"); BufferedWriter writer = new BufferedWriter(new FileWriter(xmlFile, true)); Document xmlDoc = XmlBuilder.getDocument(); Element dmpElement = xmlDoc.createElement("dmp"); @@ -1138,7 +1138,7 @@ public class DataManagementPlanManager { mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); String fileName = dmp.getLabel(); fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", ""); - File file = new File(fileName + ".json"); + File file = new File(this.environment.getProperty("temp.temp") + fileName + ".json"); OutputStream output = new FileOutputStream(file); try { // mapper.writeValue(file, rdaExportModel); diff --git a/dmp-backend/web/src/main/resources/config/application.properties b/dmp-backend/web/src/main/resources/config/application.properties index 095672df1..610c84be8 100644 --- a/dmp-backend/web/src/main/resources/config/application.properties +++ b/dmp-backend/web/src/main/resources/config/application.properties @@ -90,4 +90,7 @@ notification.finalised.subject=[OpenDMP] The {name} has been finalised notification.modifiedFinalised.subject=[OpenDMP] The {name} has been modified and finalised #############LOGGING######### -logging.config=classpath:logging/logback-${spring.profiles.active}.xml \ No newline at end of file +logging.config=classpath:logging/logback-${spring.profiles.active}.xml + +#############TEMP######### +temp.temp=tmp/ \ No newline at end of file