aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks/src/main
diff options
context:
space:
mode:
authorElena Kuleshov <evn@att.com>2019-09-12 15:55:39 -0400
committerElena Kuleshov <evn@att.com>2019-09-12 15:55:39 -0400
commit4b5f7e4cd1b6aeaeecc3f430bae6b45c13db4c01 (patch)
treeb92c14ade8a7b1f6075a03650340dbc4a6e2af4d /bpmn/so-bpmn-tasks/src/main
parentf4f42b9b89880e8992c483255ed04863a3577f64 (diff)
Build payload APPC parameter from UserParams
If a payload parameter is not specified on VID request for APPC interaction, we will need to build it from UserParams from requestCOntext. Issue-ID: SO-2311 Signed-off-by: Kuleshov, Elena <evn@att.com> Change-Id: Ie6affe2bad031d80c43c0358a49cb252fb04f5e2
Diffstat (limited to 'bpmn/so-bpmn-tasks/src/main')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcRunTasks.java21
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);