diff options
2 files changed, 203 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy new file mode 100644 index 0000000000..90c2b923b0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/HandlePNF.groovy @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 Huawei Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor +import org.onap.so.bpmn.common.scripts.CatalogDbUtils +import org.onap.so.bpmn.common.scripts.ExceptionUtil +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +public class HandlePNF extends AbstractServiceTaskProcessor{ + private static final Logger logger = LoggerFactory.getLogger( HandlePNF.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + CatalogDbUtils cutils = new CatalogDbUtils() + + @Override + void preProcessRequest(DelegateExecution execution) { + msoLogger.debug("Start preProcess for HandlePNF") + + // set correlation ID + def resourceInput = execution.getVariable("resourceInput") + String serInput = jsonUtil.getJsonValue(resourceInput, "requestsInputs") + String correlationId = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_pnf_name") + if (!StringUtils.isEmpty(correlationId)) { + execution.setVariable(ExecutionVariableNames.CORRELATION_ID, correlationId) + msoLogger.debug("Found correlation id : " + correlationId) + } else { + msoLogger.error("== correlation id is empty ==") + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "correlation id is not provided") + } + + // next task will set the uuid + msoLogger.debug("exit preProcess for HandlePNF") + } + + void postProcessRequest(DelegateExecution execution) { + msoLogger.debug("start postProcess for HandlePNF") + + msoLogger.debug("exit postProcess for HandlePNF") + } + + public void sendSyncResponse (DelegateExecution execution) { + msoLogger.debug(" *** sendSyncResponse *** ") + + try { + String operationStatus = "finished" + // RESTResponse for main flow + String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() + msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp) + sendWorkflowResponse(execution, 202, resourceOperationResp) + execution.setVariable("sentSyncResponse", true) + + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + msoLogger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + msoLogger.debug(" ***** Exit sendSyncResponse *****") + } +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn new file mode 100644 index 0000000000..c81b289737 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/HandlePNF.bpmn @@ -0,0 +1,119 @@ +<?xml version="1.0" encoding="UTF-8"?> +<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.16.2"> + <bpmn:process id="HandlePNF" name="HandlePNF" isExecutable="true"> + <bpmn:startEvent id="createNS_StartEvent_pnf_disc" name="start PNF handling"> + <bpmn:outgoing>SequenceFlow_1c92ks3_activate</bpmn:outgoing> + </bpmn:startEvent> + <bpmn:scriptTask id="Task_13sx2bp_activate" name="Pre Process Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1c92ks3_activate</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_17xr584</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_12q67gd</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def handlePNF = new HandlePNF() +handlePNF.preProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_1c92ks3_activate" sourceRef="createNS_StartEvent_pnf_disc" targetRef="Task_13sx2bp_activate" /> + <bpmn:sequenceFlow id="SequenceFlow_17xr584" sourceRef="Task_13sx2bp_activate" targetRef="Task_0kv28gm" /> + <bpmn:sequenceFlow id="SequenceFlow_0pujwl4" sourceRef="Task_0657l04" targetRef="PostProcessPNFDiscovery" /> + <bpmn:endEvent id="EndEvent_0pigsdfk3" name="end PNF hadler"> + <bpmn:incoming>SequenceFlow_02fi1yn</bpmn:incoming> + </bpmn:endEvent> + <bpmn:sequenceFlow id="SequenceFlow_1la8oih" sourceRef="PostProcessPNFDiscovery" targetRef="Task_1r8h7of" /> + <bpmn:callActivity id="Task_0657l04" name="invoke pnf handler" calledElement="CreateAndActivatePnfResource"> + <bpmn:extensionElements> + <camunda:in source="correlationId" target="correlationId" /> + <camunda:in source="pnfUuid" target="pnfUuid" /> + </bpmn:extensionElements> + <bpmn:incoming>SequenceFlow_1apj1fn</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_0pujwl4</bpmn:outgoing> + </bpmn:callActivity> + <bpmn:scriptTask id="PostProcessPNFDiscovery" name="Post Process Request" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_0pujwl4</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1la8oih</bpmn:outgoing> + <bpmn:outgoing>SequenceFlow_1ezf4gu</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def handlePNF = new HandlePNF() +handlePNF.postProcessRequest(execution)</bpmn:script> + </bpmn:scriptTask> + <bpmn:sequenceFlow id="SequenceFlow_12q67gd" sourceRef="Task_13sx2bp_activate" targetRef="Task_0kv28gm" /> + <bpmn:sequenceFlow id="SequenceFlow_1apj1fn" sourceRef="Task_0kv28gm" targetRef="Task_0657l04" /> + <bpmn:serviceTask id="Task_0kv28gm" name="Generate PNF uuid" camunda:delegateExpression="${GeneratePnfUuidDelegate}"> + <bpmn:incoming>SequenceFlow_12q67gd</bpmn:incoming> + <bpmn:incoming>SequenceFlow_17xr584</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_1apj1fn</bpmn:outgoing> + </bpmn:serviceTask> + <bpmn:sequenceFlow id="SequenceFlow_1ezf4gu" sourceRef="PostProcessPNFDiscovery" targetRef="Task_1r8h7of" /> + <bpmn:sequenceFlow id="SequenceFlow_02fi1yn" sourceRef="Task_1r8h7of" targetRef="EndEvent_0pigsdfk3" /> + <bpmn:scriptTask id="Task_1r8h7of" name="Send Sync Response" scriptFormat="groovy"> + <bpmn:incoming>SequenceFlow_1ezf4gu</bpmn:incoming> + <bpmn:incoming>SequenceFlow_1la8oih</bpmn:incoming> + <bpmn:outgoing>SequenceFlow_02fi1yn</bpmn:outgoing> + <bpmn:script>import org.onap.so.bpmn.infrastructure.scripts.* +def handlePNF = new HandlePNF() +handlePNF.sendSyncResponse(execution)</bpmn:script> + </bpmn:scriptTask> + </bpmn:process> + <bpmndi:BPMNDiagram id="BPMNDiagram_1"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="HandlePNF"> + <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent_pnf_disc"> + <dc:Bounds x="-464" y="306" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="-466" y="352" width="47" height="27" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_14l9mlv_di" bpmnElement="Task_13sx2bp_activate"> + <dc:Bounds x="-341" y="284" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1c92ks3_di" bpmnElement="SequenceFlow_1c92ks3_activate"> + <di:waypoint x="-428" y="324" /> + <di:waypoint x="-341" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_17xr584_di" bpmnElement="SequenceFlow_17xr584"> + <di:waypoint x="-241" y="324" /> + <di:waypoint x="-180" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_0pujwl4_di" bpmnElement="SequenceFlow_0pujwl4"> + <di:waypoint x="81" y="324" /> + <di:waypoint x="156" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="EndEvent_0pigdk3_di" bpmnElement="EndEvent_0pigsdfk3"> + <dc:Bounds x="543" y="306" width="36" height="36" /> + <bpmndi:BPMNLabel> + <dc:Bounds x="524" y="349" width="78" height="14" /> + </bpmndi:BPMNLabel> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1la8oih_di" bpmnElement="SequenceFlow_1la8oih"> + <di:waypoint x="256" y="324" /> + <di:waypoint x="353" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="CallActivity_1sxp6qj_di" bpmnElement="Task_0657l04"> + <dc:Bounds x="-19" y="284" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="ScriptTask_0qqb00i_di" bpmnElement="PostProcessPNFDiscovery"> + <dc:Bounds x="156" y="284" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_12q67gd_di" bpmnElement="SequenceFlow_12q67gd"> + <di:waypoint x="-241" y="324" /> + <di:waypoint x="-180" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_1apj1fn_di" bpmnElement="SequenceFlow_1apj1fn"> + <di:waypoint x="-80" y="324" /> + <di:waypoint x="-19" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ServiceTask_1y3h50n_di" bpmnElement="Task_0kv28gm"> + <dc:Bounds x="-180" y="284" width="100" height="80" /> + </bpmndi:BPMNShape> + <bpmndi:BPMNEdge id="SequenceFlow_1ezf4gu_di" bpmnElement="SequenceFlow_1ezf4gu"> + <di:waypoint x="256" y="324" /> + <di:waypoint x="353" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNEdge id="SequenceFlow_02fi1yn_di" bpmnElement="SequenceFlow_02fi1yn"> + <di:waypoint x="453" y="324" /> + <di:waypoint x="543" y="324" /> + </bpmndi:BPMNEdge> + <bpmndi:BPMNShape id="ScriptTask_1yqlrg7_di" bpmnElement="Task_1r8h7of"> + <dc:Bounds x="353" y="284" width="100" height="80" /> + </bpmndi:BPMNShape> + </bpmndi:BPMNPlane> + </bpmndi:BPMNDiagram> +</bpmn:definitions> |