From 5fa8680d198315cfd11fc043a6f686ebd1d15cb6 Mon Sep 17 00:00:00 2001 From: tragait Date: Thu, 5 Dec 2019 18:04:31 +0000 Subject: SO-CDS PNF BB This commit implements code for PNF BB for pnf software upgrade usecase. Issue-ID: SO-2090 Signed-off-by: tragait Change-Id: I3da3ba965bc92fda0ecc542d42afe694f19e06e1 Signed-off-by: tragait --- .../camunda/controller/cds/CdsControllerDE.java | 64 --------------- .../controller/cds/PnfConfigCdsControllerDE.java | 71 +++++++++++++++++ .../tasks/GenericPnfCDSProcessingDE.java | 92 ++++++++++++++++++++++ 3 files changed, 163 insertions(+), 64 deletions(-) delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java (limited to 'bpmn/so-bpmn-tasks/src/main/java/org/onap') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java deleted file mode 100644 index 0f65b4b3d4..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/CdsControllerDE.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ -package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.cds; - -import java.util.List; -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; -import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; -import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; -import org.onap.so.client.cds.AbstractCDSProcessingBBUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * This implementation of {@ref ControllerRunnable} is used for Self service, i.e, blueprint based Controller. - */ -@Component -public class CdsControllerDE implements ControllerRunnable { - - @Autowired(required = false) - private List> prepareList; - - @Autowired - private AbstractCDSProcessingBBUtils abstractCDSProcessingBBUtils; - - @Override - public Boolean understand(ControllerContext context) { - return context.getControllerActor().equalsIgnoreCase("cds"); - } - - @Override - public Boolean ready(ControllerContext context) { - return true; - } - - @Override - public void prepare(ControllerContext context) { - prepareList.stream().filter(prepare -> prepare.understand(context)) - .forEach(prepare -> prepare.prepare(context)); - } - - @Override - public void run(ControllerContext context) { - DelegateExecution execution = context.getExecution(); - abstractCDSProcessingBBUtils.constructExecutionServiceInputObject(execution); - abstractCDSProcessingBBUtils.sendRequestToCDSClient(execution); - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java new file mode 100644 index 0000000000..ffd49e6b84 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/impl/camunda/controller/cds/PnfConfigCdsControllerDE.java @@ -0,0 +1,71 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.so.bpmn.infrastructure.decisionpoint.impl.camunda.controller.cds; + +import java.util.List; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.controller.ControllerPreparable; +import org.onap.so.client.cds.AbstractCDSProcessingBBUtils; +import org.onap.so.client.cds.PayloadConstants; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * This implementation of {@ref ControllerRunnable} is used for Self service, i.e, blueprint based Controller. + */ +@Component +public class PnfConfigCdsControllerDE implements ControllerRunnable { + + private static final String ASSIGN_ACTION = "config-assign"; + private static final String DEPLOY_ACTION = "config-deploy"; + + @Autowired(required = false) + private List> prepareList; + + @Autowired + private AbstractCDSProcessingBBUtils cdsDispatcher; + + @Override + public Boolean understand(ControllerContext context) { + return PayloadConstants.CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) + && PayloadConstants.PNF_SCOPE.equalsIgnoreCase(context.getControllerScope()) + && (ASSIGN_ACTION.equalsIgnoreCase(context.getControllerAction()) + || DEPLOY_ACTION.equalsIgnoreCase(context.getControllerAction())); // legacy behavior + } + + @Override + public Boolean ready(ControllerContext context) { + return true; + } + + @Override + public void prepare(ControllerContext context) { + prepareList.stream().filter(prepare -> prepare.understand(context)) + .forEach(prepare -> prepare.prepare(context)); + } + + @Override + public void run(ControllerContext context) { + DelegateExecution execution = context.getExecution(); + cdsDispatcher.constructExecutionServiceInputObject(execution); + cdsDispatcher.sendRequestToCDSClient(execution); + } +} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java new file mode 100644 index 0000000000..d5423b2ff7 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/flowspecific/tasks/GenericPnfCDSProcessingDE.java @@ -0,0 +1,92 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.flowspecific.tasks; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.cds.AbstractCDSProcessingBBUtils; +import org.onap.so.client.cds.GeneratePayloadForCds; +import org.onap.so.client.cds.PayloadConstants; +import org.onap.so.client.cds.beans.AbstractCDSPropertiesBean; +import org.onap.so.client.exception.ExceptionBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * For pnf, DelegateExecution is being used. + * + * @param - DelegateExecution + */ +@Component +public class GenericPnfCDSProcessingDE implements ControllerRunnable { + private static final Logger logger = LoggerFactory.getLogger(GenericPnfCDSProcessingDE.class); + private static final String EXECUTION_OBJECT = "executionObject"; + private static final String ASSIGN_ACTION = "config-assign"; + private static final String DEPLOY_ACTION = "config-deploy"; + + @Autowired + private ExceptionBuilder exceptionBuilder; + + @Autowired + private AbstractCDSProcessingBBUtils cdsDispather; + + @Autowired + private GeneratePayloadForCds generatePayloadForCds; + + @Override + public Boolean understand(ControllerContext context) { + final String scope = context.getControllerScope(); + return PayloadConstants.CDS_ACTOR.equalsIgnoreCase(context.getControllerActor()) + && PayloadConstants.PNF_SCOPE.equalsIgnoreCase(scope) + && !(ASSIGN_ACTION.equalsIgnoreCase(context.getControllerAction()) + || DEPLOY_ACTION.equalsIgnoreCase(context.getControllerAction())); + } + + @Override + public Boolean ready(ControllerContext context) { + return true; + } + + @Override + public void prepare(ControllerContext context) { + DelegateExecution delegateExecution = context.getExecution(); + try { + AbstractCDSPropertiesBean abstractCDSPropertiesBean = + generatePayloadForCds.buildCdsPropertiesBean(delegateExecution); + + delegateExecution.setVariable(EXECUTION_OBJECT, abstractCDSPropertiesBean); + + } catch (Exception ex) { + logger.error("An exception occurred when creating payload for CDS request", ex); + exceptionBuilder.buildAndThrowWorkflowException(delegateExecution, 7000, ex); + } + } + + @Override + public void run(ControllerContext context) { + DelegateExecution obj = context.getExecution(); + cdsDispather.constructExecutionServiceInputObject(obj); + cdsDispather.sendRequestToCDSClient(obj); + } +} -- cgit 1.2.3-korg