2 * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix
3 * Foundation. ================================================================================ Licensed under the
4 * Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may
5 * obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
8 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
9 * either express or implied. See the License for the specific language governing permissions and limitations under the
12 * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
15 package org.onap.so.bpmn.infrastructure.pnf.delegate;
17 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT;
18 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
19 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
20 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
21 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
22 import org.camunda.bpm.engine.delegate.DelegateExecution;
23 import org.camunda.bpm.engine.delegate.JavaDelegate;
24 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
25 import org.onap.so.client.exception.ExceptionBuilder;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28 import org.springframework.beans.factory.annotation.Autowired;
31 * Abstract class for preparing CDS call.
33 public abstract class PrepareCdsCallDelegate implements JavaDelegate {
35 protected Logger logger = LoggerFactory.getLogger(this.getClass());
37 protected static final String ORIGINATOR_ID = "SO";
38 protected static final int ERROR_CODE = 7010;
40 protected String actionName;
41 protected String mode;
44 protected ExceptionBuilder exceptionUtil;
47 public void execute(DelegateExecution delegateExecution) {
49 logger.debug("Running execute block for activity:{}", delegateExecution.getCurrentActivityId());
50 AbstractCDSPropertiesBean cdsPropertiesBean = new AbstractCDSPropertiesBean();
51 cdsPropertiesBean.setBlueprintName((String) delegateExecution.getVariable(PRC_BLUEPRINT_NAME));
52 cdsPropertiesBean.setBlueprintVersion((String) delegateExecution.getVariable(PRC_BLUEPRINT_VERSION));
53 cdsPropertiesBean.setOriginatorId(ORIGINATOR_ID);
54 cdsPropertiesBean.setActionName(getActionName());
55 cdsPropertiesBean.setMode(getMode());
56 cdsPropertiesBean.setRequestId((String) delegateExecution.getVariable(MSO_REQUEST_ID));
57 cdsPropertiesBean.setSubRequestId((String) delegateExecution.getVariable(PNF_UUID));
58 cdsPropertiesBean.setRequestObject(getRequestObject(delegateExecution));
59 delegateExecution.setVariable(EXECUTION_OBJECT, cdsPropertiesBean);
63 * Return the request object sent to CDS call.
65 * @param delegateExecution BPMN delegateExecution context
66 * @return string value of the request object
68 protected abstract String getRequestObject(final DelegateExecution delegateExecution);
70 public String getActionName() {
74 public String getMode() {