3 * ============LICENSE_START=======================================================
5 * ================================================================================
6 * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
7 * ================================================================================
8 * Modifications Copyright (c) 2019 Samsung
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.scripts
25 import com.fasterxml.jackson.databind.ObjectMapper
26 import org.onap.so.bpmn.common.recipe.ResourceInput
27 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
28 import org.camunda.bpm.engine.delegate.DelegateExecution
29 import org.onap.so.bpmn.core.json.JsonUtils
30 import org.onap.so.bpmn.common.scripts.ExceptionUtil
31 import org.slf4j.Logger
32 import org.slf4j.LoggerFactory
35 public class DeleteVFCNSResource extends AbstractServiceTaskProcessor {
37 String Prefix = "DCUSE_"
38 ExceptionUtil exceptionUtil = new ExceptionUtil()
39 JsonUtils jsonUtil = new JsonUtils()
41 private static final Logger logger = LoggerFactory.getLogger( DeleteVFCNSResource.class);
43 public void preProcessRequest (DelegateExecution execution) {
44 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
45 logger.info(" ***** start preProcessRequest *****")
47 String resourceInputStr = execution.getVariable("resourceInput")
48 ResourceInput resourceInput = new ObjectMapper().readValue(resourceInputStr, ResourceInput.class)
50 String globalSubscriberId = resourceInput.getGlobalSubscriberId()
51 String serviceType = execution.getVariable("serviceType")
52 String operationId = resourceInput.getOperationId()
53 String resourceModeluuid = resourceInput.getResourceModelInfo().getModelCustomizationUuid()
54 String resourceInstanceId = resourceInput.getResourceInstancenUuid()
57 execution.setVariable("globalSubscriberId",globalSubscriberId)
58 execution.setVariable("serviceType", serviceType)
59 execution.setVariable("operationId", operationId)
60 execution.setVariable("resourceTemplateId", resourceModeluuid)
61 execution.setVariable("resourceInstanceId", resourceInstanceId)
63 logger.info(" ***** end preProcessRequest *****")
66 void postProcessRequest (DelegateExecution execution) {
67 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
68 logger.info(" ***** start postProcessRequest *****")
70 logger.info(" ***** end postProcessRequest *****")
73 void sendSyncResponse (DelegateExecution execution) {
74 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
75 logger.debug( " *** sendSyncResponse *** ")
78 String nsInstanceId = execution.getVariable("nsInstanceId")
79 String operationStatus = execution.getVariable("operationStatus")
80 // RESTResponse for main flow
81 String createVFCResourceRestRsp = """{"nsInstanceId":"${nsInstanceId}","operationStatus":"${operationStatus}"}""".trim()
82 logger.debug( " sendSyncResponse to APIH:" + "\n" + createVFCResourceRestRsp)
83 sendWorkflowResponse(execution, 202, createVFCResourceRestRsp)
84 execution.setVariable("sentSyncResponse", true)
86 } catch (Exception ex) {
87 String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
89 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
91 logger.debug(" ***** Exit sendSyncResopnse *****")