summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskEntityImpl.java2
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskYangToolsImpl.java49
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java126
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/OutputEntity.java12
4 files changed, 182 insertions, 7 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskEntityImpl.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskEntityImpl.java
index a387756d7c..3cb5cd9fb1 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskEntityImpl.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskEntityImpl.java
@@ -32,7 +32,7 @@ public class SdncVlOperationTaskEntityImpl extends AbstractSdncVlOperationTask {
if (!responseCode.equals("200")) {
String processKey = getProcessKey(execution);
int errorCode = Integer.valueOf(responseCode);
- String errorMessage = output.getOutput().getEsponseMessage();
+ String errorMessage = output.getOutput().getResponseMessage();
WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage);
execution.setVariable("SDNCA_SuccessIndicator", workflowException);
updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage);
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskYangToolsImpl.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskYangToolsImpl.java
new file mode 100644
index 0000000000..0665a257aa
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncVlOperationTaskYangToolsImpl.java
@@ -0,0 +1,49 @@
+package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask;
+
+import okhttp3.RequestBody;
+import okhttp3.ResponseBody;
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.openecomp.mso.bpmn.core.WorkflowException;
+import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi;
+import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.NetworkTopologyRequestBodyBuilder;
+import org.openecomp.mso.requestsdb.RequestsDbConstant;
+import org.openecomp.mso.yangDecoder.transform.api.ITransformJava2StringService;
+import org.openecomp.mso.yangDecoder.transform.impl.TransfromJava2StringFactory;
+
+import java.util.Map;
+
+/**
+ * Created by 10112215 on 2017/9/20.
+ */
+public class SdncVlOperationTaskYangToolsImpl extends AbstractSdncVlOperationTask {
+
+ public void sendRestrequestAndHandleResponse(DelegateExecution execution,
+ Map<String, String> inputs,
+ GenericResourceApi genericResourceApiClient) throws Exception {
+ updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!");
+ NetworkTopologyRequestBodyBuilder builder = new NetworkTopologyRequestBodyBuilder();
+ RequestBody body = builder.build(inputs);
+ updateProgress(execution, null, null, "50", "RequestBody build finished!");
+ ResponseBody responseBody = genericResourceApiClient.postNetworkTopologyPeration(body).execute().body();
+ updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
+ saveResponse(execution, responseBody);
+ }
+
+ private void saveResponse(DelegateExecution execution, ResponseBody responseBody) throws Exception {
+ ITransformJava2StringService java2jsonService = TransfromJava2StringFactory.getJava2jsonService();
+ NetworkTopologyOperationOutput output = (NetworkTopologyOperationOutput) java2jsonService.
+ transformRpcDataObjectFromString(NetworkTopologyRequestBodyBuilder.URI_PATH, responseBody.string());
+ String responseCode = output.getResponseCode();
+ if (!responseCode.equals("200")) {
+ String processKey = getProcessKey(execution);
+ int errorCode = Integer.valueOf(responseCode);
+ String errorMessage = output.getResponseMessage();
+ WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage);
+ execution.setVariable("SDNCA_SuccessIndicator", workflowException);
+ updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage);
+ throw new Exception("");
+ }
+ }
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java
new file mode 100644
index 0000000000..8fc70ca0e3
--- /dev/null
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/builder/NetworkTopologyRequestBodyBuilder.java
@@ -0,0 +1,126 @@
+package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder;
+
+import okhttp3.RequestBody;
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONObject;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.request.input.NetworkRequestInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.request.input.network.request.input.NetworkInputParametersBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.Param;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.param.ParamKey;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder;
+import org.openecomp.mso.yangDecoder.transform.api.ITransformJava2StringService;
+import org.openecomp.mso.yangDecoder.transform.impl.TransfromJava2StringFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Created by 10112215 on 2017/9/20.
+ */
+public class NetworkTopologyRequestBodyBuilder implements AbstractBuilder<Map<String, String>, RequestBody> {
+
+ public static final String URI_PATH = "GENERIC-RESOURCE-API:network-topology-operation";
+ public static final SdncRequestHeader.SvcAction SVC_DEFAULT_ACTION = SdncRequestHeader.SvcAction.Create;
+ public static final String SVC_REQUEST_ID = "MSO";
+ public static final String SDC_ACTION = "SDC_ACTION";
+ public static final RequestInformation.RequestAction REQUEST_ACTION = RequestInformation.RequestAction.CreateNetworkInstance;
+ protected static ITransformJava2StringService java2jsonService;
+
+ static
+ {
+ try {
+ java2jsonService = TransfromJava2StringFactory.getJava2jsonService();
+ } catch (Exception e) {
+ e.printStackTrace();
+ java2jsonService = null;
+ }
+ }
+
+ @Override
+ public RequestBody build(Map<String, String> input) throws Exception {
+ NetworkTopologyOperationInput sdncInput = getSdncInput(input);
+ RequestBody body = getRequestBody(sdncInput);
+ return body;
+ }
+
+ protected String getJsonInput(NetworkTopologyOperationInput sdncInput) throws Exception {
+ return java2jsonService.transformRpcDataObjectToString(URI_PATH, sdncInput);
+ }
+
+ private RequestBody getRequestBody(NetworkTopologyOperationInput sdncInput) throws Exception {
+ String jsonString = getJsonInput(sdncInput);
+ String json = (new JSONObject(jsonString)).toString();
+ return RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),json);
+ }
+
+ protected NetworkTopologyOperationInput getSdncInput(Map<String, String> inputs) {
+ NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder = new NetworkTopologyOperationInputBuilder();
+ {
+ loadSdncRequestHeader(inputs, networkTopologyOperationInputBuilder);
+ loadRequestInformation(networkTopologyOperationInputBuilder);
+ loadNetworkInputParameters(inputs, networkTopologyOperationInputBuilder);
+ }
+ return networkTopologyOperationInputBuilder.build();
+ }
+
+ private void loadNetworkInputParameters(Map<String, String> inputs, NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) {
+ NetworkRequestInputBuilder networkRequestInputBuilder = new NetworkRequestInputBuilder();
+ {
+ NetworkInputParametersBuilder networkInputParametersBuilder = new NetworkInputParametersBuilder();
+ {
+ List<Param> paramList = getParamList(inputs);
+ networkInputParametersBuilder.setParam(paramList);
+ }
+ networkRequestInputBuilder.setNetworkInputParameters(networkInputParametersBuilder.build());
+ }
+ networkTopologyOperationInputBuilder.setNetworkRequestInput(networkRequestInputBuilder.build());
+ }
+
+ private void loadRequestInformation(NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) {
+ RequestInformationBuilder requestInformationBuilder = new RequestInformationBuilder();
+ {
+ requestInformationBuilder.setRequestId(SVC_REQUEST_ID);
+ requestInformationBuilder.setRequestAction(REQUEST_ACTION);
+ }
+ networkTopologyOperationInputBuilder.setRequestInformation(requestInformationBuilder.build());
+ }
+
+ private void loadSdncRequestHeader(Map<String, String> inputs, NetworkTopologyOperationInputBuilder networkTopologyOperationInputBuilder) {
+ SdncRequestHeaderBuilder sdncRequestHeaderBuilder = new SdncRequestHeaderBuilder();
+ {
+ sdncRequestHeaderBuilder.setSvcRequestId(SVC_REQUEST_ID);
+ SdncRequestHeader.SvcAction svcAction = SVC_DEFAULT_ACTION;
+ String action = inputs.get(SDC_ACTION);
+ if (!StringUtils.isBlank(action)) {
+ if (action.toLowerCase().contains("delete")) {
+ svcAction = SdncRequestHeader.SvcAction.Delete;
+ } else if (action.toLowerCase().contains("create")) {
+ svcAction = SdncRequestHeader.SvcAction.Create;
+ }
+ }
+ sdncRequestHeaderBuilder.setSvcAction(svcAction);
+ }
+ networkTopologyOperationInputBuilder.setSdncRequestHeader(sdncRequestHeaderBuilder.build());
+ }
+
+ private List<Param> getParamList(Map<String, String> inputs) {
+ List<Param> paramList = new ArrayList<>();
+ if (inputs != null && !inputs.isEmpty()) {
+ inputs.keySet().forEach(key -> {
+ ParamBuilder paramBuilder = new ParamBuilder();
+ paramBuilder.setName(key);
+ paramBuilder.setValue(inputs.get(key));
+ paramBuilder.setKey(new ParamKey(key));
+ paramList.add(paramBuilder.build());
+ });
+ }
+ return paramList;
+ }
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/OutputEntity.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/OutputEntity.java
index 48fb9f1594..a52919d0fd 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/OutputEntity.java
+++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/client/entity/OutputEntity.java
@@ -12,8 +12,8 @@ public class OutputEntity {
@JsonProperty("response-code")
private String responseCode;
- @JsonProperty("esponse-message")
- private String esponseMessage;
+ @JsonProperty("response-message")
+ private String responseMessage;
@JsonProperty("ack-final-indicator")
private String ackFinalIndicator;
@@ -40,12 +40,12 @@ public class OutputEntity {
this.responseCode = responseCode;
}
- public String getEsponseMessage() {
- return esponseMessage;
+ public String getResponseMessage() {
+ return responseMessage;
}
- public void setEsponseMessage(String esponseMessage) {
- this.esponseMessage = esponseMessage;
+ public void setResponseMessage(String responseMessage) {
+ this.responseMessage = responseMessage;
}
public String getAckFinalIndicator() {