use dmp label in export file names if grant does not exist

This commit is contained in:
Bernaldo Mihasi 2023-09-22 09:29:51 +03:00
parent 9cc42c57e9
commit fbad63ee76
1 changed files with 20 additions and 3 deletions

View File

@ -1633,7 +1633,13 @@ public class DataManagementPlanManager {
wordBuilder.fillFooter(dmpEntity, null, document, false);
String fileName = "DMP_" + dmpEntity.getGrant().getLabel();
String fileName;
if (dmpEntity.getGrant() != null && dmpEntity.getGrant().getLabel() != null) {
fileName = "DMP_" + dmpEntity.getGrant().getLabel();
}
else {
fileName = "DMP_" + dmpEntity.getLabel();
}
if (versioned) {
fileName += "_" + dmpEntity.getVersion();
}
@ -1882,7 +1888,12 @@ public class DataManagementPlanManager {
writer.close();
FileEnvelope fileEnvelope = new FileEnvelope();
fileEnvelope.setFile(xmlFile);
fileEnvelope.setFilename("DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion() + ".xml");
if (dmp.getGrant() != null && dmp.getGrant().getLabel() != null) {
fileEnvelope.setFilename("DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion() + ".xml");
}
else {
fileEnvelope.setFilename("DMP_" + dmp.getLabel() + "_" + dmp.getVersion() + ".xml");
}
return fileEnvelope;
}
@ -1900,7 +1911,13 @@ public class DataManagementPlanManager {
.collect(Collectors.toSet()));
String result = rdaManager.convertToRDA(dmp);
String fileName = "DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion();
String fileName;
if (dmp.getGrant() != null && dmp.getGrant().getLabel() != null) {
fileName = "DMP_" + dmp.getGrant().getLabel() + "_" + dmp.getVersion();
}
else {
fileName = "DMP_" + dmp.getLabel() + "_" + dmp.getVersion();
}
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "").replace(" ", "_").replace(",", "_");
String uuid = UUID.randomUUID().toString();
File file = new File(this.environment.getProperty("temp.temp") + uuid + ".json");