summaryrefslogtreecommitdiffstats
path: root/prh-app-server/src/main/java
diff options
context:
space:
mode:
authorJoanna Jeremicz <joanna.jeremicz@nokia.com>2019-03-08 09:48:09 +0100
committerJoanna Jeremicz <joanna.jeremicz@nokia.com>2019-03-12 10:59:06 +0100
commitc69d68d5669e45c969fd1293aa76c78d55a95dca (patch)
treefee7e38468fce8a49db12cf4fb2f2b1e0cefd9c5 /prh-app-server/src/main/java
parentdf2c17cd5619d6ca069f73342a9aaafbdf0bba59 (diff)
Add AdditionalFields in PNF_Ready event
Enhance the PNF_Ready event with AdditionalFields contents and remove IP information Change-Id: Iacef7e11dd104868440984a0540b2ccd31c8b036 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.java82
-rw-r--r--prh-app-server/src/main/java/org/onap/dcaegen2/services/prh/service/PnfRegistrationFields.java8
2 files changed, 41 insertions, 49 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 7532c5d8..295cd7ca 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
@@ -36,19 +36,19 @@ import java.util.Optional;
import java.util.stream.StreamSupport;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.COMMON_EVENT_HEADER;
-import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.COMMON_FORMAT;
+import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.COMMON_FORMAT_FOR_STRING;
+import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.COMMON_FORMAT_FOR_JSON_OBJECT;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.CORRELATION_ID;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.EQUIP_MODEL;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.EQUIP_TYPE;
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;
import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.SW_VERSION;
+import static org.onap.dcaegen2.services.prh.service.PnfRegistrationFields.ADDITIONAL_FIELDS;
/**
@@ -59,14 +59,13 @@ public class DmaapConsumerJsonParser {
private static final Logger LOGGER = LoggerFactory.getLogger(DmaapConsumerJsonParser.class);
private String pnfSourceName;
- private String pnfOamIpv4Address;
- private String pnfOamIpv6Address;
- private String pnfSerialNumberAdditionalField;
- private String pnfEquipVendorAdditionalField;
- private String pnfEquipModelAdditionalField;
- private String pnfEquipTypeAdditionalField;
- private String pnfNfRoleAdditionalField;
- private String pnfSwVersionAdditionalField;
+ private String pnfSerialNumberOptionalField;
+ private String pnfEquipVendorOptionalField;
+ private String pnfEquipModelOptionalField;
+ private String pnfEquipTypeOptionalField;
+ private String pnfNfRoleOptionalField;
+ private String pnfSwVersionOptionalField;
+ private JsonObject pnfAdditionalFields;
/**
* Extract info from string and create @see {@link org.onap.dcaegen2.services.prh.model.ConsumerDmaapModel}.
@@ -119,58 +118,51 @@ public class DmaapConsumerJsonParser {
.getAsJsonObject(PNF_REGISTRATION_FIELDS);
this.pnfSourceName = getValueFromJson(commonEventHeader, SOURCE_NAME);
- this.pnfNfRoleAdditionalField = getValueFromJson(commonEventHeader, NF_ROLE);
+ this.pnfNfRoleOptionalField = getValueFromJson(commonEventHeader, NF_ROLE);
- this.pnfOamIpv4Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_4_ADDRESS);
- this.pnfOamIpv6Address = getValueFromJson(pnfRegistrationFields, OAM_IPV_6_ADDRESS);
- this.pnfSerialNumberAdditionalField = getValueFromJson(pnfRegistrationFields, SERIAL_NUMBER);
- this.pnfEquipVendorAdditionalField = getValueFromJson(pnfRegistrationFields, EQUIP_VENDOR);
- this.pnfEquipModelAdditionalField = getValueFromJson(pnfRegistrationFields, EQUIP_MODEL);
- this.pnfEquipTypeAdditionalField = getValueFromJson(pnfRegistrationFields, EQUIP_TYPE);
- this.pnfSwVersionAdditionalField = getValueFromJson(pnfRegistrationFields, SW_VERSION);
+ this.pnfSerialNumberOptionalField = getValueFromJson(pnfRegistrationFields, SERIAL_NUMBER);
+ this.pnfEquipVendorOptionalField = getValueFromJson(pnfRegistrationFields, EQUIP_VENDOR);
+ this.pnfEquipModelOptionalField = getValueFromJson(pnfRegistrationFields, EQUIP_MODEL);
+ this.pnfEquipTypeOptionalField = getValueFromJson(pnfRegistrationFields, EQUIP_TYPE);
+ this.pnfSwVersionOptionalField = getValueFromJson(pnfRegistrationFields, SW_VERSION);
+ this.pnfAdditionalFields = pnfRegistrationFields.getAsJsonObject(ADDITIONAL_FIELDS);
- return (StringUtils.isEmpty(pnfSourceName) || !ipPropertiesNotEmpty(pnfOamIpv4Address, pnfOamIpv6Address))
+ return (StringUtils.isEmpty(pnfSourceName))
? logErrorAndReturnMonoEmpty("Incorrect json, consumerDmaapModel can not be created: "
+ printMessage()) :
Mono.just(ImmutableConsumerDmaapModel.builder()
.correlationId(pnfSourceName)
- .ipv4(pnfOamIpv4Address)
- .ipv6(pnfOamIpv6Address)
- .serialNumber(pnfSerialNumberAdditionalField)
- .equipVendor(pnfEquipVendorAdditionalField)
- .equipModel(pnfEquipModelAdditionalField)
- .equipType(pnfEquipTypeAdditionalField)
- .nfRole(pnfNfRoleAdditionalField)
- .swVersion(pnfSwVersionAdditionalField).build());
+ .serialNumber(pnfSerialNumberOptionalField)
+ .equipVendor(pnfEquipVendorOptionalField)
+ .equipModel(pnfEquipModelOptionalField)
+ .equipType(pnfEquipTypeOptionalField)
+ .nfRole(pnfNfRoleOptionalField)
+ .swVersion(pnfSwVersionOptionalField)
+ .additionalFields(Optional.ofNullable(pnfAdditionalFields).orElse(new JsonObject())).build());
}
private String getValueFromJson(JsonObject jsonObject, String jsonKey) {
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);
}
private String printMessage() {
return String.format("%n{"
- + "\"" + CORRELATION_ID + COMMON_FORMAT + ","
- + "\"" + OAM_IPV_4_ADDRESS + COMMON_FORMAT + ","
- + "\"" + OAM_IPV_6_ADDRESS + COMMON_FORMAT + ","
- + "\"" + SERIAL_NUMBER + COMMON_FORMAT + ","
- + "\"" + EQUIP_VENDOR + COMMON_FORMAT + ","
- + "\"" + EQUIP_MODEL + COMMON_FORMAT + ","
- + "\"" + EQUIP_TYPE + COMMON_FORMAT + ","
- + "\"" + NF_ROLE + COMMON_FORMAT + ","
- + "\"" + SW_VERSION + COMMON_FORMAT
- + "%n}", this.pnfSourceName, this.pnfOamIpv4Address, this.pnfOamIpv6Address,
- this.pnfSerialNumberAdditionalField, this.pnfEquipVendorAdditionalField,
- this.pnfEquipModelAdditionalField, this.pnfEquipTypeAdditionalField,
- this.pnfNfRoleAdditionalField, this.pnfSwVersionAdditionalField
+ + "\"" + CORRELATION_ID + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + SERIAL_NUMBER + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + EQUIP_VENDOR + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + EQUIP_MODEL + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + EQUIP_TYPE + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + NF_ROLE + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + SW_VERSION + COMMON_FORMAT_FOR_STRING + ","
+ + "\"" + ADDITIONAL_FIELDS + COMMON_FORMAT_FOR_JSON_OBJECT
+ + "%n}", this.pnfSourceName,
+ 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 a9a28c0c..696bbba6 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
@@ -23,22 +23,22 @@ package org.onap.dcaegen2.services.prh.service;
class PnfRegistrationFields {
- static final String COMMON_FORMAT = "\": \"%s\"";
+ static final String COMMON_FORMAT_FOR_STRING = "\": \"%s\"";
+ static final String COMMON_FORMAT_FOR_JSON_OBJECT = "\": %s";
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";
- // additional fields
+ // optional fields
static final String SERIAL_NUMBER = "serialNumber";
static final String EQUIP_VENDOR = "vendorName";
static final String EQUIP_MODEL = "modelNumber";
static final String EQUIP_TYPE = "unitType";
static final String NF_ROLE = "nfNamingCode";
static final String SW_VERSION = "softwareVersion";
+ static final String ADDITIONAL_FIELDS = "additionalFields";
private PnfRegistrationFields() {}
}