2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
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.pnf.delegate;
22 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.EXECUTION_OBJECT;
23 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MSO_REQUEST_ID;
24 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PNF_UUID;
25 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME;
26 import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION;
28 import org.camunda.bpm.engine.delegate.DelegateExecution;
29 import org.camunda.bpm.engine.delegate.JavaDelegate;
30 import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean;
31 import org.onap.so.client.exception.ExceptionBuilder;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34 import org.springframework.beans.factory.annotation.Autowired;
37 * Abstract class for preparing CDS call.
39 public abstract class PrepareCdsCallDelegate implements JavaDelegate {
41 protected Logger logger = LoggerFactory.getLogger(this.getClass());
43 protected static final String ORIGINATOR_ID = "SO";
44 protected static final int ERROR_CODE = 7010;
46 protected String actionName;
47 protected String mode;
50 protected ExceptionBuilder exceptionUtil;
53 public void execute(DelegateExecution delegateExecution){
55 logger.debug("Running execute block for activity:{}", delegateExecution.getCurrentActivityId());
56 AbstractCDSPropertiesBean cdsPropertiesBean = new AbstractCDSPropertiesBean();
57 cdsPropertiesBean.setBlueprintName((String) delegateExecution.getVariable(PRC_BLUEPRINT_NAME));
58 cdsPropertiesBean.setBlueprintVersion((String) delegateExecution.getVariable(PRC_BLUEPRINT_VERSION));
59 cdsPropertiesBean.setOriginatorId(ORIGINATOR_ID);
60 cdsPropertiesBean.setActionName(getActionName());
61 cdsPropertiesBean.setMode(getMode());
62 cdsPropertiesBean.setRequestId((String) delegateExecution.getVariable(MSO_REQUEST_ID));
63 cdsPropertiesBean.setSubRequestId((String) delegateExecution.getVariable(PNF_UUID));
64 cdsPropertiesBean.setRequestObject(getRequestObject(delegateExecution));
65 delegateExecution.setVariable(EXECUTION_OBJECT, cdsPropertiesBean);
69 * Return the request object sent to CDS call.
71 * @param delegateExecution BPMN delegateExecution context
72 * @return string value of the request object
74 protected abstract String getRequestObject(final DelegateExecution delegateExecution);
76 public String getActionName() {
80 public String getMode() {