2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2020 Nordix
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
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
22 import org.camunda.bpm.engine.delegate.DelegateExecution;
23 import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext;
24 import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable;
25 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
26 import org.onap.so.client.cds.AbstractCDSProcessingBBUtils;
27 import org.onap.so.client.cds.GeneratePayloadForCds;
28 import org.onap.so.client.cds.PayloadConstants;
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 pnf, DelegateExecution is being used.
39 * @param - DelegateExecution
42 public class GenericPnfCDSProcessingDE implements ControllerRunnable<DelegateExecution> {
43 private static final Logger logger = LoggerFactory.getLogger(GenericPnfCDSProcessingDE.class);
44 private static final String EXECUTION_OBJECT = "executionObject";
45 private static final String ASSIGN_ACTION = "config-assign";
46 private static final String DEPLOY_ACTION = "config-deploy";
49 private ExceptionBuilder exceptionBuilder;
52 private AbstractCDSProcessingBBUtils cdsDispather;
55 private GeneratePayloadForCds generatePayloadForCds;
58 public Boolean understand(ControllerContext<DelegateExecution> context) {
59 final String scope = context.getControllerScope();
60 return PayloadConstants.CDS_ACTOR.equalsIgnoreCase(context.getControllerActor())
61 && PayloadConstants.PNF_SCOPE.equalsIgnoreCase(scope)
62 && !(ASSIGN_ACTION.equalsIgnoreCase(context.getControllerAction())
63 || DEPLOY_ACTION.equalsIgnoreCase(context.getControllerAction()));
67 public Boolean ready(ControllerContext<DelegateExecution> context) {
72 public void prepare(ControllerContext<DelegateExecution> context) {
73 DelegateExecution delegateExecution = context.getExecution();
75 AbstractCDSPropertiesBean abstractCDSPropertiesBean =
76 generatePayloadForCds.buildCdsPropertiesBean(delegateExecution);
78 delegateExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean);
80 } catch (Exception ex) {
81 logger.error("An exception occurred when creating payload for CDS request", ex);
82 exceptionBuilder.buildAndThrowWorkflowException(delegateExecution, 7000, ex);
87 public void run(ControllerContext<DelegateExecution> context) {
88 DelegateExecution obj = context.getExecution();
89 cdsDispather.constructExecutionServiceInputObject(obj);
90 cdsDispather.sendRequestToCDSClient(obj);