2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask;
24 import org.camunda.bpm.engine.delegate.DelegateExecution;
25 import org.openecomp.mso.bpmn.core.WorkflowException;
26 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.GenericResourceApi;
27 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.ServiceRpcInputEntityBuilder;
28 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcServiceTopologyOperationInputEntity;
29 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.RpcServiceTopologyOperationOutputEntity;
30 import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.entity.ServiceTopologyOperationOutputEntity;
31 import org.openecomp.mso.requestsdb.RequestsDbConstant;
36 * Created by 10112215 on 2017/9/26.
38 public class SdncServiceTopologyOperationTask extends AbstractSdncOperationTask {
40 public void sendRestrequestAndHandleResponse(DelegateExecution execution,
41 Map<String, String> inputs,
42 GenericResourceApi genericResourceApiClient) throws Exception {
43 // updateProgress(execution, null, null, "40", "sendRestrequestAndHandleResponse begin!");
44 ServiceRpcInputEntityBuilder builder = new ServiceRpcInputEntityBuilder();
45 RpcServiceTopologyOperationInputEntity inputEntity = builder.build(execution, inputs);
46 // updateProgress(execution, null, null, "50", "RequestBody build finished!");
47 RpcServiceTopologyOperationOutputEntity outputEntity = genericResourceApiClient.postServiceTopologyOperation(inputEntity).execute().body();
48 // updateProgress(execution, null, null, "90", "sendRestrequestAndHandleResponse finished!");
49 saveOutput(execution, outputEntity);
52 private void saveOutput(DelegateExecution execution, RpcServiceTopologyOperationOutputEntity output) throws Exception {
53 String responseCode = output.getOutput().getResponseCode();
54 if (!"200".equals(responseCode)) {
55 String processKey = getProcessKey(execution);
56 int errorCode = Integer.valueOf(responseCode);
57 String errorMessage = output.getOutput().getResponseMessage();
58 WorkflowException workflowException = new WorkflowException(processKey, errorCode, errorMessage);
59 execution.setVariable("SDNCA_SuccessIndicator", workflowException);
60 // updateProgress(execution, RequestsDbConstant.Status.ERROR, String.valueOf(errorCode), null, errorMessage);
61 throw new Exception("");