aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket-be/vnf-sdk-marketplace/src/main
diff options
context:
space:
mode:
authorBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2020-10-08 11:48:34 +0200
committerBartosz Gardziejewski <bartosz.gardziejewski@nokia.com>2020-10-08 12:07:15 +0200
commitc184cf1bda7a8a5d1cd489fb8080d2ee507611de (patch)
tree220770e6930f70d3b9ba8f61441aa96cc384fc5e /vnfmarket-be/vnf-sdk-marketplace/src/main
parent15c39f44fb16ca5e16b522b32eea79b4f73193c3 (diff)
Fix get executions JSON parsing error.
Signed-off-by: Bartosz Gardziejewski <bartosz.gardziejewski@nokia.com> Change-Id: I1ee1c070cc0c97eebfad5cdb5e737d8136631cbf Issue-ID: VNFSDK-697
Diffstat (limited to 'vnfmarket-be/vnf-sdk-marketplace/src/main')
-rw-r--r--vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResultsSupplier.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResultsSupplier.java b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResultsSupplier.java
index 3f1e4c57..e2d43f14 100644
--- a/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResultsSupplier.java
+++ b/vnfmarket-be/vnf-sdk-marketplace/src/main/java/org/onap/vtp/execution/VTPExecutionResultsSupplier.java
@@ -19,6 +19,7 @@ package org.onap.vtp.execution;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,21 +66,21 @@ public class VTPExecutionResultsSupplier {
.orElse(createNoOutputFileErrorMessageInJsonFormat());
}
- private JsonArray loadOutputJsonFromFile(File file) {
- JsonArray outputJson;
+ private JsonElement loadOutputJsonFromFile(File file) {
+ JsonElement outputJson;
try {
String executionResult = Files.readString(file.toPath());
- outputJson = gson.fromJson(executionResult, JsonArray.class);
+ outputJson = gson.fromJson(executionResult, JsonElement.class);
} catch (IOException | JsonParseException e) {
logger.error(e.getMessage(),e);
String errorMessage = "" +
- "[{ \"error\": \"fail to load execution result\",\"reason\":\"" + e.getMessage() + "\"}]";
- outputJson = gson.fromJson(errorMessage, JsonArray.class);
+ "{ \"error\": \"fail to load execution result\",\"reason\":\"" + e.getMessage() + "\"}";
+ outputJson = gson.fromJson(errorMessage, JsonObject.class);
}
return outputJson;
}
- private JsonArray createNoOutputFileErrorMessageInJsonFormat() {
- return gson.fromJson("[{ \"error\": \"unable to find execution results\"}]", JsonArray.class);
+ private JsonElement createNoOutputFileErrorMessageInJsonFormat() {
+ return gson.fromJson("{ \"error\": \"unable to find execution results\"}", JsonObject.class);
}
}