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