summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main/java
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-06-04 15:43:27 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-06-04 15:43:27 +0200
commit53e33ec68a6eb0a06ea130215e03a7725da9d22d (patch)
treeb39721025dbb39a5fb1487c72dd498ecd410b1fe /prh-app-server/src/main/java
parent04fdbd0e18a891241ed068044093a257ff506400 (diff)
2nd fix for DmaapConsumerJsonParser
Change-Id: I0b5fa7e2a1e8472f72e636a84ef6d2285580b494 Issue-ID: DCAEGEN2-451 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main/java')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
index 04956f8d..ba0ec0e8 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java
@@ -26,6 +26,7 @@ import org.onap.dcaegen2.services.prh.exceptions.DmaapNotFoundException;
import org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel;
import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel;
+import java.util.Optional;
import java.util.stream.StreamSupport;
/**
@@ -41,17 +42,16 @@ public class DmaapConsumerJsonParser {
private static final String PNF_SERIAL_NUMBER = "pnfSerialNumber";
- private DmaapConsumerJsonParser() {
- }
+ private DmaapConsumerJsonParser() {}
public static ConsumerDmaapModel getJsonObject(String message) throws DmaapNotFoundException {
JsonElement jsonElement = new JsonParser().parse(message);
- JsonObject jsonObject;
- jsonObject = jsonElement.isJsonObject() ? jsonElement.getAsJsonObject() :
+ JsonObject jsonObject = jsonElement.isJsonObject() ? jsonElement.getAsJsonObject() :
StreamSupport.stream(jsonElement.getAsJsonArray().spliterator(), false).findFirst()
- .orElseThrow(() -> new DmaapNotFoundException("Json object not found in json array"))
+ .flatMap(element -> Optional.of(new JsonParser().parse(element.toString()).getAsJsonObject()))
+ .orElseThrow(() -> new DmaapNotFoundException("Json object not found in json array"))
.getAsJsonObject();
return create(jsonObject);