2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 Huawei Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import org.apache.commons.lang3.StringUtils
24 import org.camunda.bpm.engine.delegate.DelegateExecution
25 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
26 import org.onap.so.bpmn.common.scripts.ExceptionUtil
27 import org.onap.so.bpmn.core.json.JsonUtils
28 import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames
29 import org.slf4j.Logger
30 import org.slf4j.LoggerFactory
32 public class HandlePNF extends AbstractServiceTaskProcessor{
33 private static final Logger logger = LoggerFactory.getLogger( HandlePNF.class);
35 ExceptionUtil exceptionUtil = new ExceptionUtil()
36 JsonUtils jsonUtil = new JsonUtils()
39 void preProcessRequest(DelegateExecution execution) {
40 logger.debug("Start preProcess for HandlePNF")
43 def resourceInput = execution.getVariable("resourceInput")
44 String serInput = jsonUtil.getJsonValue(resourceInput, "requestsInputs")
45 String correlationId = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_pnf_name")
46 if (!StringUtils.isEmpty(correlationId)) {
47 execution.setVariable(ExecutionVariableNames.CORRELATION_ID, correlationId)
48 logger.debug("Found correlation id : " + correlationId)
50 logger.error("== correlation id is empty ==")
51 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "correlation id is not provided")
54 // next task will set the uuid
55 logger.debug("exit preProcess for HandlePNF")
58 void postProcessRequest(DelegateExecution execution) {
59 logger.debug("start postProcess for HandlePNF")
61 logger.debug("exit postProcess for HandlePNF")
64 public void sendSyncResponse (DelegateExecution execution) {
65 logger.debug(" *** sendSyncResponse *** ")
68 String operationStatus = "finished"
69 // RESTResponse for main flow
70 String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
71 logger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
72 sendWorkflowResponse(execution, 202, resourceOperationResp)
73 execution.setVariable("sentSyncResponse", true)
75 } catch (Exception ex) {
76 String msg = "Exception in sendSyncResponse:" + ex.getMessage()
78 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
80 logger.debug(" ***** Exit sendSyncResponse *****")