aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main
diff options
context:
space:
mode:
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-11-07 17:46:59 +0100
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>2018-11-07 17:46:59 +0100
commit1c554c3332ccf6be4e576e9159bbb0f901197379 (patch)
tree2f27cccca3b87c7ef220339852a7d760fa35081b /bpmn/so-bpmn-infrastructure-common/src/main
parent2073a3b4c20965252c7f3a0c1aea8e4407e876fa (diff)
bug fixing with reading dmaap message
Change-Id: I259337e866d1b401b574ba427219157dfc4987af Issue-ID: SO-1191 Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java35
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java2
2 files changed, 16 insertions, 21 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
index 90b48ab2c1..159298b4ad 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/JsonUtilForCorrelationId.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -31,41 +33,32 @@ import java.util.Spliterator;
public final class JsonUtilForCorrelationId {
- private static final String JSON_HEADER = "pnfRegistrationFields";
private static final String JSON_CORRELATION_ID_FIELD_NAME = "correlationId";
static List<String> parseJsonToGelAllCorrelationId(String json) {
- List<String> list = new ArrayList<>();
JsonElement je = new JsonParser().parse(json);
- if (je.isJsonObject()) {
- getCorrelationIdFromJsonObject(je.getAsJsonObject()).ifPresent(corr -> list.add(corr));
- } else {
- JsonArray array = je.getAsJsonArray();
- Spliterator<JsonElement> spliterator = array.spliterator();
- spliterator.forEachRemaining(jsonElement -> {
- parseJsonElementToJsonObject(jsonElement)
- .ifPresent(jsonObject -> getCorrelationIdFromJsonObject(jsonObject)
- .ifPresent(correlationId -> list.add(correlationId)));
- });
- }
+ JsonArray array = je.getAsJsonArray();
+ List<String> list = new ArrayList<>();
+ Spliterator<JsonElement> spliterator = array.spliterator();
+ spliterator.forEachRemaining(jsonElement -> {
+ handleEscapedCharacters(jsonElement)
+ .ifPresent(jsonObject -> getCorrelationId(jsonObject)
+ .ifPresent(correlationId -> list.add(correlationId)));
+ });
return list;
}
- private static Optional<JsonObject> parseJsonElementToJsonObject(JsonElement jsonElement) {
+ private static Optional<JsonObject> handleEscapedCharacters(JsonElement jsonElement) {
if (jsonElement.isJsonObject()) {
return Optional.ofNullable(jsonElement.getAsJsonObject());
}
return Optional.ofNullable(new JsonParser().parse(jsonElement.getAsString()).getAsJsonObject());
}
- private static Optional<String> getCorrelationIdFromJsonObject(JsonObject jsonObject) {
- if (jsonObject.has(JSON_HEADER)) {
- JsonObject jo = jsonObject.getAsJsonObject(JSON_HEADER);
- if (jo.has(JSON_CORRELATION_ID_FIELD_NAME)) {
- return Optional.ofNullable(jo.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString());
- }
+ private static Optional<String> getCorrelationId(JsonObject jsonObject) {
+ if (jsonObject.has(JSON_CORRELATION_ID_FIELD_NAME)) {
+ return Optional.ofNullable(jsonObject.get(JSON_CORRELATION_ID_FIELD_NAME).getAsString());
}
return Optional.empty();
}
-
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
index 518d7ff194..373e84bb9d 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/dmaap/PnfEventReadyDmaapClient.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Copyright (C) 2018 Nokia.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at