2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (c) 2022 Deutsche telekom
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=========================================================
22 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
24 import org.onap.so.bpmn.common.BuildingBlockExecution;
25 import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
26 import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
27 import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
28 import org.onap.so.client.cds.GeneratePayloadForCds;
29 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
30 import org.onap.so.client.exception.ExceptionBuilder;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
33 import org.springframework.beans.factory.annotation.Autowired;
34 import org.springframework.stereotype.Component;
37 * This class is used in context of Building Block flow for configuration of vnf/vfmodule/service.
39 * @param - BuildingBlockExecution
42 public class NssiCDSProcessingBB implements ControllerRunnable<BuildingBlockExecution> {
43 private static final Logger logger = LoggerFactory.getLogger(NssiCDSProcessingBB.class);
44 private static final String EXECUTION_OBJECT = "executionObject";
45 public static final String CDS_ACTOR = "cds";
46 public static final String NSSI_SCOPE = "nssi";
49 private ExceptionBuilder exceptionBuilder;
52 private AbstractCDSProcessingBBUtils cdsDispather;
55 private GeneratePayloadForCds generatePayloadForCds;
58 public Boolean understand(ControllerContext<BuildingBlockExecution> context) {
59 String scope = context.getControllerScope();
60 return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) && NSSI_SCOPE.equalsIgnoreCase(scope);
64 public Boolean ready(ControllerContext<BuildingBlockExecution> context) {
69 public void prepare(ControllerContext<BuildingBlockExecution> context) {
70 BuildingBlockExecution buildingBlockExecution = context.getExecution();
72 AbstractCDSPropertiesBean abstractCDSPropertiesBean =
73 generatePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
74 buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
75 } catch (Exception ex) {
76 logger.error("An exception occurred when creating payload for CDS request", ex);
77 exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, ex);
82 public void run(ControllerContext<BuildingBlockExecution> context) {
83 BuildingBlockExecution obj = context.getExecution();
84 cdsDispather.constructExecutionServiceInputObjectBB(obj);
85 cdsDispather.sendRequestToCDSClientBB(obj);