2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.openecomp.mso.bpmn.infrastructure.scripts
23 import org.apache.commons.lang3.StringUtils
24 import org.camunda.bpm.engine.delegate.BpmnError
25 import org.json.JSONObject
27 import org.openecomp.mso.bpmn.common.recipe.ResourceInput
28 import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
29 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
30 import org.camunda.bpm.engine.delegate.DelegateExecution
31 import org.openecomp.mso.bpmn.core.json.JsonUtils
32 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
33 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
36 * This groovy class supports the <class>ActivateSDNCCNetworkResource.bpmn</class> process.
37 * flow for SDNC Network Resource Activate
39 public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
41 String Prefix = "ACTSDNCRES_"
43 ExceptionUtil exceptionUtil = new ExceptionUtil()
45 JsonUtils jsonUtil = new JsonUtils()
47 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
49 public void preProcessRequest(DelegateExecution execution) {
50 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
51 utils.log("INFO"," ***** started preProcessRequest*****", isDebug)
54 public void prepareSDNCRequest(DelegateExecution execution) {
55 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
56 utils.log("INFO"," ***** started prepareSDNCRequest *****", isDebug)
59 public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) {
60 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
61 utils.log("INFO"," ***** started prepareUpdateAfterDeActivateSDNCResource *****", isDebug)
64 public void postDeactivateSDNCCall(DelegateExecution execution) {
65 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
66 utils.log("INFO"," ***** started postDeactivateSDNCCall *****", isDebugEnabled)
69 public void sendSyncResponse(DelegateExecution execution) {
70 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
71 utils.log("INFO"," ***** started sendSyncResponse *****", isDebugEnabled)
74 String operationStatus = "finished"
75 // RESTResponse for main flow
76 String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
77 utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
78 sendWorkflowResponse(execution, 202, resourceOperationResp)
79 execution.setVariable("sentSyncResponse", true)
81 } catch (Exception ex) {
82 String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
83 utils.log("DEBUG", msg, isDebugEnabled)
84 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
86 utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)