diff options
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java')
-rw-r--r-- | bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java index 0f384096cb..4495e87789 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/AbstractSdncOperationTask.java @@ -22,16 +22,19 @@ package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask; import org.apache.commons.lang3.StringUtils; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.json.JSONObject; import org.onap.msb.sdk.httpclient.RestServiceCreater; import org.onap.msb.sdk.httpclient.msb.MSBServiceClient; -import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; import org.openecomp.mso.bpmn.core.BaseTask; +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi; import org.openecomp.mso.logger.MessageEnum; import org.openecomp.mso.logger.MsoLogger; import org.openecomp.mso.requestsdb.RequestsDatabase; import org.openecomp.mso.requestsdb.RequestsDbConstant; import org.openecomp.mso.requestsdb.ResourceOperationStatus; +import java.util.HashMap; import java.util.Map; /** @@ -41,7 +44,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private static final String DEFAULT_MSB_IP = "127.0.0.1"; private static final int DEFAULT_MSB_Port = 10081; - private static final String SDCADAPTOR_INPUTS = "SDCADAPTOR_INPUTS"; + private static final String SDCADAPTOR_INPUTS = "resourceParameters"; private RequestsDatabase requestsDB = RequestsDatabase.getInstance(); @@ -51,7 +54,7 @@ public abstract class AbstractSdncOperationTask extends BaseTask { public void execute(DelegateExecution execution) { GenericResourceApi genericResourceApiClient = getGenericResourceApiClient(execution); updateProgress(execution, RequestsDbConstant.Status.PROCESSING, null, "10", "execute begin!"); - Map<String, String> inputs = (Map<String, String>) execution.getVariable(SDCADAPTOR_INPUTS); + Map<String, String> inputs = getInputs(execution); updateProgress(execution, null, null, "30", "getGenericResourceApiClient finished!"); try { sendRestrequestAndHandleResponse(execution, inputs, genericResourceApiClient); @@ -63,6 +66,15 @@ public abstract class AbstractSdncOperationTask extends BaseTask { } } + protected Map<String, String> getInputs(DelegateExecution execution) { + Map<String, String> inputs = new HashMap<>(); + String json = (String) execution.getVariable(SDCADAPTOR_INPUTS); + JSONObject jsonObject = new JSONObject(json); + JSONObject paras = jsonObject.getJSONObject("additionalParamForNs"); + paras.keySet().stream().forEach(key -> inputs.put(key, paras.getString((String) key))); + return inputs; + } + public abstract void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, GenericResourceApi genericResourceApiClient) throws Exception; @@ -93,15 +105,16 @@ public abstract class AbstractSdncOperationTask extends BaseTask { private GenericResourceApi getGenericResourceApiClient(DelegateExecution execution) { updateProgress(execution, null, null, "20", "getGenericResourceApiClient begin!"); - String msbIp = getString(execution, "MSB_IP", DEFAULT_MSB_IP); - int msbPort = getInteger(execution, "MSB_Port", DEFAULT_MSB_Port); + Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties"); + String msbIp = getString(properties, "msb.address", DEFAULT_MSB_IP); + int msbPort = Integer.valueOf(getString(properties, "msb.port", String.valueOf(DEFAULT_MSB_Port))); MSBServiceClient msbClient = new MSBServiceClient(msbIp, msbPort); RestServiceCreater restServiceCreater = new RestServiceCreater(msbClient); return restServiceCreater.createService(GenericResourceApi.class); } - private String getString(DelegateExecution execution, String name, String defaultValue) { - String vlaue = (String) execution.getVariable(name); + private String getString(Map<String, String> properties, String name, String defaultValue) { + String vlaue = properties.get(name); try { if (!StringUtils.isBlank(vlaue)) { return vlaue; |