913c82fc58edf573f5e64d254a62a21b7bc11a7c
[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.onap.so.logger.MsoLogger
28 import org.openecomp.mso.bpmn.common.recipe.ResourceInput
29 import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
30 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
31 import org.camunda.bpm.engine.delegate.DelegateExecution
32 import org.openecomp.mso.bpmn.core.json.JsonUtils
33 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
34 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
35
36 /**
37  * This groovy class supports the <class>ActivateSDNCCNetworkResource.bpmn</class> process.
38  * flow for SDNC Network Resource Activate
39  */
40 public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
41     private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,
42             CreateSDNCNetworkResource.class);
43     String Prefix = "DEACTSDNCRES_"
44
45     ExceptionUtil exceptionUtil = new ExceptionUtil()
46
47     JsonUtils jsonUtil = new JsonUtils()
48
49     SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
50
51     public void preProcessRequest(DelegateExecution execution) {
52         msoLogger.info(" ***** started  preProcessRequest*****")
53     }
54
55     public void prepareSDNCRequest(DelegateExecution execution) {
56         msoLogger.info(" ***** started prepareSDNCRequest *****")
57     }
58
59     public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) {
60         msoLogger.info("***** started prepareUpdateAfterDeActivateSDNCResource *****")
61     }
62
63     public void postDeactivateSDNCCall(DelegateExecution execution) {
64         msoLogger.info(" ***** started postDeactivateSDNCCall *****")
65     }
66
67     public void sendSyncResponse(DelegateExecution execution) {
68         def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
69         msoLogger.info(" ***** started sendSyncResponse *****")
70
71         try {
72             String operationStatus = "finished"
73             // RESTResponse for main flow
74             String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
75             msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
76             sendWorkflowResponse(execution, 202, resourceOperationResp)
77             execution.setVariable("sentSyncResponse", true)
78
79         } catch (Exception ex) {
80             String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
81             msoLogger.debug(msg)
82             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
83         }
84         msoLogger.debug(" ***** Exit sendSyncResopnse *****")
85     }
86
87 }