diff options
Diffstat (limited to 'prh-commons/src/main')
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java | 6 | ||||
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java index d8eefec1..f6b817ef 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/ConsumerDmaapModel.java @@ -38,6 +38,12 @@ public interface ConsumerDmaapModel extends AaiModel, DmaapModel { @SerializedName(value = "correlationId", alternate = "correlationId") String getCorrelationId(); + @SerializedName(value = "ipaddress-v4-oam", alternate = "ipaddress-v4-oam") + String getIpv4(); + + @SerializedName(value = "ipaddress-v6-oam", alternate = "ipaddress-v6-oam") + String getIpv6(); + @SerializedName(value = "serial-number", alternate = "serial-number") String getSerialNumber(); diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java index f04168c2..d031b1b5 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/JsonBodyBuilderImpl.java @@ -42,7 +42,9 @@ public class JsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> public String createJsonBody(ConsumerDmaapModel consumerDmaapModel) { GsonBuilder gsonBuilder = new GsonBuilder(); ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); - return filterOutAdditionalFieldsIfEmpty(gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder() + return filterOutRedundantFields(gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder() + .ipv4(consumerDmaapModel.getIpv4()) + .ipv6(consumerDmaapModel.getIpv6()) .correlationId(consumerDmaapModel.getCorrelationId()) .serialNumber(consumerDmaapModel.getSerialNumber()) .equipVendor(consumerDmaapModel.getEquipVendor()) @@ -54,11 +56,13 @@ public class JsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> .build())); } - private String filterOutAdditionalFieldsIfEmpty(String json) { + private String filterOutRedundantFields(String json) { JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject(); if(jsonObject.get(ADDITIONAL_FIELDS).equals(new JsonObject())) { jsonObject.remove(ADDITIONAL_FIELDS); } + jsonObject.remove("ipaddress-v4-oam"); + jsonObject.remove("ipaddress-v6-oam"); return jsonObject.toString(); } }
\ No newline at end of file |