diff options
author | Steve Smokowski <ss835w@att.com> | 2019-09-17 14:09:25 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-09-17 14:09:25 +0000 |
commit | e288bedf6a7b83c6127cbb1bc4281084cdbc218e (patch) | |
tree | f20be82f539540b38755a33d85503faa78e64b0b /bpmn/so-bpmn-tasks/src/main/java/org | |
parent | 680401b41d5b53ef3de6613334415939ee435eae (diff) | |
parent | 4b5f7e4cd1b6aeaeecc3f430bae6b45c13db4c01 (diff) |
Merge "Build payload APPC parameter from UserParams"
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main/java/org')
-rw-r--r-- | bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java index 9c72d229b2..79ccd9216f 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java @@ -24,6 +24,7 @@ package org.onap.so.bpmn.infrastructure.appc.tasks; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Optional; import org.onap.so.logger.LoggingAnchor; import org.json.JSONArray; @@ -31,6 +32,7 @@ import org.json.JSONObject; import org.onap.aai.domain.yang.Vserver; import org.onap.appc.client.lcm.model.Action; import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.core.json.JsonUtils; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; @@ -166,6 +168,10 @@ public class AppcRunTasks { String pay = requestParameters.getPayload(); if (pay != null) { payload = Optional.of(pay); + } else { + String payloadFromUserParams = + buildPayloadFromUserParams(gBBInput.getRequestContext().getUserParams()); + payload = Optional.of(payloadFromUserParams); } } logger.debug("Running APP-C action: {}", action.toString()); @@ -221,6 +227,21 @@ public class AppcRunTasks { return payloadInfo; } + protected String buildPayloadFromUserParams(Map<String, Object> userParams) { + if (userParams == null || userParams.size() == 0) { + return null; + } + + String payload = "{}"; + for (Map.Entry<String, Object> entry : userParams.entrySet()) { + payload = JsonUtils.addJsonValue(payload, entry.getKey(), (String) entry.getValue()); + } + + payload = payload.replaceAll("\"", "\\\\\""); + payload = payload.replaceAll("\n", ""); + return payload; + } + protected void getVserversForAppc(BuildingBlockExecution execution, GenericVnf vnf) throws Exception { AAIResultWrapper aaiRW = aaiVnfResources.queryVnfWrapperById(vnf); |