summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main/java
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2019-03-14 08:52:17 +0100
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>2019-03-14 09:37:07 +0100
commitda01e853388b3715a4da488a73a10522e90bf0ed (patch)
tree9f25184027034f47c9f3a72b266e600fe7ad7aaa /prh-app-server/src/main/java
parentc69d68d5669e45c969fd1293aa76c78d55a95dca (diff)
Revert IP information removal
Change-Id: I43cdc2f2086f884df1f74dfbf999addae2019b5e Issue-ID: DCAEGEN2-1312 Signed-off-by: Joanna Jeremicz <joanna.jeremicz@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.java18
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java2
2 files changed, 18 insertions, 2 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 295cd7ca..f7141581 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
@@ -44,6 +44,8 @@ import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.EQUIP
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.EQUIP_VENDOR;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.EVENT;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.NF_ROLE;
+import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.OAM_IPV_4_ADDRESS;
+import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.OAM_IPV_6_ADDRESS;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.PNF_REGISTRATION_FIELDS;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.SERIAL_NUMBER;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.SOURCE_NAME;
@@ -59,6 +61,8 @@ public class DmaapConsumerJsonParser {
private static final Logger LOGGER = LoggerFactory.getLogger(DmaapConsumerJsonParser.class);
private String pnfSourceName;
+ private String pnfOamIpv4Address;
+ private String pnfOamIpv6Address;
private String pnfSerialNumberOptionalField;
private String pnfEquipVendorOptionalField;
private String pnfEquipModelOptionalField;
@@ -120,6 +124,8 @@ public class DmaapConsumerJsonParser {
this.pnfSourceName = getValueFromJson(commonEventHeader, SOURCE_NAME);
this.pnfNfRoleOptionalField = getValueFromJson(commonEventHeader, NF_ROLE);
+ this.pnfOamIpv4Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_4_ADDRESS);
+ this.pnfOamIpv6Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_6_ADDRESS);
this.pnfSerialNumberOptionalField = getValueFromJson(pnfRegistrationFields, SERIAL_NUMBER);
this.pnfEquipVendorOptionalField = getValueFromJson(pnfRegistrationFields, EQUIP_VENDOR);
this.pnfEquipModelOptionalField = getValueFromJson(pnfRegistrationFields, EQUIP_MODEL);
@@ -127,11 +133,13 @@ public class DmaapConsumerJsonParser {
this.pnfSwVersionOptionalField = getValueFromJson(pnfRegistrationFields, SW_VERSION);
this.pnfAdditionalFields = pnfRegistrationFields.getAsJsonObject(ADDITIONAL_FIELDS);
- return (StringUtils.isEmpty(pnfSourceName))
+ return (StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address))
? logErrorAndReturnMonoEmpty("Incorrect json, consumerDmaapModel can not be created: "
+ printMessage()) :
Mono.just(ImmutableConsumerDmaapModel.builder()
.correlationId(pnfSourceName)
+ .ipv4(pnfOamIpv4Address)
+ .ipv6(pnfOamIpv6Address)
.serialNumber(pnfSerialNumberOptionalField)
.equipVendor(pnfEquipVendorOptionalField)
.equipModel(pnfEquipModelOptionalField)
@@ -145,6 +153,10 @@ public class DmaapConsumerJsonParser {
return jsonObject.has(jsonKey) ? jsonObject.get(jsonKey).getAsString() : "";
}
+ private boolean ipPropertiesNotEmpty(String ipv4, String ipv6) {
+ return (!StringUtils.isEmpty(ipv4)) || !(StringUtils.isEmpty(ipv6));
+ }
+
private boolean containsHeader(JsonObject jsonObject) {
return jsonObject.has(EVENT) && jsonObject.getAsJsonObject(EVENT).has(PNF_REGISTRATION_FIELDS);
}
@@ -152,6 +164,8 @@ public class DmaapConsumerJsonParser {
private String printMessage() {
return String.format("%n{"
+ "\"" + CORRELATION_ID + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + OAM_IPV_4_ADDRESS + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + OAM_IPV_6_ADDRESS + COMMON_FORMAT_FOR_STRING + ","
+ "\"" + SERIAL_NUMBER + COMMON_FORMAT_FOR_STRING + ","
+ "\"" + EQUIP_VENDOR + COMMON_FORMAT_FOR_STRING + ","
+ "\"" + EQUIP_MODEL + COMMON_FORMAT_FOR_STRING + ","
@@ -159,7 +173,7 @@ public class DmaapConsumerJsonParser {
+ "\"" + NF_ROLE + COMMON_FORMAT_FOR_STRING + ","
+ "\"" + SW_VERSION + COMMON_FORMAT_FOR_STRING + ","
+ "\"" + ADDITIONAL_FIELDS + COMMON_FORMAT_FOR_JSON_OBJECT
- + "%n}", this.pnfSourceName,
+ + "%n}", this.pnfSourceName, this.pnfOamIpv4Address, this.pnfOamIpv6Address,
this.pnfSerialNumberOptionalField, this.pnfEquipVendorOptionalField,
this.pnfEquipModelOptionalField, this.pnfEquipTypeOptionalField,
this.pnfNfRoleOptionalField, this.pnfSwVersionOptionalField, this.pnfAdditionalFields
diff --git a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java
index 696bbba6..a40795b1 100644
--- a/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java
+++ b/prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java
@@ -28,6 +28,8 @@ class PnfRegistrationFields {
static final String EVENT = "event";
static final String COMMON_EVENT_HEADER = "commonEventHeader";
static final String PNF_REGISTRATION_FIELDS = "pnfRegistrationFields";
+ static final String OAM_IPV_4_ADDRESS = "oamV4IpAddress";
+ static final String OAM_IPV_6_ADDRESS = "oamV6IpAddress";
static final String SOURCE_NAME = "sourceName";
static final String CORRELATION_ID = "correlationId";