diff options
author | Joanna Jeremicz <joanna.jeremicz@nokia.com> | 2019-03-21 14:15:10 +0100 |
---|---|---|
committer | Joanna Jeremicz <joanna.jeremicz@nokia.com> | 2019-03-22 08:13:58 +0100 |
commit | c85d30c68054fe76eb0ffc9e9264336a37476451 (patch) | |
tree | 17cad272907dfeea252eb474e865daa18105a07b /prh-commons/src/main/java | |
parent | bccafdc99094a8ff9107f242b31f80e5a839b5c2 (diff) |
Remove IP requirement
Remove the requirement of at least one IP present in VES event.
Update IP information in AAI only if it is present and is not empty.
Change-Id: I83ae8990d45d71de4c839e43b5065db89b6c6a3a
Issue-ID: DCAEGEN2-1312
Signed-off-by: Joanna Jeremicz <joanna.jeremicz@nokia.com>
Diffstat (limited to 'prh-commons/src/main/java')
-rw-r--r-- | prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java index 8e95a75f..2be95ee3 100644 --- a/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java +++ b/prh-commons/src/main/java/org/onap/dcaegen2/services/prh/model/AaiJsonBodyBuilderImpl.java @@ -22,9 +22,11 @@ package org.onap.dcaegen2.services.prh.model; import com.google.gson.GsonBuilder; import com.google.gson.TypeAdapterFactory; +import org.onap.dcaegen2.services.prh.model.ImmutableConsumerDmaapModel.Builder; import org.onap.dcaegen2.services.sdk.rest.services.model.JsonBodyBuilder; import java.util.ServiceLoader; +import org.springframework.util.StringUtils; public class AaiJsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapModel> { @@ -39,9 +41,7 @@ public class AaiJsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapMode GsonBuilder gsonBuilder = new GsonBuilder(); ServiceLoader.load(TypeAdapterFactory.class).forEach(gsonBuilder::registerTypeAdapterFactory); - return gsonBuilder.create().toJson(ImmutableConsumerDmaapModel.builder() - .ipv4(consumerDmaapModel.getIpv4()) - .ipv6(consumerDmaapModel.getIpv6()) + Builder builder = ImmutableConsumerDmaapModel.builder() .correlationId(consumerDmaapModel.getCorrelationId()) .serialNumber(consumerDmaapModel.getSerialNumber()) .equipVendor(consumerDmaapModel.getEquipVendor()) @@ -49,7 +49,17 @@ public class AaiJsonBodyBuilderImpl implements JsonBodyBuilder<ConsumerDmaapMode .equipType(consumerDmaapModel.getEquipType()) .nfRole(consumerDmaapModel.getNfRole()) .swVersion(consumerDmaapModel.getSwVersion()) - .additionalFields(consumerDmaapModel.getAdditionalFields()) - .build()); + .additionalFields(consumerDmaapModel.getAdditionalFields()); + + String ipv4 = consumerDmaapModel.getIpv4(); + if (!StringUtils.isEmpty(ipv4)) { + builder.ipv4(ipv4); + } + String ipv6 = consumerDmaapModel.getIpv6(); + if (!StringUtils.isEmpty(ipv6)) { + builder.ipv6(ipv6); + } + + return gsonBuilder.create().toJson(builder.build()); } }
\ No newline at end of file |