2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2022 Ericsson. All rights reserved.
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.bpmn.infrastructure.adapter.cnfm.tasks;
22 import org.onap.logging.filter.base.ONAPComponents;
23 import org.onap.so.bpmn.common.BuildingBlockExecution;
24 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
25 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
26 import org.onap.so.client.exception.ExceptionBuilder;
27 import org.onap.so.serviceinstancebeans.RequestDetails;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.stereotype.Component;
33 import static java.util.Objects.isNull;
37 * This class performs CNF Delete
39 * @author raviteja.karumuri@est.tech
42 public class CnfDeleteTask {
44 private static final String AS_INSTANCE_ID = "asInstanceid";
45 private static final Logger LOGGER = LoggerFactory.getLogger(CnfInstantiateTask.class);
46 private final ExceptionBuilder exceptionUtil;
47 private final CnfmHttpServiceProvider cnfmHttpServiceProvider;
50 public CnfDeleteTask(final CnfmHttpServiceProvider cnfmHttpServiceProvider, final ExceptionBuilder exceptionUtil) {
51 this.cnfmHttpServiceProvider = cnfmHttpServiceProvider;
52 this.exceptionUtil = exceptionUtil;
55 public void invokeCnfmToDeleteAsInstnace(final BuildingBlockExecution execution) {
57 LOGGER.debug("Executing DelteAsInstance task ...");
58 final ExecuteBuildingBlock executeBuildingBlock =
59 (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
61 final GeneralBuildingBlock generalBuildingBlock = execution.getGeneralBuildingBlock();
63 final RequestDetails requestDetails = executeBuildingBlock.getRequestDetails();
64 LOGGER.debug("RequestDetails of DeleteAsInstance: {}", requestDetails);
66 if (isNull(requestDetails) && isNull(requestDetails.getModelInfo())
67 && isNull(requestDetails.getRequestInfo()) && isNull(requestDetails.getCloudConfiguration())
68 && isNull(generalBuildingBlock)) {
69 LOGGER.error("Missing Mandatory attribute from RequestDetails: {} or GeneralBuildingBlock: {}",
70 requestDetails, generalBuildingBlock);
71 exceptionUtil.buildAndThrowWorkflowException(execution, 2000,
72 "Missing Mandatory attribute from RequestDetails or GeneralBuildingBlock", ONAPComponents.SO);
75 LOGGER.debug("Finished executing DeleteAsInstance task ...");
77 } catch (final Exception exception) {
78 LOGGER.error("Unable to invoke DeleteAsInstance", exception);
79 exceptionUtil.buildAndThrowWorkflowException(execution, 2001, exception);