2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
20 package org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.tasks;
22 import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.CREATE_VNF_RESPONSE_PARAM_NAME;
23 import static org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.CamundaVariableNameConstants.OPERATION_STATUS_PARAM_NAME;
24 import org.camunda.bpm.engine.delegate.DelegateExecution;
25 import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.CreateVnfResponse;
26 import org.onap.so.adapters.etsisol003adapter.lcm.v1.model.OperationStateEnum;
27 import org.onap.so.etsi.nfvo.ns.lcm.bpmn.flows.extclients.vnfm.Sol003AdapterServiceProvider;
28 import org.onap.so.etsi.nfvo.ns.lcm.database.service.DatabaseServiceProvider;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.stereotype.Component;
35 * @author Waqas Ikram (waqas.ikram@est.tech)
39 public class MonitorSol003AdapterCreateJobTask extends MonitorSol003AdapterJobTask {
41 private static final Logger LOGGER = LoggerFactory.getLogger(MonitorSol003AdapterCreateJobTask.class);
44 public MonitorSol003AdapterCreateJobTask(final Sol003AdapterServiceProvider sol003AdapterServiceProvider,
45 final DatabaseServiceProvider databaseServiceProvider) {
46 super(sol003AdapterServiceProvider, databaseServiceProvider);
49 public void getCurrentOperationStatus(final DelegateExecution execution) {
51 LOGGER.debug("Executing getCurrentOperationStatus ...");
52 final CreateVnfResponse vnfInstantiateResponse =
53 (CreateVnfResponse) execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
54 execution.setVariable(OPERATION_STATUS_PARAM_NAME,
55 getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
56 LOGGER.debug("Finished executing getCurrentOperationStatus ...");
57 } catch (final Exception exception) {
58 final String message = "Unable to invoke get current Operation status";
59 LOGGER.error(message, exception);
60 abortOperation(execution, message);
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 DelegateExecution execution) {
71 final String message = "Instantiation operation time out";
72 LOGGER.error(message);
73 abortOperation(execution, message);
77 * Check the final status of instantiation throw exception if not completed successfully
79 * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
81 public void checkIfOperationWasSuccessful(final DelegateExecution execution) {
82 LOGGER.debug("Executing checkIfOperationWasSuccessful ...");
83 final OperationStateEnum operationStatus =
84 (OperationStateEnum) execution.getVariable(OPERATION_STATUS_PARAM_NAME);
85 final CreateVnfResponse vnfInstantiateResponse =
86 (CreateVnfResponse) execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
88 if (operationStatus == null) {
89 final String message = "Unable to instantiate jobId: "
90 + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null")
91 + "Unable to retrieve OperationStatus";
92 LOGGER.error(message);
93 abortOperation(execution, message);
95 if (operationStatus != OperationStateEnum.COMPLETED) {
96 final String message = "Unable to instantiate jobId: "
97 + (vnfInstantiateResponse != null ? vnfInstantiateResponse.getJobId() : "null")
98 + " OperationStatus: " + operationStatus;
99 LOGGER.error(message);
100 abortOperation(execution, message);
103 LOGGER.debug("Successfully completed instatiation of job {}", vnfInstantiateResponse);