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.delegate.DelegateExecution
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(DelegateExecution 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 (DelegateExecution 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 (DelegateExecution 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=all"
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) {
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 (DelegateExecution 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 (DelegateExecution 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")
419 modelCustomizationUuid = utils.getNodeText1(networkRequest, "modelCustomizationId")
422 String deleteNetworkRequest = """
423 <deleteNetworkRequest>
424 <cloudSiteId>${cloudSiteId}</cloudSiteId>
425 <tenantId>${tenantId}</tenantId>
426 <networkId>${networkId}</networkId>
427 <networkStackId>${networkStackId}</networkStackId>
428 <networkType>${networkType}</networkType>
429 <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
430 <skipAAI>true</skipAAI>
432 <requestId>${requestId}</requestId>
433 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
435 <messageId>${messageId}</messageId>
436 <notificationUrl>${notificationUrl}</notificationUrl>
437 </deleteNetworkRequest>
440 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest, isDebugEnabled)
442 String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest)
443 utils.logAudit(buildDeleteNetworkRequestAsString)
444 utils.log("DEBUG", Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
446 String restURL = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
447 execution.setVariable("URN_mso_adapters_network_rest_endpoint", restURL + "/" + networkId)
448 utils.log("DEBUG", "URN_mso_adapters_network_rest_endpoint - " + "\n" + restURL + "/" + networkId, isDebugEnabled)
450 execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString)
451 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
453 catch (Exception ex) {
455 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage()
456 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
457 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
463 * This method is used instead of an HTTP Connector task because the
464 * connector does not allow DELETE with a body.
466 public void sendRequestToVnfAdapter(DelegateExecution execution) {
467 def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' +
468 'execution=' + execution.getId() +
470 def isDebugEnabled = execution.getVariable('isDebugLogEnabled')
471 logDebug('Entered ' + method, isDebugEnabled)
475 String vnfAdapterUrl = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
476 String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest")
478 RESTConfig config = new RESTConfig(vnfAdapterUrl)
479 RESTClient client = new RESTClient(config).
480 addHeader("Content-Type", "application/xml").
481 addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO"));
483 APIResponse response;
485 response = client.httpDelete(vnfAdapterRequest)
487 execution.setVariable(Prefix + "networkReturnCode", response.getStatusCode())
488 execution.setVariable(Prefix + "deleteNetworkResponse", response.getResponseBodyAsString())
490 } catch (Exception ex) {
492 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage()
493 logError(exceptionMessage)
494 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
495 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
501 public void prepareSDNCRequest (DelegateExecution execution) {
502 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
503 execution.setVariable("prefix", Prefix)
505 utils.log("DEBUG", " ***** Inside prepareSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
509 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
510 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
512 String networkId = ""
513 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
514 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
516 if (networkId == 'null') {networkId = ""}
518 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
520 // get/set 'msoRequestId' and 'mso-request-id'
521 String requestId = execution.getVariable("msoRequestId")
522 if (requestId != null) {
523 execution.setVariable("mso-request-id", requestId)
525 requestId = execution.getVariable("mso-request-id")
527 execution.setVariable(Prefix + "requestId", requestId)
528 utils.log("DEBUG", Prefix + "requestId " + requestId, isDebugEnabled)
529 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
531 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
532 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
533 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
534 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
535 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
536 utils.logAudit(sndcTopologyDeleteRequesAsString)
537 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
538 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
540 } catch (Exception ex) {
542 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
543 logError(exceptionMessage)
544 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
545 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
551 public void prepareRpcSDNCRequest (DelegateExecution execution) {
552 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
553 execution.setVariable("prefix", Prefix)
555 utils.log("DEBUG", " ***** Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
559 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
560 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
562 String networkId = ""
563 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
564 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
566 if (networkId == 'null') {networkId = ""}
568 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
570 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
571 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
572 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
573 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null)
574 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
575 utils.logAudit(sndcTopologyDeleteRequesAsString)
576 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
577 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
579 } catch (Exception ex) {
581 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
582 logError(exceptionMessage)
583 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
584 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
591 public void prepareRpcSDNCDeactivate(DelegateExecution execution) {
592 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
593 execution.setVariable("prefix",Prefix)
595 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
600 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
601 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
602 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
603 String networkId = ""
604 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
605 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
607 if (networkId == 'null') {networkId = ""}
608 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
610 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null)
611 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
612 execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
613 utils.log("DEBUG", " Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
616 } catch (Exception ex) {
617 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage()
618 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
619 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
625 // **************************************************
626 // Post or Validate Response Section
627 // **************************************************
629 public void validateNetworkResponse (DelegateExecution execution) {
630 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
631 execution.setVariable("prefix", Prefix)
633 utils.log("DEBUG", " ***** Inside validateNetworkResponse of DoDeleteNetworkInstance *****", isDebugEnabled)
636 String returnCode = execution.getVariable(Prefix + "networkReturnCode")
637 String networkResponse = execution.getVariable(Prefix + "deleteNetworkResponse")
639 utils.log("DEBUG", " Network Adapter responseCode: " + returnCode, isDebugEnabled)
640 utils.log("DEBUG", "Network Adapter Response - " + "\n" + networkResponse, isDebugEnabled)
641 utils.logAudit(networkResponse)
643 String errorMessage = ""
644 if (returnCode == "200") {
645 utils.log("DEBUG", " Network Adapter Response is successful - " + "\n" + networkResponse, isDebugEnabled)
647 // prepare rollback data
648 String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","")
649 if ((rollbackData == null) || (rollbackData.isEmpty())) {
650 utils.log("DEBUG", " Network Adapter 'rollback' data is not Sent: " + "\n" + networkResponse, isDebugEnabled)
651 execution.setVariable(Prefix + "rollbackNetworkRequest", "")
653 String rollbackNetwork =
654 """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network">
656 </NetworkAdapter:rollbackNetwork>"""
657 String rollbackNetworkXml = utils.formatXml(rollbackNetwork)
658 execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml)
659 utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled)
663 } else { // network error
664 if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx
665 if (networkResponse.contains("deleteNetworkError") ) {
666 networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '')
667 errorMessage = utils.getNodeText1(networkResponse, "message")
668 errorMessage = "Received error from Network Adapter: " + errorMessage
669 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
671 } else { // CatchAll exception
672 if (returnCode == "500") {
673 errorMessage = "JBWEB000065: HTTP Status 500."
675 errorMessage = "Return code is " + returnCode
677 errorMessage = "Received error from Network Adapter: " + errorMessage
678 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
682 } else { // CatchAll exception
683 String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode
684 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
690 } catch (BpmnError e) {
693 } catch (Exception ex) {
695 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, validateNetworkResponse() - " + ex.getMessage()
696 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
697 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
703 public void validateSDNCResponse (DelegateExecution execution) {
704 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
705 execution.setVariable("prefix", Prefix)
707 utils.log("DEBUG", " ***** Inside validateSDNCResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
709 String response = execution.getVariable(Prefix + "deleteSDNCResponse")
710 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
711 WorkflowException workflowException = execution.getVariable("WorkflowException")
713 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
714 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
716 String deleteSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deleteSDNCResponse"))
717 deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
718 execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml)
720 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess'
721 execution.setVariable(Prefix + "isSdncRollbackNeeded", true) //
722 execution.setVariable(Prefix + "isPONR", true)
723 utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled)
725 utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled)
726 throw new BpmnError("MSOWorkflowException")
731 public void validateRpcSDNCDeactivateResponse (DelegateExecution execution) {
732 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
733 execution.setVariable("prefix",Prefix)
735 utils.log("DEBUG", " ***** Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
737 String response = execution.getVariable(Prefix + "deactivateSDNCResponse")
738 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
739 WorkflowException workflowException = execution.getVariable("WorkflowException")
741 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
742 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
744 String assignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deactivateSDNCResponse"))
745 assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
746 execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml)
748 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess'
749 execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true)
750 utils.log("DEBUG", "Successfully Validated Rpc SDNC Activate Response", isDebugEnabled)
753 utils.log("DEBUG", "Did NOT Successfully Validated Rpc SDNC Deactivate Response", isDebugEnabled)
754 throw new BpmnError("MSOWorkflowException")
759 public void prepareRpcSDNCDeactivateRollback(DelegateExecution execution) {
760 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
761 execution.setVariable("prefix",Prefix)
763 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
768 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
769 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
770 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
771 String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse")
772 String networkId = utils.getNodeText1(deactivateSDNCResponse, "network-id")
773 if (networkId == 'null') {networkId = ""}
774 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
776 // 2. prepare rollback topology via SDNC Adapter SUBFLOW call
777 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null)
778 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
779 execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
780 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'activate-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
783 } catch (Exception ex) {
784 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage()
785 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
786 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
792 public void prepareRollbackData(DelegateExecution execution) {
793 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
794 execution.setVariable("prefix",Prefix)
796 utils.log("DEBUG", " ***** Inside prepareRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
800 Map<String, String> rollbackData = new HashMap<String, String>();
801 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
802 if (rollbackNetworkRequest != null) {
803 if (rollbackNetworkRequest != "") {
804 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
807 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
808 if (rollbackDeactivateSDNCRequest != null) {
809 if (rollbackDeactivateSDNCRequest != "") {
810 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
813 execution.setVariable("rollbackData", rollbackData)
814 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
816 execution.setVariable("WorkflowException", execution.getVariable("WorkflowException"))
817 utils.log("DEBUG", "** WorkflowException : " + execution.getVariable("WorkflowException"), isDebugEnabled)
819 } catch (Exception ex) {
820 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage()
821 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
822 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
828 public void postProcessResponse (DelegateExecution execution) {
829 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
830 execution.setVariable("prefix", Prefix)
832 utils.log("DEBUG", " ***** Inside postProcessResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
836 utils.log("DEBUG", " ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"), isDebugEnabled)
837 if (execution.getVariable(Prefix + "isException") == false) {
838 execution.setVariable(Prefix + "Success", true)
839 execution.setVariable("WorkflowException", null)
840 if (execution.getVariable(Prefix + "isSilentSuccess") == true) {
841 execution.setVariable("rolledBack", false)
843 execution.setVariable("rolledBack", true)
845 prepareSuccessRollbackData(execution) // populate rollbackData
848 execution.setVariable(Prefix + "Success", false)
849 execution.setVariable("rollbackData", null)
850 String exceptionMessage = " Exception encountered in MSO Bpmn. "
851 if (execution.getVariable("workflowException") != null) { // Output of Rollback flow.
852 utils.log("DEBUG", " ***** workflowException: " + execution.getVariable("workflowException"), isDebugEnabled)
853 WorkflowException wfex = execution.getVariable("workflowException")
854 exceptionMessage = wfex.getErrorMessage()
856 if (execution.getVariable(Prefix + "WorkflowException") != null) {
857 WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException")
858 exceptionMessage = pwfex.getErrorMessage()
860 if (execution.getVariable("WorkflowException") != null) {
861 WorkflowException pwfex = execution.getVariable("WorkflowException")
862 exceptionMessage = pwfex.getErrorMessage()
867 // going to the Main flow: a-la-carte or macro
868 utils.log("DEBUG", " ***** postProcessResponse(), BAD !!!", isDebugEnabled)
869 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
870 throw new BpmnError("MSOWorkflowException")
874 } catch(BpmnError b){
875 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
878 } catch (Exception ex) {
880 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage()
881 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
882 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
883 throw new BpmnError("MSOWorkflowException")
889 public void prepareSuccessRollbackData(DelegateExecution execution) {
890 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
891 execution.setVariable("prefix",Prefix)
893 utils.log("DEBUG", " ***** Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
897 if (execution.getVariable("sdncVersion") != '1610') {
898 prepareRpcSDNCDeactivateRollback(execution)
899 prepareRpcSDNCUnassignRollback(execution)
901 prepareSDNCRollback(execution)
904 Map<String, String> rollbackData = new HashMap<String, String>();
905 String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
906 if (rollbackSDNCRequest != null) {
907 if (rollbackSDNCRequest != "") {
908 rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest"))
911 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
912 if (rollbackNetworkRequest != null) {
913 if (rollbackNetworkRequest != "") {
914 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
917 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
918 if (rollbackDeactivateSDNCRequest != null) {
919 if (rollbackDeactivateSDNCRequest != "") {
920 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
923 execution.setVariable("rollbackData", rollbackData)
925 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
926 execution.setVariable("WorkflowException", null)
929 } catch (Exception ex) {
930 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage()
931 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
932 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
938 public void prepareRpcSDNCUnassignRollback(DelegateExecution execution) {
939 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
940 execution.setVariable("prefix",Prefix)
942 utils.log("DEBUG", " ***** Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
947 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
948 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
950 String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse")
951 String networkId = utils.getNodeText1(deleteSDNCResponse, "network-id")
952 if (networkId == 'null') {networkId = ""}
953 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
955 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
956 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
957 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
958 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null)
959 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
960 utils.logAudit(sndcTopologyDeleteRequesAsString)
961 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
962 utils.log("DEBUG", Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
963 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
966 } catch (Exception ex) {
967 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage()
968 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
969 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
975 public void prepareSDNCRollback (DelegateExecution execution) {
976 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
977 execution.setVariable("prefix", Prefix)
979 utils.log("DEBUG", " ***** Inside prepareSDNCRollback of DoDeleteNetworkInstance ***** ", isDebugEnabled)
984 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
985 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
987 String networkId = ""
988 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
989 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
991 if (networkId == 'null') {networkId = ""}
993 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
995 // get/set 'msoRequestId' and 'mso-request-id'
996 String requestId = execution.getVariable("msoRequestId")
997 if (requestId != null) {
998 execution.setVariable("mso-request-id", requestId)
1000 requestId = execution.getVariable("mso-request-id")
1002 execution.setVariable(Prefix + "requestId", requestId)
1004 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
1006 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
1007 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1008 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
1009 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
1010 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
1011 utils.logAudit(sndcTopologyDeleteRequesAsString)
1012 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
1013 utils.log("DEBUG", Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
1014 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
1017 } catch (Exception ex) {
1019 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage()
1020 logError(exceptionMessage)
1021 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1022 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1028 public void setExceptionFlag(DelegateExecution execution){
1029 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1030 execution.setVariable("prefix",Prefix)
1032 utils.log("DEBUG", " ***** Inside setExceptionFlag() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
1036 execution.setVariable(Prefix + "isException", true)
1038 if (execution.getVariable("SavedWorkflowException1") != null) {
1039 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1"))
1041 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException"))
1043 utils.log("DEBUG", Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled)
1045 } catch(Exception ex){
1046 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage()
1047 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1048 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1054 // *******************************
1055 // Build Error Section
1056 // *******************************
1058 public void processJavaException(DelegateExecution execution){
1059 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1060 execution.setVariable("prefix",Prefix)
1062 utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
1063 utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
1064 utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
1065 execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated
1066 exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
1068 }catch(Exception e){
1069 utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
1070 execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated
1071 exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method")
1073 utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled)