2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 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.onap.so.bpmn.infrastructure.workflow.tasks;
23 import java.util.ArrayList;
24 import java.util.List;
26 import org.camunda.bpm.engine.delegate.BpmnError;
27 import org.camunda.bpm.engine.delegate.DelegateExecution;
28 import org.onap.so.bpmn.common.BuildingBlockExecution;
29 import org.onap.so.bpmn.common.workflow.context.WorkflowCallbackResponse;
30 import org.onap.so.bpmn.common.workflow.context.WorkflowContextHolder;
31 import org.onap.so.bpmn.core.WorkflowException;
32 import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
33 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
34 import org.onap.so.client.exception.ExceptionBuilder;
35 import org.onap.so.db.request.beans.InfraActiveRequests;
36 import org.onap.so.db.request.client.RequestsDbClient;
37 import org.onap.so.serviceinstancebeans.RequestReferences;
38 import org.onap.so.serviceinstancebeans.ServiceInstancesResponse;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
41 import org.springframework.beans.factory.annotation.Autowired;
42 import org.springframework.stereotype.Component;
44 import com.fasterxml.jackson.core.JsonProcessingException;
45 import com.fasterxml.jackson.databind.ObjectMapper;
48 public class FlowCompletionTasks {
50 private static final Logger logger = LoggerFactory.getLogger(FlowCompletionTasks.class);
53 private RequestsDbClient requestDbclient;
55 public void updateRequestDbStatus(BuildingBlockExecution execution) {
57 String requestId = execution.getGeneralBuildingBlock().getRequestContext().getMsoRequestId();
58 InfraActiveRequests request = requestDbclient.getInfraActiveRequestbyRequestId(requestId);
60 WorkflowException workflowException = (WorkflowException) execution.getVariable("WorkflowException");
61 if (workflowException == null) {
62 request.setStatusMessage("RequestCompletedSuccessfully");
63 request.setRequestStatus("COMPLETE");
67 request.setStatusMessage(workflowException.getErrorMessage());
68 request.setRequestStatus("FAILED");
70 request.setProgress(100L);
71 request.setLastModifiedBy("CamundaBPMN");
73 requestDbclient.updateInfraActiveRequests(request);
74 } catch (Exception e) {
75 logger.error("Unable to save the updated request status to the DB",e);