aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
index cc99f178bd..8c1e8f6d62 100644
--- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIServiceInstanceResources.java
@@ -181,9 +181,27 @@ public class AAIServiceInstanceResources {
.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstance.getServiceInstanceId()));
org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance =
aaiObjectMapper.mapServiceInstance(serviceInstance);
+ mapEmptyStringsToNull(aaiServiceInstance);
injectionHelper.getAaiClient().update(serviceInstanceURI, aaiServiceInstance);
}
+ /*
+ * Per serialization configurations in GraphInventoryCommonObjectMapperPatchProvider, empty strings are mapped to
+ * null and included in the payload. Null values are on the other hand excluded. Passing null values in a PATCH
+ * request to AAI will fail. We need to map empty strings to null before serialization in order to exclude these
+ * values from the payload.
+ */
+ private void mapEmptyStringsToNull(org.onap.aai.domain.yang.ServiceInstance serviceInstance) {
+ if (serviceInstance != null) {
+ if ("".equals(serviceInstance.getServiceType()))
+ serviceInstance.setServiceType(null);
+ if ("".equals(serviceInstance.getServiceRole()))
+ serviceInstance.setServiceRole(null);
+ if ("".equals(serviceInstance.getServiceFunction()))
+ serviceInstance.setServiceFunction(null);
+ }
+ }
+
public boolean checkInstanceServiceNameInUse(ServiceInstance serviceInstance) {
AAIPluralResourceUri uriSI = AAIUriFactory.createNodesUri(Types.SERVICE_INSTANCES.getFragment())
.queryParam("service-instance-name", serviceInstance.getServiceInstanceName());