2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Ericsson. All rights reserved.
4 * ================================================================================
5 * Modifications Copyright (c) 2019 Samsung
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.
19 * SPDX-License-Identifier: Apache-2.0
20 * ============LICENSE_END=========================================================
22 package org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks;
24 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.DELETE_VNF_RESPONSE_PARAM_NAME;
25 import static org.onap.so.bpmn.infrastructure.adapter.vnfm.tasks.Constants.OPERATION_STATUS_PARAM_NAME;
26 import org.onap.so.bpmn.common.BuildingBlockExecution;
27 import org.onap.so.client.exception.ExceptionBuilder;
28 import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
29 import org.onap.vnfmadapter.v1.model.OperationStateEnum;
30 import org.slf4j.Logger;
31 import org.slf4j.LoggerFactory;
32 import org.springframework.beans.factory.annotation.Autowired;
33 import org.springframework.stereotype.Component;
34 import com.google.common.base.Optional;
39 * @author Lathishbabu Ganesan (lathishbabu.ganesan@est.tech)
43 public class MonitorVnfmDeleteJobTask extends MonitorVnfmJobTask {
45 private static final Logger LOGGER = LoggerFactory.getLogger(MonitorVnfmDeleteJobTask.class);
48 public MonitorVnfmDeleteJobTask(final VnfmAdapterServiceProvider vnfmAdapterServiceProvider,
49 final ExceptionBuilder exceptionUtil) {
50 super(vnfmAdapterServiceProvider, exceptionUtil);
54 * Get the current operation status of Delete job
56 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
58 public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
59 LOGGER.debug("Executing getCurrentOperationStatus ...");
60 final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME);
61 execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, deleteVnfResponse.getJobId()));
62 LOGGER.debug("Finished executing getCurrentOperationStatus ...");
66 * Log and throw exception on timeout for job status
68 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
70 public void timeOutLogFailue(final BuildingBlockExecution execution) {
71 final String message = "Delete operation time out";
72 LOGGER.error(message);
73 exceptionUtil.buildAndThrowWorkflowException(execution, 1213, message);
77 * Check the final status of delete throw exception if not completed successfully
79 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
81 public void checkIfOperationWasSuccessful(final BuildingBlockExecution execution) {
82 LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
83 final Optional<OperationStateEnum> operationStatusOption = execution.getVariable(OPERATION_STATUS_PARAM_NAME);
84 final DeleteVnfResponse deleteVnfResponse = execution.getVariable(DELETE_VNF_RESPONSE_PARAM_NAME);
85 if (operationStatusOption == null || !operationStatusOption.isPresent()) {
86 final String message = "Unable to delete jobId: "
87 + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null") + "Unable to retrieve OperationStatus";
88 LOGGER.error(message);
89 exceptionUtil.buildAndThrowWorkflowException(execution, 1214, message);
90 } else if (operationStatusOption != null && operationStatusOption.isPresent()) {
91 final OperationStateEnum operationStatus = operationStatusOption.get();
92 if (operationStatus != OperationStateEnum.COMPLETED) {
93 final String message =
94 "Unable to Delete jobId: " + (deleteVnfResponse != null ? deleteVnfResponse.getJobId() : "null")
95 + " OperationStatus: " + operationStatus;
96 LOGGER.error(message);
97 exceptionUtil.buildAndThrowWorkflowException(execution, 1215, message);
99 LOGGER.debug("Successfully completed Deletion of job {}", deleteVnfResponse);