From 4b5f7e4cd1b6aeaeecc3f430bae6b45c13db4c01 Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Thu, 12 Sep 2019 15:55:39 -0400 Subject: 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 Change-Id: Ie6affe2bad031d80c43c0358a49cb252fb04f5e2 --- .../infrastructure/appc/tasks/AppcRunTasks.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'bpmn/so-bpmn-tasks/src/main') 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 userParams) { + if (userParams == null || userParams.size() == 0) { + return null; + } + + String payload = "{}"; + for (Map.Entry 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); -- cgit 1.2.3-korg