2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Bell Canada
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=========================================================
21 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
23 import org.onap.so.bpmn.common.BuildingBlockExecution;
24 import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
25 import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
26 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
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 * For Vnf/Vf-Module/Service BuildingBlockExecution is being used.
39 * @param - BuildingBlockExecution
42 public class GenericCDSProcessingBB implements ControllerRunnable<BuildingBlockExecution> {
43 private static final Logger logger = LoggerFactory.getLogger(GenericCDSProcessingBB.class);
44 private static final String EXECUTION_OBJECT = "executionObject";
45 public static final String CDS_ACTOR = "cds";
46 public static final String VNF_SCOPE = "vnf";
47 public static final String VF_MODULE_SCOPE = "vf-module";
50 private ExceptionBuilder exceptionBuilder;
53 private ExtractPojosForBB extractPojosForBB;
56 private AbstractCDSProcessingBBUtils cdsDispather;
59 private GeneratePayloadForCds generatePayloadForCds;
62 public Boolean understand(ControllerContext<BuildingBlockExecution> context) {
63 String scope = context.getControllerScope();
64 return CDS_ACTOR.equalsIgnoreCase(context.getControllerActor())
65 && (VNF_SCOPE.equalsIgnoreCase(scope) || VF_MODULE_SCOPE.equalsIgnoreCase(scope));
69 public Boolean ready(ControllerContext<BuildingBlockExecution> context) {
74 public void prepare(ControllerContext<BuildingBlockExecution> context) {
75 BuildingBlockExecution buildingBlockExecution = context.getExecution();
77 AbstractCDSPropertiesBean abstractCDSPropertiesBean =
78 generatePayloadForCds.buildCdsPropertiesBean(buildingBlockExecution);
79 buildingBlockExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
80 } catch (Exception ex) {
81 logger.error("An exception occurred when creating payload for CDS request", ex);
82 exceptionBuilder.buildAndThrowWorkflowException(buildingBlockExecution, 7000, ex);
87 public void run(ControllerContext<BuildingBlockExecution> context) {
88 BuildingBlockExecution obj = context.getExecution();
89 cdsDispather.constructExecutionServiceInputObject(obj);
90 cdsDispather.sendRequestToCDSClient(obj);