summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main
diff options
context:
space:
mode:
authorpwielebs <piotr.wielebski@nokia.com>2018-08-30 12:02:31 +0200
committerpwielebs <piotr.wielebski@nokia.com>2018-08-30 12:02:31 +0200
commited4d45332691282e7e0dc4bb413d20f46e1a0a66 (patch)
tree5bb2c06ef453ae8868cbd0f1b04ce9375c165459 /prh-app-server/src/main
parent4fbb9e8ad097c9ec3c3434ba257e887fb3a64699 (diff)
Introduction of a new parameter "sourceName"
- used instead of pnf-name (correlationId) Change-Id: Iabcbfacbc029bd6d229080c2064a291e17c7f4f8 Issue-ID: DCAEGEN2-744 Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Diffstat (limited to 'prh-app-server/src/main')
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/DmaapConsumerJsonParser.java46
1 files changed, 22 insertions, 24 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 17b1ef67..8742d872 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
@@ -40,11 +40,11 @@ import reactor.core.publisher.Mono;
public class DmaapConsumerJsonParser {
private static final String EVENT = "event";
+ private static final String COMMON_EVENT_HEADER = "commonEventHeader";
private static final String PNF_REGISTRATION_FIELDS = "pnfRegistrationFields";
private static final String OAM_IPV_4_ADDRESS = "oamV4IpAddress";
private static final String OAM_IPV_6_ADDRESS = "oamV6IpAddress";
- private static final String VENDOR_NAME = "vendorName";
- private static final String SERIAL_NUMBER = "serialNumber";
+ private static final String SOURCE_NAME = "sourceName";
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -89,20 +89,23 @@ public class DmaapConsumerJsonParser {
: transform(monoJsonP));
}
- private Mono<ConsumerDmaapModel> transform(JsonObject monoJsonP) {
- monoJsonP = monoJsonP.getAsJsonObject(EVENT).getAsJsonObject(PNF_REGISTRATION_FIELDS);
- String pnfVendorName = getValueFromJson(monoJsonP, VENDOR_NAME);
- String pnfSerialNumber = getValueFromJson(monoJsonP, SERIAL_NUMBER);
- String pnfOamIpv4Address = getValueFromJson(monoJsonP, OAM_IPV_4_ADDRESS);
- String pnfOamIpv6Address = getValueFromJson(monoJsonP, OAM_IPV_6_ADDRESS);
- return
- (!vendorAndSerialNotEmpty(pnfSerialNumber, pnfVendorName) || !ipPropertiesNotEmpty(pnfOamIpv4Address,
- pnfOamIpv6Address))
+ private Mono<ConsumerDmaapModel> transform(JsonObject responseFromDmaap) {
+
+ JsonObject commonEventHeader = responseFromDmaap.getAsJsonObject(EVENT)
+ .getAsJsonObject(COMMON_EVENT_HEADER);
+ JsonObject pnfRegistrationFields = responseFromDmaap.getAsJsonObject(EVENT)
+ .getAsJsonObject(PNF_REGISTRATION_FIELDS);
+
+ String pnfSourceName = getValueFromJson(commonEventHeader, SOURCE_NAME);
+ String pnfOamIpv4Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_4_ADDRESS);
+ String pnfOamIpv6Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_6_ADDRESS);
+
+ return ( StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address) )
? Mono.error(new DmaapNotFoundException("Incorrect json, consumerDmaapModel can not be created: "
- + printMessage(pnfVendorName, pnfSerialNumber, pnfOamIpv4Address, pnfOamIpv6Address))) :
+ + printMessage(pnfSourceName, pnfOamIpv4Address, pnfOamIpv6Address))) :
Mono.just(ImmutableConsumerDmaapModel.builder()
- .pnfName(pnfVendorName.substring(0, Math.min(pnfVendorName.length(), 3)).toUpperCase()
- .concat(pnfSerialNumber)).ipv4(pnfOamIpv4Address)
+ .sourceName(pnfSourceName)
+ .ipv4(pnfOamIpv4Address)
.ipv6(pnfOamIpv6Address).build());
}
@@ -110,10 +113,6 @@ public class DmaapConsumerJsonParser {
return jsonObject.has(jsonKey) ? jsonObject.get(jsonKey).getAsString() : "";
}
- private boolean vendorAndSerialNotEmpty(String pnfSerialNumber, String pnfVendorName) {
- return (!StringUtils.isEmpty(pnfSerialNumber) && !StringUtils.isEmpty(pnfVendorName));
- }
-
private boolean ipPropertiesNotEmpty(String ipv4, String ipv6) {
return (!StringUtils.isEmpty(ipv4)) || !(StringUtils.isEmpty(ipv6));
}
@@ -122,12 +121,11 @@ public class DmaapConsumerJsonParser {
return jsonObject.has(EVENT) && jsonObject.getAsJsonObject(EVENT).has(PNF_REGISTRATION_FIELDS);
}
- private String printMessage(String vendorName, String serialNumber, String oamIpv4Address, String oamIpv6Address) {
+ private String printMessage(String sourceName, String oamIpv4Address, String oamIpv6Address) {
return String.format("%n{"
- + "\"" + VENDOR_NAME + " : \"%s\","
- + "\"" + SERIAL_NUMBER + "\": \"%s\","
- + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\","
- + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\""
- + "%n}", vendorName, serialNumber, oamIpv4Address, oamIpv6Address);
+ + "\"" + SOURCE_NAME + "\": \"%s\","
+ + "\"" + OAM_IPV_4_ADDRESS + "\": \"%s\","
+ + "\"" + OAM_IPV_6_ADDRESS + "\": \"%s\""
+ + "%n}", sourceName, oamIpv4Address, oamIpv6Address);
}
}