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.getNodeText1(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")
244 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
245 AaiUtil aaiUriUtil = new AaiUtil(this)
246 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
247 String queryAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=1"
248 utils.logAudit(queryAAIRequest)
249 execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest)
250 utils.log("DEBUG", Prefix + "AAIRequest - " + "\n" + queryAAIRequest, isDebugEnabled)
252 RESTConfig config = new RESTConfig(queryAAIRequest);
254 ExceptionUtil exceptionUtil = new ExceptionUtil()
255 Boolean isVfRelationshipExist = false
257 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAIRequest)
258 String returnCode = response.getStatusCode()
259 execution.setVariable(Prefix + "aaiReturnCode", returnCode)
261 utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled)
263 String aaiResponseAsString = response.getResponseBodyAsString()
264 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
265 execution.setVariable(Prefix + "queryAAIResponse", aaiResponseAsString)
267 if (returnCode=='200' || returnCode=='204') {
268 utils.logAudit(aaiResponseAsString)
269 execution.setVariable(Prefix + "isAAIGood", true)
270 utils.log("DEBUG", " AAI Query Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled)
271 // verify if vf or vnf relationship exist
272 if (utils.nodeExists(aaiResponseAsString, "relationship")) {
273 NetworkUtils networkUtils = new NetworkUtils()
274 isVfRelationshipExist = networkUtils.isVfRelationshipExist(aaiResponseAsString)
275 execution.setVariable(Prefix + "isVfRelationshipExist", isVfRelationshipExist)
276 if (isVfRelationshipExist == true) {
277 String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId
278 exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage)
281 // verify if lcpCloudRegion was sent as input, if not get value from AAI Response
282 if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) {
283 String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString)
284 execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion)
285 utils.log("DEBUG", " Get AAI getCloudRegion() : " + lcpCloudRegion, isDebugEnabled)
287 if (execution.getVariable(Prefix + "tenantId") == null ) {
288 String tenantId = networkUtils.getTenantId(aaiResponseAsString)
289 execution.setVariable(Prefix + "tenantId", tenantId)
290 utils.log("DEBUG", " Get AAI getTenantId() : " + tenantId, isDebugEnabled)
295 utils.log("DEBUG", Prefix + "isVfRelationshipExist - " + isVfRelationshipExist, isDebugEnabled)
298 execution.setVariable(Prefix + "isAAIGood", false)
299 if (returnCode=='404' || aaiResponseAsString == "" || aaiResponseAsString == null) {
300 // not found // empty aai response
301 execution.setVariable(Prefix + "isSilentSuccess", true)
302 utils.log("DEBUG", " AAI Query is Silent Success", isDebugEnabled)
305 if (aaiResponseAsString.contains("RESTFault")) {
306 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
307 execution.setVariable("WorkflowException", exceptionObject)
311 String dataErrorMessage = "Unexpected Error Response from callRESTQueryAAI() - " + returnCode
312 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
313 exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage)
319 utils.log("DEBUG", " AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood"), isDebugEnabled)
321 } catch (Exception ex) {
323 String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage()
324 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
325 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
331 public void callRESTQueryAAICloudRegion (Execution execution) {
332 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
333 execution.setVariable("prefix", Prefix)
335 utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion of DoDeleteNetworkInstance ***** " , isDebugEnabled)
338 String networkInputs = execution.getVariable(Prefix + "networkInputs")
339 // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region")
340 String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion")
341 cloudRegion = UriUtils.encode(cloudRegion,"UTF-8")
343 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
344 AaiUtil aaiUtil = new AaiUtil(this)
345 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
346 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
347 utils.logAudit(queryCloudRegionRequest)
348 execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
349 utils.log("DEBUG", Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled)
351 String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
352 String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion)
354 if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) {
355 execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo)
356 execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc)
359 String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode")
360 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
361 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
365 } catch (BpmnError e) {
368 } catch (Exception ex) {
370 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, callRESTQueryAAICloudRegion(). Unexpected Response from AAI - " + ex.getMessage()
371 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
372 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
378 public void prepareNetworkRequest (Execution execution) {
379 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
380 execution.setVariable("prefix", Prefix)
382 utils.log("DEBUG", " ***** Inside prepareNetworkRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
383 ExceptionUtil exceptionUtil = new ExceptionUtil()
386 String networkRequest = execution.getVariable(Prefix + "networkRequest")
387 String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo")
388 String tenantId = execution.getVariable(Prefix + "tenantId")
390 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
391 String networkType = utils.getNodeText1(queryAAIResponse, "network-type")
392 String networkId = utils.getNodeText1(queryAAIResponse, "network-id")
393 String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled")
395 String networkStackId = ""
396 networkStackId = utils.getNodeText1(queryAAIResponse, "heat-stack-id")
397 if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) {
398 networkStackId = "force_delete"
401 String requestId = execution.getVariable("msoRequestId")
402 if (requestId != null) {
403 execution.setVariable("mso-request-id", requestId)
405 requestId = execution.getVariable("mso-request-id")
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 modelCustomizationUuid = ""
415 if (utils.nodeExists(networkRequest, "networkModelInfo")) {
416 String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
417 modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid")
420 String deleteNetworkRequest = """
421 <deleteNetworkRequest>
422 <cloudSiteId>${cloudSiteId}</cloudSiteId>
423 <tenantId>${tenantId}</tenantId>
424 <networkId>${networkId}</networkId>
425 <networkStackId>${networkStackId}</networkStackId>
426 <networkType>${networkType}</networkType>
427 <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
428 <skipAAI>true</skipAAI>
430 <requestId>${requestId}</requestId>
431 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
433 <messageId>${messageId}</messageId>
434 <notificationUrl>${notificationUrl}</notificationUrl>
435 </deleteNetworkRequest>
438 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest, isDebugEnabled)
440 String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest)
441 utils.logAudit(buildDeleteNetworkRequestAsString)
442 utils.log("DEBUG", Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
444 String restURL = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
445 execution.setVariable("URN_mso_adapters_network_rest_endpoint", restURL + "/" + networkId)
446 utils.log("DEBUG", "URN_mso_adapters_network_rest_endpoint - " + "\n" + restURL + "/" + networkId, isDebugEnabled)
448 execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString)
449 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
451 catch (Exception ex) {
453 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage()
454 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
455 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
461 * This method is used instead of an HTTP Connector task because the
462 * connector does not allow DELETE with a body.
464 public void sendRequestToVnfAdapter(Execution execution) {
465 def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' +
466 'execution=' + execution.getId() +
468 def isDebugEnabled = execution.getVariable('isDebugLogEnabled')
469 logDebug('Entered ' + method, isDebugEnabled)
473 String vnfAdapterUrl = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
474 String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest")
476 RESTConfig config = new RESTConfig(vnfAdapterUrl)
477 RESTClient client = new RESTClient(config).
478 addHeader("Content-Type", "application/xml").
479 addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO"));
481 APIResponse response;
483 response = client.httpDelete(vnfAdapterRequest)
485 execution.setVariable(Prefix + "networkReturnCode", response.getStatusCode())
486 execution.setVariable(Prefix + "deleteNetworkResponse", response.getResponseBodyAsString())
488 } catch (Exception ex) {
490 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage()
491 logError(exceptionMessage)
492 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
493 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
499 public void prepareSDNCRequest (Execution execution) {
500 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
501 execution.setVariable("prefix", Prefix)
503 utils.log("DEBUG", " ***** Inside prepareSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
507 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
508 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
510 String networkId = ""
511 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
512 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
514 if (networkId == 'null') {networkId = ""}
516 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
518 // get/set 'msoRequestId' and 'mso-request-id'
519 String requestId = execution.getVariable("msoRequestId")
520 if (requestId != null) {
521 execution.setVariable("mso-request-id", requestId)
523 requestId = execution.getVariable("mso-request-id")
525 execution.setVariable(Prefix + "requestId", requestId)
526 utils.log("DEBUG", Prefix + "requestId " + requestId, isDebugEnabled)
527 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
529 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
530 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
531 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
532 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
533 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
534 utils.logAudit(sndcTopologyDeleteRequesAsString)
535 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
536 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
538 } catch (Exception ex) {
540 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
541 logError(exceptionMessage)
542 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
543 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
549 public void prepareRpcSDNCRequest (Execution execution) {
550 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
551 execution.setVariable("prefix", Prefix)
553 utils.log("DEBUG", " ***** Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
557 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
558 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
560 String networkId = ""
561 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
562 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
564 if (networkId == 'null') {networkId = ""}
566 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
568 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
569 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
570 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
571 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null)
572 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
573 utils.logAudit(sndcTopologyDeleteRequesAsString)
574 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
575 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
577 } catch (Exception ex) {
579 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
580 logError(exceptionMessage)
581 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
582 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
589 public void prepareRpcSDNCDeactivate(Execution execution) {
590 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
591 execution.setVariable("prefix",Prefix)
593 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
598 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
599 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
600 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
601 String networkId = ""
602 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
603 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
605 if (networkId == 'null') {networkId = ""}
606 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
608 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null)
609 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
610 execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
611 utils.log("DEBUG", " Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
614 } catch (Exception ex) {
615 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage()
616 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
617 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
623 // **************************************************
624 // Post or Validate Response Section
625 // **************************************************
627 public void validateNetworkResponse (Execution execution) {
628 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
629 execution.setVariable("prefix", Prefix)
631 utils.log("DEBUG", " ***** Inside validateNetworkResponse of DoDeleteNetworkInstance *****", isDebugEnabled)
634 String returnCode = execution.getVariable(Prefix + "networkReturnCode")
635 String networkResponse = execution.getVariable(Prefix + "deleteNetworkResponse")
637 utils.log("DEBUG", " Network Adapter responseCode: " + returnCode, isDebugEnabled)
638 utils.log("DEBUG", "Network Adapter Response - " + "\n" + networkResponse, isDebugEnabled)
639 utils.logAudit(networkResponse)
641 String errorMessage = ""
642 if (returnCode == "200") {
643 utils.log("DEBUG", " Network Adapter Response is successful - " + "\n" + networkResponse, isDebugEnabled)
645 // prepare rollback data
646 String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","")
647 if ((rollbackData == null) || (rollbackData.isEmpty())) {
648 utils.log("DEBUG", " Network Adapter 'rollback' data is not Sent: " + "\n" + networkResponse, isDebugEnabled)
649 execution.setVariable(Prefix + "rollbackNetworkRequest", "")
651 String rollbackNetwork =
652 """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network">
654 </NetworkAdapter:rollbackNetwork>"""
655 String rollbackNetworkXml = utils.formatXml(rollbackNetwork)
656 execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml)
657 utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled)
661 } else { // network error
662 if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx
663 if (networkResponse.contains("deleteNetworkError") ) {
664 networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '')
665 errorMessage = utils.getNodeText1(networkResponse, "message")
666 errorMessage = "Received error from Network Adapter: " + errorMessage
667 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
669 } else { // CatchAll exception
670 if (returnCode == "500") {
671 errorMessage = "JBWEB000065: HTTP Status 500."
673 errorMessage = "Return code is " + returnCode
675 errorMessage = "Received error from Network Adapter: " + errorMessage
676 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
680 } else { // CatchAll exception
681 String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode
682 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
688 } catch (BpmnError e) {
691 } catch (Exception ex) {
693 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, validateNetworkResponse() - " + ex.getMessage()
694 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
695 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
701 public void validateSDNCResponse (Execution execution) {
702 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
703 execution.setVariable("prefix", Prefix)
705 utils.log("DEBUG", " ***** Inside validateSDNCResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
707 String response = execution.getVariable(Prefix + "deleteSDNCResponse")
708 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
709 WorkflowException workflowException = execution.getVariable("WorkflowException")
711 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
712 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
714 String deleteSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deleteSDNCResponse"))
715 deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
716 execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml)
718 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess'
719 execution.setVariable(Prefix + "isSdncRollbackNeeded", true) //
720 execution.setVariable(Prefix + "isPONR", true)
721 utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled)
723 utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled)
724 throw new BpmnError("MSOWorkflowException")
729 public void validateRpcSDNCDeactivateResponse (Execution execution) {
730 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
731 execution.setVariable("prefix",Prefix)
733 utils.log("DEBUG", " ***** Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
735 String response = execution.getVariable(Prefix + "deactivateSDNCResponse")
736 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
737 WorkflowException workflowException = execution.getVariable("WorkflowException")
739 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
740 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
742 String assignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deactivateSDNCResponse"))
743 assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
744 execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml)
746 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess'
747 execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true)
748 utils.log("DEBUG", "Successfully Validated Rpc SDNC Activate Response", isDebugEnabled)
751 utils.log("DEBUG", "Did NOT Successfully Validated Rpc SDNC Deactivate Response", isDebugEnabled)
752 throw new BpmnError("MSOWorkflowException")
757 public void prepareRpcSDNCDeactivateRollback(Execution execution) {
758 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
759 execution.setVariable("prefix",Prefix)
761 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
766 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
767 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
768 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
769 String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse")
770 String networkId = utils.getNodeText1(deactivateSDNCResponse, "network-id")
771 if (networkId == 'null') {networkId = ""}
772 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
774 // 2. prepare rollback topology via SDNC Adapter SUBFLOW call
775 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "ActivateNetworkInstance", cloudRegionId, networkId, null)
776 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
777 execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
778 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'activate-ActivateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
781 } catch (Exception ex) {
782 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage()
783 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
784 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
790 public void prepareRollbackData(Execution execution) {
791 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
792 execution.setVariable("prefix",Prefix)
794 utils.log("DEBUG", " ***** Inside prepareRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
798 Map<String, String> rollbackData = new HashMap<String, String>();
799 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
800 if (rollbackNetworkRequest != null) {
801 if (rollbackNetworkRequest != "") {
802 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
805 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
806 if (rollbackDeactivateSDNCRequest != null) {
807 if (rollbackDeactivateSDNCRequest != "") {
808 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
811 execution.setVariable("rollbackData", rollbackData)
812 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
814 execution.setVariable("WorkflowException", execution.getVariable("WorkflowException"))
815 utils.log("DEBUG", "** WorkflowException : " + execution.getVariable("WorkflowException"), isDebugEnabled)
817 } catch (Exception ex) {
818 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage()
819 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
820 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
826 public void postProcessResponse (Execution execution) {
827 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
828 execution.setVariable("prefix", Prefix)
830 utils.log("DEBUG", " ***** Inside postProcessResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
834 utils.log("DEBUG", " ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"), isDebugEnabled)
835 if (execution.getVariable(Prefix + "isException") == false) {
836 execution.setVariable(Prefix + "Success", true)
837 execution.setVariable("WorkflowException", null)
838 if (execution.getVariable(Prefix + "isSilentSuccess") == true) {
839 execution.setVariable("rolledBack", false)
841 execution.setVariable("rolledBack", true)
843 prepareSuccessRollbackData(execution) // populate rollbackData
846 execution.setVariable(Prefix + "Success", false)
847 execution.setVariable("rollbackData", null)
848 String exceptionMessage = " Exception encountered in MSO Bpmn. "
849 if (execution.getVariable("workflowException") != null) { // Output of Rollback flow.
850 utils.log("DEBUG", " ***** workflowException: " + execution.getVariable("workflowException"), isDebugEnabled)
851 WorkflowException wfex = execution.getVariable("workflowException")
852 exceptionMessage = wfex.getErrorMessage()
854 if (execution.getVariable(Prefix + "WorkflowException") != null) {
855 WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException")
856 exceptionMessage = pwfex.getErrorMessage()
858 if (execution.getVariable("WorkflowException") != null) {
859 WorkflowException pwfex = execution.getVariable("WorkflowException")
860 exceptionMessage = pwfex.getErrorMessage()
865 // going to the Main flow: a-la-carte or macro
866 utils.log("DEBUG", " ***** postProcessResponse(), BAD !!!", isDebugEnabled)
867 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
868 throw new BpmnError("MSOWorkflowException")
872 } catch(BpmnError b){
873 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
876 } catch (Exception ex) {
878 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage()
879 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
880 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
881 throw new BpmnError("MSOWorkflowException")
887 public void prepareSuccessRollbackData(Execution execution) {
888 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
889 execution.setVariable("prefix",Prefix)
891 utils.log("DEBUG", " ***** Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
895 if (execution.getVariable("sdncVersion") == '1702') {
896 prepareRpcSDNCDeactivateRollback(execution)
897 prepareRpcSDNCUnassignRollback(execution)
899 prepareSDNCRollback(execution)
902 Map<String, String> rollbackData = new HashMap<String, String>();
903 String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
904 if (rollbackSDNCRequest != null) {
905 if (rollbackSDNCRequest != "") {
906 rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest"))
909 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
910 if (rollbackNetworkRequest != null) {
911 if (rollbackNetworkRequest != "") {
912 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
915 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
916 if (rollbackDeactivateSDNCRequest != null) {
917 if (rollbackDeactivateSDNCRequest != "") {
918 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
921 execution.setVariable("rollbackData", rollbackData)
923 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
924 execution.setVariable("WorkflowException", null)
927 } catch (Exception ex) {
928 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage()
929 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
930 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
936 public void prepareRpcSDNCUnassignRollback(Execution execution) {
937 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
938 execution.setVariable("prefix",Prefix)
940 utils.log("DEBUG", " ***** Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
945 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
946 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
948 String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse")
949 String networkId = utils.getNodeText1(deleteSDNCResponse, "network-id")
950 if (networkId == 'null') {networkId = ""}
951 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
953 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
954 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
955 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
956 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null)
957 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
958 utils.logAudit(sndcTopologyDeleteRequesAsString)
959 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
960 utils.log("DEBUG", Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
961 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
964 } catch (Exception ex) {
965 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage()
966 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
967 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
973 public void prepareSDNCRollback (Execution execution) {
974 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
975 execution.setVariable("prefix", Prefix)
977 utils.log("DEBUG", " ***** Inside prepareSDNCRollback of DoDeleteNetworkInstance ***** ", isDebugEnabled)
982 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
983 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
985 String networkId = ""
986 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
987 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
989 if (networkId == 'null') {networkId = ""}
991 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
993 // get/set 'msoRequestId' and 'mso-request-id'
994 String requestId = execution.getVariable("msoRequestId")
995 if (requestId != null) {
996 execution.setVariable("mso-request-id", requestId)
998 requestId = execution.getVariable("mso-request-id")
1000 execution.setVariable(Prefix + "requestId", requestId)
1002 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
1004 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
1005 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1006 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
1007 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
1008 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
1009 utils.logAudit(sndcTopologyDeleteRequesAsString)
1010 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
1011 utils.log("DEBUG", Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
1012 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
1015 } catch (Exception ex) {
1017 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage()
1018 logError(exceptionMessage)
1019 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1020 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1026 public void setExceptionFlag(Execution execution){
1027 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1028 execution.setVariable("prefix",Prefix)
1030 utils.log("DEBUG", " ***** Inside setExceptionFlag() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
1034 execution.setVariable(Prefix + "isException", true)
1036 if (execution.getVariable("SavedWorkflowException1") != null) {
1037 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1"))
1039 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException"))
1041 utils.log("DEBUG", Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled)
1043 } catch(Exception ex){
1044 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage()
1045 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1046 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1052 // *******************************
1053 // Build Error Section
1054 // *******************************
1056 public void processJavaException(Execution execution){
1057 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1058 execution.setVariable("prefix",Prefix)
1060 utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
1061 utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
1062 utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
1063 execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated
1064 exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
1066 }catch(Exception e){
1067 utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
1068 execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated
1069 exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method")
1071 utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled)