Added file removal in finally block

This commit is contained in:
Luca Frosini 2024-03-18 17:15:02 +01:00
parent 0511aa400e
commit a43b095b0c
1 changed files with 10 additions and 7 deletions

View File

@ -103,13 +103,16 @@ public abstract class Record extends CKANPackage {
Template tsTemplate = freeMarker.getTemplate("timeseries.ftl");
Template template = freeMarker.getTemplate(getType() + ".ftl");
Map<String, Object> map = getMapFromSourceJson(node);
File transformedJson = getTransformedJsonFile(template,map);
jsonNode = mapper.readTree(transformedJson);
jsonNode = elaborateTimeSeries(tsTemplate,map);
jsonNode = checkTags(jsonNode);
jsonNode = checkOrganization(jsonNode);
jsonNode = checkGroups(jsonNode);
transformedJson.delete();
File transformedJson = getTransformedJsonFile(template,map);
try {
jsonNode = mapper.readTree(transformedJson);
jsonNode = elaborateTimeSeries(tsTemplate,map);
jsonNode = checkTags(jsonNode);
jsonNode = checkOrganization(jsonNode);
jsonNode = checkGroups(jsonNode);
} finally {
transformedJson.delete();
}
return jsonNode;
}