2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
20 package org.openecomp.mso.bpmn.infrastructure.scripts;
22 import org.openecomp.mso.bpmn.core.json.JsonUtils
23 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
24 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
25 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
26 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils
27 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
28 import org.openecomp.mso.bpmn.common.scripts.VidUtils
29 import org.openecomp.mso.bpmn.core.WorkflowException
30 import org.openecomp.mso.rest.APIResponse;
31 import org.openecomp.mso.rest.RESTClient
32 import org.openecomp.mso.rest.RESTConfig
34 import java.util.UUID;
36 import org.camunda.bpm.engine.delegate.BpmnError
37 import org.camunda.bpm.engine.runtime.Execution
38 import org.apache.commons.lang3.*
39 import org.apache.commons.codec.binary.Base64;
40 import org.springframework.web.util.UriUtils
42 import groovy.xml.XmlUtil
45 public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor {
46 String Prefix= "DELNWKI_"
47 String groovyClassName = "DoDeleteNetworkInstance"
48 ExceptionUtil exceptionUtil = new ExceptionUtil()
49 JsonUtils jsonUtil = new JsonUtils()
50 VidUtils vidUtils = new VidUtils(this)
51 NetworkUtils networkUtils = new NetworkUtils()
52 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
54 public InitializeProcessVariables(Execution execution){
55 /* Initialize all the process variables in this block */
57 execution.setVariable(Prefix + "networkRequest", "")
58 execution.setVariable(Prefix + "isSilentSuccess", false)
59 execution.setVariable(Prefix + "Success", false)
61 execution.setVariable(Prefix + "requestId", "")
62 execution.setVariable(Prefix + "source", "")
63 execution.setVariable(Prefix + "lcpCloudRegion", "")
64 execution.setVariable(Prefix + "networkInputs", "")
65 execution.setVariable(Prefix + "tenantId", "")
67 execution.setVariable(Prefix + "queryAAIRequest","")
68 execution.setVariable(Prefix + "queryAAIResponse", "")
69 execution.setVariable(Prefix + "aaiReturnCode", "")
70 execution.setVariable(Prefix + "isAAIGood", false)
71 execution.setVariable(Prefix + "isVfRelationshipExist", false)
73 // AAI query Cloud Region
74 execution.setVariable(Prefix + "queryCloudRegionRequest","")
75 execution.setVariable(Prefix + "queryCloudRegionReturnCode","")
76 execution.setVariable(Prefix + "queryCloudRegionResponse","")
77 execution.setVariable(Prefix + "cloudRegionPo","")
78 execution.setVariable(Prefix + "cloudRegionSdnc","")
80 execution.setVariable(Prefix + "deleteNetworkRequest", "")
81 execution.setVariable(Prefix + "deleteNetworkResponse", "")
82 execution.setVariable(Prefix + "networkReturnCode", "")
83 execution.setVariable(Prefix + "rollbackNetworkRequest", "")
85 execution.setVariable(Prefix + "deleteSDNCRequest", "")
86 execution.setVariable(Prefix + "deleteSDNCResponse", "")
87 execution.setVariable(Prefix + "sdncReturnCode", "")
88 execution.setVariable(Prefix + "sdncResponseSuccess", false)
90 execution.setVariable(Prefix + "deactivateSDNCRequest", "")
91 execution.setVariable(Prefix + "deactivateSDNCResponse", "")
92 execution.setVariable(Prefix + "deactivateSdncReturnCode", "")
93 execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "")
95 execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", "")
96 execution.setVariable(Prefix + "isException", false)
101 // **************************************************
102 // Pre or Prepare Request Section
103 // **************************************************
105 public void preProcessRequest (Execution execution) {
106 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
107 execution.setVariable("prefix",Prefix)
109 utils.log("DEBUG", " ***** Inside preProcessRequest() of " + groovyClassName + " Request ***** ", isDebugEnabled)
111 // initialize flow variables
112 InitializeProcessVariables(execution)
115 // get incoming message/input
116 execution.setVariable("action", "DELETE")
117 String deleteNetwork = execution.getVariable("bpmnRequest")
118 if (deleteNetwork != null) {
119 if (deleteNetwork.contains("requestDetails")) {
120 // JSON format request is sent, create xml
122 def prettyJson = JsonOutput.prettyPrint(deleteNetwork.toString())
123 utils.log("DEBUG", " Incoming message formatted . . . : " + '\n' + prettyJson, isDebugEnabled)
124 deleteNetwork = vidUtils.createXmlNetworkRequestInfra(execution, deleteNetwork)
126 } catch (Exception ex) {
127 String dataErrorMessage = " Invalid json format Request - " + ex.getMessage()
128 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
129 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
132 // XML format request is sent
136 // vIPR format request is sent, create xml from individual variables
137 deleteNetwork = vidUtils.createXmlNetworkRequestInstance(execution)
140 deleteNetwork = utils.formatXml(deleteNetwork)
141 utils.logAudit(deleteNetwork)
142 execution.setVariable(Prefix + "networkRequest", deleteNetwork)
143 utils.log("DEBUG", Prefix + "networkRequest - " + '\n' + deleteNetwork, isDebugEnabled)
145 // validate 'backout-on-failure' to override 'URN_mso_rollback'
146 boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, deleteNetwork)
147 execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled)
148 utils.log("DEBUG", Prefix + "rollbackEnabled - " + rollbackEnabled, isDebugEnabled)
150 String networkInputs = utils.getNodeXml(deleteNetwork, "network-inputs", false).replace("tag0:","").replace(":tag0","")
151 execution.setVariable(Prefix + "networkInputs", networkInputs)
154 String messageId = execution.getVariable("testMessageId") // for testing
155 if (messageId == null || messageId == "") {
156 messageId = UUID.randomUUID()
157 utils.log("DEBUG", Prefix + "messageId, random generated: " + messageId, isDebugEnabled)
159 utils.log("DEBUG", Prefix + "messageId, pre-assigned: " + messageId, isDebugEnabled)
161 execution.setVariable(Prefix + "messageId", messageId)
163 String source = utils.getNodeText1(deleteNetwork, "source")
164 execution.setVariable(Prefix + "source", source)
165 utils.log("DEBUG", Prefix + "source - " + source, isDebugEnabled)
167 String networkId = ""
168 if (utils.nodeExists(networkInputs, "network-id")) {
169 networkId = utils.getNodeText1(networkInputs, "network-id")
170 if (networkId == null || networkId == "" || networkId == 'null' ) {
171 sendSyncError(execution)
172 // missing value of network-id
173 String dataErrorMessage = "network-request has missing 'network-id' element/value."
174 utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled)
175 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
179 // lcpCloudRegion or tenantId not sent, will be extracted from query AA&I
180 def lcpCloudRegion = null
181 if (utils.nodeExists(networkInputs, "aic-cloud-region")) {
182 lcpCloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region")
183 if (lcpCloudRegion == 'null') {
184 lcpCloudRegion = null
187 execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion)
188 utils.log("DEBUG", "lcpCloudRegion : " + lcpCloudRegion, isDebugEnabled)
190 String tenantId = null
191 if (utils.nodeExists(networkInputs, "tenant-id")) {
192 tenantId = utils.getNodeText1(networkInputs, "tenant-id")
193 if (tenantId == 'null') {
198 execution.setVariable(Prefix + "tenantId", tenantId)
199 utils.log("DEBUG", "tenantId : " + tenantId, isDebugEnabled)
201 String sdncVersion = execution.getVariable("sdncVersion")
202 utils.log("DEBUG", "sdncVersion? : " + sdncVersion, isDebugEnabled)
204 // PO Authorization Info / headers Authorization=
205 String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth")
206 utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled)
208 def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey"))
209 execution.setVariable("BasicAuthHeaderValuePO",encodedString)
210 execution.setVariable("BasicAuthHeaderValueSDNC", encodedString)
212 } catch (IOException ex) {
213 String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage()
214 utils.log("DEBUG", dataErrorMessage, , isDebugEnabled)
215 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
218 } catch (BpmnError e) {
221 } catch (Exception ex){
223 String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, PreProcessRequest() - " + ex.getMessage()
224 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
225 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
232 public void callRESTQueryAAI (Execution execution) {
233 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
234 execution.setVariable("prefix",Prefix)
236 utils.log("DEBUG", " ***** Inside callRESTQueryAAI() of DoDoDeleteNetworkInstance ***** " , isDebugEnabled)
239 String networkInputs = execution.getVariable(Prefix + "networkInputs")
240 String networkId = utils.getNodeText(networkInputs, "network-id")
241 networkId = UriUtils.encode(networkId,"UTF-8")
242 String messageId = execution.getVariable(Prefix + "messageId")
245 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
246 AaiUtil aaiUriUtil = new AaiUtil(this)
247 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
248 String queryAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId
249 utils.logAudit(queryAAIRequest)
250 execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest)
251 utils.log("DEBUG", Prefix + "AAIRequest - " + "\n" + queryAAIRequest, isDebugEnabled)
253 RESTConfig config = new RESTConfig(queryAAIRequest);
255 ExceptionUtil exceptionUtil = new ExceptionUtil()
256 Boolean isVfRelationshipExist = false
258 RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId)
259 .addHeader("X-FromAppId", "MSO")
260 .addHeader("Content-Type", "application/xml")
261 .addHeader("Accept","application/xml");
262 APIResponse response = client.get()
263 String returnCode = response.getStatusCode()
264 execution.setVariable(Prefix + "aaiReturnCode", returnCode)
266 utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled)
268 String aaiResponseAsString = response.getResponseBodyAsString()
269 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
270 execution.setVariable(Prefix + "queryAAIResponse", aaiResponseAsString)
272 if (returnCode=='200' || returnCode=='204') {
273 utils.logAudit(aaiResponseAsString)
274 execution.setVariable(Prefix + "isAAIGood", true)
275 utils.log("DEBUG", " AAI Query Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled)
276 // verify if vf or vnf relationship exist
277 if (utils.nodeExists(aaiResponseAsString, "relationship")) {
278 NetworkUtils networkUtils = new NetworkUtils()
279 isVfRelationshipExist = networkUtils.isVfRelationshipExist(aaiResponseAsString)
280 execution.setVariable(Prefix + "isVfRelationshipExist", isVfRelationshipExist)
281 if (isVfRelationshipExist == true) {
282 String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId
283 exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage)
286 // verify if lcpCloudRegion was sent as input, if not get value from AAI Response
287 if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) {
288 String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString)
289 execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion)
290 utils.log("DEBUG", " Get AAI getCloudRegion() : " + lcpCloudRegion, isDebugEnabled)
292 if (execution.getVariable(Prefix + "tenantId") == null ) {
293 String tenantId = networkUtils.getTenantId(aaiResponseAsString)
294 execution.setVariable(Prefix + "tenantId", tenantId)
295 utils.log("DEBUG", " Get AAI getTenantId() : " + tenantId, isDebugEnabled)
300 utils.log("DEBUG", Prefix + "isVfRelationshipExist - " + isVfRelationshipExist, isDebugEnabled)
303 execution.setVariable(Prefix + "isAAIGood", false)
304 if (returnCode=='404' || aaiResponseAsString == "" || aaiResponseAsString == null) {
305 // not found // empty aai response
306 execution.setVariable(Prefix + "isSilentSuccess", true)
307 utils.log("DEBUG", " AAI Query is Silent Success", isDebugEnabled)
310 if (aaiResponseAsString.contains("RESTFault")) {
311 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
312 execution.setVariable("WorkflowException", exceptionObject)
316 String dataErrorMessage = "Unexpected Error Response from callRESTQueryAAI() - " + returnCode
317 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
318 exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage)
324 utils.log("DEBUG", " AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood"), isDebugEnabled)
326 } catch (Exception ex) {
328 String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage()
329 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
330 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
336 public void callRESTQueryAAICloudRegion (Execution execution) {
337 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
338 execution.setVariable("prefix", Prefix)
340 utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion of DoDeleteNetworkInstance ***** " , isDebugEnabled)
343 String networkInputs = execution.getVariable(Prefix + "networkInputs")
344 // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region")
345 String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion")
346 cloudRegion = UriUtils.encode(cloudRegion,"UTF-8")
348 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
349 AaiUtil aaiUtil = new AaiUtil(this)
350 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
351 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
352 utils.logAudit(queryCloudRegionRequest)
353 execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
354 utils.log("DEBUG", Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled)
356 String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
357 String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion)
359 if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) {
360 execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo)
361 execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc)
364 String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode")
365 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
366 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
370 } catch (BpmnError e) {
373 } catch (Exception ex) {
375 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, callRESTQueryAAICloudRegion(). Unexpected Response from AAI - " + ex.getMessage()
376 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
377 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
383 public void prepareNetworkRequest (Execution execution) {
384 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
385 execution.setVariable("prefix", Prefix)
387 utils.log("DEBUG", " ***** Inside prepareNetworkRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
388 ExceptionUtil exceptionUtil = new ExceptionUtil()
391 String networkInputs = execution.getVariable(Prefix + "networkInputs")
392 String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo")
393 String tenantId = execution.getVariable(Prefix + "tenantId")
395 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
396 String networkType = utils.getNodeText1(queryAAIResponse, "network-type")
397 String networkId = utils.getNodeText1(queryAAIResponse, "network-id")
398 String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled")
400 String networkStackId = ""
401 networkStackId = utils.getNodeText1(queryAAIResponse, "heat-stack-id")
402 if (networkStackId == 'null' || networkStackId == "") {
403 networkStackId = "force_delete"
406 String requestId = execution.getVariable(Prefix + "requestId")
407 String serviceInstanceId = execution.getVariable("serviceInstanceId")
409 // Added new Elements
410 String messageId = execution.getVariable(Prefix + "messageId")
411 String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use?
412 //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use?
414 String deleteNetworkRequest = """
415 <deleteNetworkRequest>
416 <cloudSiteId>${cloudSiteId}</cloudSiteId>
417 <tenantId>${tenantId}</tenantId>
418 <networkId>${networkId}</networkId>
419 <networkStackId>${networkStackId}</networkStackId>
420 <networkType>${networkType}</networkType>
421 <skipAAI>true</skipAAI>
423 <requestId>${requestId}</requestId>
424 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
426 <messageId>${messageId}</messageId>
427 <notificationUrl>${notificationUrl}</notificationUrl>
428 </deleteNetworkRequest>
431 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest, isDebugEnabled)
433 String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest)
434 utils.logAudit(buildDeleteNetworkRequestAsString)
435 utils.log("DEBUG", Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
437 String restURL = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
438 execution.setVariable("URN_mso_adapters_network_rest_endpoint", restURL + "/" + networkId)
439 utils.log("DEBUG", "URN_mso_adapters_network_rest_endpoint - " + "\n" + restURL + "/" + networkId, isDebugEnabled)
441 execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString)
442 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
444 catch (Exception ex) {
446 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage()
447 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
448 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
454 * This method is used instead of an HTTP Connector task because the
455 * connector does not allow DELETE with a body.
457 public void sendRequestToVnfAdapter(Execution execution) {
458 def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' +
459 'execution=' + execution.getId() +
461 def isDebugEnabled = execution.getVariable('isDebugLogEnabled')
462 logDebug('Entered ' + method, isDebugEnabled)
466 String vnfAdapterUrl = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
467 String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest")
469 RESTConfig config = new RESTConfig(vnfAdapterUrl)
470 RESTClient client = new RESTClient(config).
471 addHeader("Content-Type", "application/xml").
472 addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO"));
474 APIResponse response;
476 response = client.httpDelete(vnfAdapterRequest)
478 execution.setVariable(Prefix + "networkReturnCode", response.getStatusCode())
479 execution.setVariable(Prefix + "deleteNetworkResponse", response.getResponseBodyAsString())
481 } catch (Exception ex) {
483 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage()
484 logError(exceptionMessage)
485 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
486 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
492 public void prepareSDNCRequest (Execution execution) {
493 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
494 execution.setVariable("prefix", Prefix)
496 utils.log("DEBUG", " ***** Inside prepareSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
500 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
501 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
503 String networkId = ""
504 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
505 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
507 if (networkId == 'null') {networkId = ""}
509 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
511 // get/set 'msoRequestId' and 'mso-request-id'
512 String requestId = execution.getVariable("msoRequestId")
513 if (requestId != null) {
514 execution.setVariable("mso-request-id", requestId)
516 requestId = execution.getVariable("mso-request-id")
518 execution.setVariable(Prefix + "requestId", requestId)
520 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
522 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
523 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
524 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
525 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
526 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
527 utils.logAudit(sndcTopologyDeleteRequesAsString)
528 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
529 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
531 } catch (Exception ex) {
533 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
534 logError(exceptionMessage)
535 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
536 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
542 public void prepareRpcSDNCRequest (Execution execution) {
543 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
544 execution.setVariable("prefix", Prefix)
546 utils.log("DEBUG", " ***** Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
550 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
551 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
553 String networkId = ""
554 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
555 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
557 if (networkId == 'null') {networkId = ""}
559 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
561 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
562 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
563 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
564 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null)
565 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
566 utils.logAudit(sndcTopologyDeleteRequesAsString)
567 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
568 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
570 } catch (Exception ex) {
572 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
573 logError(exceptionMessage)
574 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
575 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
582 public void prepareRpcSDNCDeactivate(Execution execution) {
583 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
584 execution.setVariable("prefix",Prefix)
586 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
591 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
592 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
593 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
594 String networkId = ""
595 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
596 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
598 if (networkId == 'null') {networkId = ""}
599 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
601 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null)
602 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
603 execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
604 utils.log("DEBUG", " Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
607 } catch (Exception ex) {
608 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage()
609 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
610 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
616 // **************************************************
617 // Post or Validate Response Section
618 // **************************************************
620 public void validateNetworkResponse (Execution execution) {
621 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
622 execution.setVariable("prefix", Prefix)
624 utils.log("DEBUG", " ***** Inside validateNetworkResponse of DoDeleteNetworkInstance *****", isDebugEnabled)
627 String returnCode = execution.getVariable(Prefix + "networkReturnCode")
628 String networkResponse = execution.getVariable(Prefix + "deleteNetworkResponse")
630 utils.log("DEBUG", " Network Adapter responseCode: " + returnCode, isDebugEnabled)
631 utils.log("DEBUG", "Network Adapter Response - " + "\n" + networkResponse, isDebugEnabled)
632 utils.logAudit(networkResponse)
634 String errorMessage = ""
635 if (returnCode == "200") {
636 utils.log("DEBUG", " Network Adapter Response is successful - " + "\n" + networkResponse, isDebugEnabled)
638 // prepare rollback data
639 String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","")
640 if ((rollbackData == null) || (rollbackData.isEmpty())) {
641 utils.log("DEBUG", " Network Adapter 'rollback' data is not Sent: " + "\n" + networkResponse, isDebugEnabled)
642 execution.setVariable(Prefix + "rollbackNetworkRequest", "")
644 String rollbackNetwork =
645 """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network">
647 </NetworkAdapter:rollbackNetwork>"""
648 String rollbackNetworkXml = utils.formatXml(rollbackNetwork)
649 execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml)
650 utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled)
654 } else { // network error
655 if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx
656 if (networkResponse.contains("deleteNetworkError") ) {
657 networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '')
658 errorMessage = utils.getNodeText1(networkResponse, "message")
659 errorMessage = "Received error from Network Adapter: " + errorMessage
660 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
662 } else { // CatchAll exception
663 if (returnCode == "500") {
664 errorMessage = "JBWEB000065: HTTP Status 500."
666 errorMessage = "Return code is " + returnCode
668 errorMessage = "Received error from Network Adapter: " + errorMessage
669 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
673 } else { // CatchAll exception
674 String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode
675 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
681 } catch (BpmnError e) {
684 } catch (Exception ex) {
686 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, validateNetworkResponse() - " + ex.getMessage()
687 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
688 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
694 public void validateSDNCResponse (Execution execution) {
695 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
696 execution.setVariable("prefix", Prefix)
698 utils.log("DEBUG", " ***** Inside validateSDNCResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
700 String response = execution.getVariable(Prefix + "deleteSDNCResponse")
701 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
702 WorkflowException workflowException = execution.getVariable("WorkflowException")
704 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
705 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
707 String deleteSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deleteSDNCResponse"))
708 deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
709 execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml)
711 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess'
712 execution.setVariable(Prefix + "isSdncRollbackNeeded", true) //
713 execution.setVariable(Prefix + "isPONR", true)
714 utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled)
716 utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled)
717 throw new BpmnError("MSOWorkflowException")
722 public void validateRpcSDNCDeactivateResponse (Execution execution) {
723 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
724 execution.setVariable("prefix",Prefix)
726 utils.log("DEBUG", " ***** Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
728 String response = execution.getVariable(Prefix + "deactivateSDNCResponse")
729 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
730 WorkflowException workflowException = execution.getVariable("WorkflowException")
732 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
733 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
735 String assignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deactivateSDNCResponse"))
736 assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
737 execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml)
739 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess'
740 execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true)
741 utils.log("DEBUG", "Successfully Validated Rpc SDNC Activate Response", isDebugEnabled)
744 utils.log("DEBUG", "Did NOT Successfully Validated Rpc SDNC Deactivate Response", isDebugEnabled)
745 throw new BpmnError("MSOWorkflowException")
750 public void prepareRpcSDNCDeactivateRollback(Execution execution) {
751 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
752 execution.setVariable("prefix",Prefix)
754 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
759 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
760 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
761 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
762 String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse")
763 String networkId = utils.getNodeText1(deactivateSDNCResponse, "network-id")
764 if (networkId == 'null') {networkId = ""}
765 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
767 // 2. prepare rollback topology via SDNC Adapter SUBFLOW call
768 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "ActivateNetworkInstance", cloudRegionId, networkId, null)
769 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
770 execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
771 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'activate-ActivateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
774 } catch (Exception ex) {
775 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage()
776 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
777 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
783 public void prepareRollbackData(Execution execution) {
784 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
785 execution.setVariable("prefix",Prefix)
787 utils.log("DEBUG", " ***** Inside prepareRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
791 Map<String, String> rollbackData = new HashMap<String, String>();
792 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
793 if (rollbackNetworkRequest != null) {
794 if (rollbackNetworkRequest != "") {
795 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
798 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
799 if (rollbackDeactivateSDNCRequest != null) {
800 if (rollbackDeactivateSDNCRequest != "") {
801 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
804 execution.setVariable("rollbackData", rollbackData)
805 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
807 execution.setVariable("WorkflowException", execution.getVariable("WorkflowException"))
808 utils.log("DEBUG", "** WorkflowException : " + execution.getVariable("WorkflowException"), isDebugEnabled)
810 } catch (Exception ex) {
811 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage()
812 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
813 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
819 public void postProcessResponse (Execution execution) {
820 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
821 execution.setVariable("prefix", Prefix)
823 utils.log("DEBUG", " ***** Inside postProcessResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
827 utils.log("DEBUG", " ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"), isDebugEnabled)
828 if (execution.getVariable(Prefix + "isException") == false) {
829 execution.setVariable(Prefix + "Success", true)
830 execution.setVariable("WorkflowException", null)
831 if (execution.getVariable(Prefix + "isSilentSuccess") == true) {
832 execution.setVariable("rolledBack", false)
834 execution.setVariable("rolledBack", true)
836 prepareSuccessRollbackData(execution) // populate rollbackData
839 execution.setVariable(Prefix + "Success", false)
840 execution.setVariable("rollbackData", null)
841 String exceptionMessage = " Exception encountered in MSO Bpmn. "
842 if (execution.getVariable("workflowException") != null) { // Output of Rollback flow.
843 utils.log("DEBUG", " ***** workflowException: " + execution.getVariable("workflowException"), isDebugEnabled)
844 WorkflowException wfex = execution.getVariable("workflowException")
845 exceptionMessage = wfex.getErrorMessage()
847 if (execution.getVariable(Prefix + "WorkflowException") != null) {
848 WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException")
849 exceptionMessage = pwfex.getErrorMessage()
852 // going to the Main flow: a-la-carte or macro
853 utils.log("DEBUG", " ***** postProcessResponse(), BAD !!!", isDebugEnabled)
854 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
855 throw new BpmnError("MSOWorkflowException")
859 } catch(BpmnError b){
860 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
863 } catch (Exception ex) {
865 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage()
866 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
867 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
868 throw new BpmnError("MSOWorkflowException")
874 public void prepareSuccessRollbackData(Execution execution) {
875 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
876 execution.setVariable("prefix",Prefix)
878 utils.log("DEBUG", " ***** Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
882 if (execution.getVariable("sdncVersion") == '1702') {
883 prepareRpcSDNCDeactivateRollback(execution)
884 prepareRpcSDNCUnassignRollback(execution)
886 prepareSDNCRollback(execution)
889 Map<String, String> rollbackData = new HashMap<String, String>();
890 String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
891 if (rollbackSDNCRequest != null) {
892 if (rollbackSDNCRequest != "") {
893 rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest"))
896 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
897 if (rollbackNetworkRequest != null) {
898 if (rollbackNetworkRequest != "") {
899 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
902 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
903 if (rollbackDeactivateSDNCRequest != null) {
904 if (rollbackDeactivateSDNCRequest != "") {
905 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
908 execution.setVariable("rollbackData", rollbackData)
910 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
911 execution.setVariable("WorkflowException", null)
914 } catch (Exception ex) {
915 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage()
916 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
917 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
923 public void prepareRpcSDNCUnassignRollback(Execution execution) {
924 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
925 execution.setVariable("prefix",Prefix)
927 utils.log("DEBUG", " ***** Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
932 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
933 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
935 String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse")
936 String networkId = utils.getNodeText1(deleteSDNCResponse, "network-id")
937 if (networkId == 'null') {networkId = ""}
938 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
940 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
941 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
942 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
943 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null)
944 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
945 utils.logAudit(sndcTopologyDeleteRequesAsString)
946 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
947 utils.log("DEBUG", Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
948 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
951 } catch (Exception ex) {
952 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage()
953 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
954 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
960 public void prepareSDNCRollback (Execution execution) {
961 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
962 execution.setVariable("prefix", Prefix)
964 utils.log("DEBUG", " ***** Inside prepareSDNCRollback of DoDeleteNetworkInstance ***** ", isDebugEnabled)
969 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
970 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
972 String networkId = ""
973 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
974 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
976 if (networkId == 'null') {networkId = ""}
978 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
980 // get/set 'msoRequestId' and 'mso-request-id'
981 String requestId = execution.getVariable("msoRequestId")
982 if (requestId != null) {
983 execution.setVariable("mso-request-id", requestId)
985 requestId = execution.getVariable("mso-request-id")
987 execution.setVariable(Prefix + "requestId", requestId)
989 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
991 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
992 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
993 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
994 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
995 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
996 utils.logAudit(sndcTopologyDeleteRequesAsString)
997 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
998 utils.log("DEBUG", Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
999 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
1002 } catch (Exception ex) {
1004 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage()
1005 logError(exceptionMessage)
1006 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1007 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1013 public void setExceptionFlag(Execution execution){
1014 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1015 execution.setVariable("prefix",Prefix)
1017 utils.log("DEBUG", " ***** Inside setExceptionFlag() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
1021 execution.setVariable(Prefix + "isException", true)
1023 if (execution.getVariable("SavedWorkflowException1") != null) {
1024 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1"))
1026 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException"))
1028 utils.log("DEBUG", Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled)
1030 } catch(Exception ex){
1031 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage()
1032 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1033 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1039 // *******************************
1040 // Build Error Section
1041 // *******************************
1043 public void processJavaException(Execution execution){
1044 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1045 execution.setVariable("prefix",Prefix)
1047 utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
1048 utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
1049 utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
1050 execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated
1051 exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
1053 }catch(Exception e){
1054 utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
1055 execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated
1056 exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method")
1058 utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled)