52249f030086cf2e441f5b374030720219a0eb43
[so.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 package org.openecomp.mso.bpmn.infrastructure.scripts
22
23 import org.apache.commons.lang3.StringUtils
24 import org.camunda.bpm.engine.delegate.BpmnError
25 import org.json.JSONObject
26 import org.json.XML
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
34
35 /**
36  * This groovy class supports the <class>ActivateSDNCCNetworkResource.bpmn</class> process.
37  * flow for SDNC Network Resource Activate
38  */
39 public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
40
41     String Prefix = "ACTSDNCRES_"
42
43     ExceptionUtil exceptionUtil = new ExceptionUtil()
44
45     JsonUtils jsonUtil = new JsonUtils()
46
47     SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
48
49     public void preProcessRequest(DelegateExecution execution) {
50         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
51         utils.log("INFO"," ***** started  preProcessRequest*****",  isDebug)
52     }
53
54     public void prepareSDNCRequest(DelegateExecution execution) {
55         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
56         utils.log("INFO"," ***** started prepareSDNCRequest *****",  isDebug)
57     }
58
59     public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) {
60         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
61         utils.log("INFO"," ***** started prepareUpdateAfterDeActivateSDNCResource *****",  isDebug)
62     }
63
64     public void postDeactivateSDNCCall(DelegateExecution execution) {
65         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
66         utils.log("INFO"," ***** started postDeactivateSDNCCall *****",  isDebugEnabled)
67     }
68
69     public void sendSyncResponse(DelegateExecution execution) {
70         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
71         utils.log("INFO"," ***** started sendSyncResponse *****",  isDebugEnabled)
72
73         try {
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)
80
81         } catch (Exception ex) {
82             String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
83             utils.log("DEBUG", msg, isDebugEnabled)
84             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
85         }
86         utils.log("DEBUG"," ***** Exit sendSyncResopnse *****",  isDebugEnabled)
87     }
88
89 }