aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-tasks
diff options
context:
space:
mode:
authorraviteja.karumuri <raviteja.karumuri@est.tech>2022-07-13 13:17:49 +0100
committerraviteja.karumuri <raviteja.karumuri@est.tech>2022-07-22 12:14:00 +0100
commit0248e0fe15cb1712e0216de64b0c4000bc2a1547 (patch)
tree1a5463c4806ac69ece3895e2553a52ceeefb7c7f /bpmn/so-bpmn-tasks
parentea82b9bcfd6584bd6f8a5c3e058f744c09e6e09d (diff)
[SO] SO BPMN Infra shall trigger Delete AS Instance workflow(s).
Issue-ID: SO-3885 Change-Id: I6e5a1501fcbb68b98ce0c7787d67996b96fa95f2 Signed-off-by: raviteja.karumuri <raviteja.karumuri@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-tasks')
-rw-r--r--bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java
new file mode 100644
index 0000000000..6bbb391ca9
--- /dev/null
+++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/cnfm/tasks/CnfDeleteTask.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2022 Ericsson. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.infrastructure.adapter.cnfm.tasks;
+
+import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
+import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.serviceinstancebeans.RequestDetails;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import static java.util.Objects.isNull;
+
+
+/**
+ * This class performs CNF Delete
+ *
+ * @author raviteja.karumuri@est.tech
+ */
+@Component
+public class CnfDeleteTask {
+
+ private static final String AS_INSTANCE_ID = "asInstanceid";
+ private static final Logger LOGGER = LoggerFactory.getLogger(CnfInstantiateTask.class);
+ private final ExceptionBuilder exceptionUtil;
+ private final CnfmHttpServiceProvider cnfmHttpServiceProvider;
+
+ @Autowired
+ public CnfDeleteTask(final CnfmHttpServiceProvider cnfmHttpServiceProvider, final ExceptionBuilder exceptionUtil) {
+ this.cnfmHttpServiceProvider = cnfmHttpServiceProvider;
+ this.exceptionUtil = exceptionUtil;
+ }
+
+ public void invokeCnfmToDeleteAsInstnace(final BuildingBlockExecution execution) {
+ try {
+ LOGGER.debug("Executing DelteAsInstance task ...");
+ final ExecuteBuildingBlock executeBuildingBlock =
+ (ExecuteBuildingBlock) execution.getVariable("buildingBlock");
+
+ final GeneralBuildingBlock generalBuildingBlock = execution.getGeneralBuildingBlock();
+
+ final RequestDetails requestDetails = executeBuildingBlock.getRequestDetails();
+ LOGGER.debug("RequestDetails of DeleteAsInstance: {}", requestDetails);
+
+ if (isNull(requestDetails) && isNull(requestDetails.getModelInfo())
+ && isNull(requestDetails.getRequestInfo()) && isNull(requestDetails.getCloudConfiguration())
+ && isNull(generalBuildingBlock)) {
+ LOGGER.error("Missing Mandatory attribute from RequestDetails: {} or GeneralBuildingBlock: {}",
+ requestDetails, generalBuildingBlock);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000,
+ "Missing Mandatory attribute from RequestDetails or GeneralBuildingBlock", ONAPComponents.SO);
+ }
+
+ LOGGER.debug("Finished executing DeleteAsInstance task ...");
+
+ } catch (final Exception exception) {
+ LOGGER.error("Unable to invoke DeleteAsInstance", exception);
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2001, exception);
+ }
+ }
+}