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.CatalogDbUtils
27 import org.onap.so.bpmn.common.scripts.ExceptionUtil
28 import org.onap.so.bpmn.core.json.JsonUtils
29 import org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames
30 import org.slf4j.Logger
31 import org.slf4j.LoggerFactory
33 public class HandlePNF extends AbstractServiceTaskProcessor{
34 private static final Logger logger = LoggerFactory.getLogger( HandlePNF.class);
36 ExceptionUtil exceptionUtil = new ExceptionUtil()
37 JsonUtils jsonUtil = new JsonUtils()
38 CatalogDbUtils cutils = new CatalogDbUtils()
41 void preProcessRequest(DelegateExecution execution) {
42 msoLogger.debug("Start preProcess for HandlePNF")
45 def resourceInput = execution.getVariable("resourceInput")
46 String serInput = jsonUtil.getJsonValue(resourceInput, "requestsInputs")
47 String correlationId = jsonUtil.getJsonValue(serInput, "service.parameters.requestInputs.ont_ont_pnf_name")
48 if (!StringUtils.isEmpty(correlationId)) {
49 execution.setVariable(ExecutionVariableNames.CORRELATION_ID, correlationId)
50 msoLogger.debug("Found correlation id : " + correlationId)
52 msoLogger.error("== correlation id is empty ==")
53 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "correlation id is not provided")
56 // next task will set the uuid
57 msoLogger.debug("exit preProcess for HandlePNF")
60 void postProcessRequest(DelegateExecution execution) {
61 msoLogger.debug("start postProcess for HandlePNF")
63 msoLogger.debug("exit postProcess for HandlePNF")
66 public void sendSyncResponse (DelegateExecution execution) {
67 msoLogger.debug(" *** sendSyncResponse *** ")
70 String operationStatus = "finished"
71 // RESTResponse for main flow
72 String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
73 msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
74 sendWorkflowResponse(execution, 202, resourceOperationResp)
75 execution.setVariable("sentSyncResponse", true)
77 } catch (Exception ex) {
78 String msg = "Exception in sendSyncResponse:" + ex.getMessage()
80 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
82 msoLogger.debug(" ***** Exit sendSyncResponse *****")