diff options
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java')
-rw-r--r-- | bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java index bea7a129fa..ed2411a30e 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/workflow/serviceTask/SdncServiceTopologyOperationTask.java @@ -21,14 +21,18 @@ package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.msb.sdk.discovery.common.RouteException; 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.HeaderUtil; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.ServiceRpcInputEntityBuilder; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcServiceTopologyOperationInputEntity; import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcServiceTopologyOperationOutputEntity; -import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.ServiceTopologyOperationOutputEntity; -import org.openecomp.mso.requestsdb.RequestsDbConstant; +import org.openecomp.mso.logger.MessageEnum; import java.util.Map; @@ -36,6 +40,9 @@ import java.util.Map; * Created by 10112215 on 2017/9/26. */ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask { + + private static final String URL = "/restconf/operations/GENERIC-RESOURCE-API:service-topology-operation"; + @Override public void sendRestrequestAndHandleResponse(DelegateExecution execution, Map<String, String> inputs, @@ -44,9 +51,27 @@ public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder(); RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs); // updateProgress(execution, null, null, "50", "RequestBody build finished!"); - RpcServiceTopologyOperationOutputEntity outputEntity = genericResourceApiClient.postServiceTopologyOperation(inputEntity).execute().body(); + RpcServiceTopologyOperationOutputEntity outputEntity; + if (!isSend2SdncDirectly()) { + outputEntity = genericResourceApiClient.postServiceTopologyOperation + (HeaderUtil.DefaulAuth, inputEntity).execute().body(); // updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!"); - saveOutput(execution, outputEntity); + saveOutput(execution, outputEntity); + } else { + Send2SdncDirectly(HeaderUtil.DefaulAuth, inputEntity); + } + } + + private void Send2SdncDirectly(String defaulAuth, + RpcServiceTopologyOperationInputEntity inputEntity) throws RouteException { + String url = "http://" + getSdncIp() + ":" + getSdncPort() + URL; + HttpPost httpPost = new HttpPost(url); + httpPost.addHeader("Authorization", defaulAuth); + httpPost.addHeader("Content-type", "application/json"); + String postBody = getPostbody(inputEntity); + LOGGER.info(MessageEnum.RA_SEND_REQUEST_SDNC, postBody.toString(), "SDNC", ""); + httpPost.setEntity(new StringEntity(postBody, ContentType.APPLICATION_XML)); + httpPost(url, httpPost); } private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception { |