2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
20 package org.openecomp.mso.bpmn.infrastructure.scripts;
\r
22 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
23 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
\r
24 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
\r
25 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
\r
26 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils
\r
27 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
\r
28 import org.openecomp.mso.bpmn.common.scripts.VidUtils
\r
29 import org.openecomp.mso.bpmn.core.WorkflowException
\r
30 import org.openecomp.mso.rest.APIResponse;
\r
31 import org.openecomp.mso.rest.RESTClient
\r
32 import org.openecomp.mso.rest.RESTConfig
\r
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")
242 String messageId = execution.getVariable(Prefix + "messageId")
245 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
246 AaiUtil aaiUriUtil = new AaiUtil(this)
247 String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution)
248 String queryAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=1"
249 utils.logAudit(queryAAIRequest)
250 execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest)
251 utils.log("DEBUG", Prefix + "AAIRequest - " + "\n" + queryAAIRequest, isDebugEnabled)
253 RESTConfig config = new RESTConfig(queryAAIRequest);
255 ExceptionUtil exceptionUtil = new ExceptionUtil()
256 Boolean isVfRelationshipExist = false
258 RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId)
259 .addHeader("X-FromAppId", "MSO")
260 .addHeader("Content-Type", "application/xml")
261 .addHeader("Accept","application/xml");
262 APIResponse response = client.get()
263 String returnCode = response.getStatusCode()
264 execution.setVariable(Prefix + "aaiReturnCode", returnCode)
266 utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled)
268 String aaiResponseAsString = response.getResponseBodyAsString()
269 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
270 execution.setVariable(Prefix + "queryAAIResponse", aaiResponseAsString)
272 if (returnCode=='200' || returnCode=='204') {
273 utils.logAudit(aaiResponseAsString)
274 execution.setVariable(Prefix + "isAAIGood", true)
275 utils.log("DEBUG", " AAI Query Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled)
276 // verify if vf or vnf relationship exist
277 if (utils.nodeExists(aaiResponseAsString, "relationship")) {
278 NetworkUtils networkUtils = new NetworkUtils()
279 isVfRelationshipExist = networkUtils.isVfRelationshipExist(aaiResponseAsString)
280 execution.setVariable(Prefix + "isVfRelationshipExist", isVfRelationshipExist)
281 if (isVfRelationshipExist == true) {
282 String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId
283 exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage)
286 // verify if lcpCloudRegion was sent as input, if not get value from AAI Response
287 if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) {
288 String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString)
289 execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion)
290 utils.log("DEBUG", " Get AAI getCloudRegion() : " + lcpCloudRegion, isDebugEnabled)
292 if (execution.getVariable(Prefix + "tenantId") == null ) {
293 String tenantId = networkUtils.getTenantId(aaiResponseAsString)
294 execution.setVariable(Prefix + "tenantId", tenantId)
295 utils.log("DEBUG", " Get AAI getTenantId() : " + tenantId, isDebugEnabled)
300 utils.log("DEBUG", Prefix + "isVfRelationshipExist - " + isVfRelationshipExist, isDebugEnabled)
303 execution.setVariable(Prefix + "isAAIGood", false)
304 if (returnCode=='404' || aaiResponseAsString == "" || aaiResponseAsString == null) {
305 // not found // empty aai response
306 execution.setVariable(Prefix + "isSilentSuccess", true)
307 utils.log("DEBUG", " AAI Query is Silent Success", isDebugEnabled)
310 if (aaiResponseAsString.contains("RESTFault")) {
311 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
312 execution.setVariable("WorkflowException", exceptionObject)
316 String dataErrorMessage = "Unexpected Error Response from callRESTQueryAAI() - " + returnCode
317 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
318 exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage)
324 utils.log("DEBUG", " AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood"), isDebugEnabled)
326 } catch (Exception ex) {
328 String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage()
329 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
330 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
336 public void callRESTQueryAAICloudRegion (Execution execution) {
337 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
338 execution.setVariable("prefix", Prefix)
340 utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion of DoDeleteNetworkInstance ***** " , isDebugEnabled)
343 String networkInputs = execution.getVariable(Prefix + "networkInputs")
344 // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region")
345 String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion")
346 cloudRegion = UriUtils.encode(cloudRegion,"UTF-8")
348 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
349 AaiUtil aaiUtil = new AaiUtil(this)
350 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
351 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
352 utils.logAudit(queryCloudRegionRequest)
353 execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
354 utils.log("DEBUG", Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled)
356 String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
357 String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion)
359 if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) {
360 execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo)
361 execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc)
364 String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode")
365 utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
366 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
370 } catch (BpmnError e) {
373 } catch (Exception ex) {
375 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, callRESTQueryAAICloudRegion(). Unexpected Response from AAI - " + ex.getMessage()
376 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
377 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
383 public void prepareNetworkRequest (Execution execution) {
384 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
385 execution.setVariable("prefix", Prefix)
387 utils.log("DEBUG", " ***** Inside prepareNetworkRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
388 ExceptionUtil exceptionUtil = new ExceptionUtil()
391 String networkRequest = execution.getVariable(Prefix + "networkRequest")
392 String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo")
393 String tenantId = execution.getVariable(Prefix + "tenantId")
395 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
396 String networkType = utils.getNodeText1(queryAAIResponse, "network-type")
397 String networkId = utils.getNodeText1(queryAAIResponse, "network-id")
398 String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled")
400 String networkStackId = ""
401 networkStackId = utils.getNodeText1(queryAAIResponse, "heat-stack-id")
402 if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) {
403 networkStackId = "force_delete"
406 String requestId = execution.getVariable("msoRequestId")
407 if (requestId != null) {
408 execution.setVariable("mso-request-id", requestId)
410 requestId = execution.getVariable("mso-request-id")
412 String serviceInstanceId = execution.getVariable("serviceInstanceId")
414 // Added new Elements
415 String messageId = execution.getVariable(Prefix + "messageId")
416 String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use?
417 //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use?
419 String modelCustomizationUuid = ""
420 if (utils.nodeExists(networkRequest, "networkModelInfo")) {
421 String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
422 modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid")
425 String deleteNetworkRequest = """
426 <deleteNetworkRequest>
427 <cloudSiteId>${cloudSiteId}</cloudSiteId>
428 <tenantId>${tenantId}</tenantId>
429 <networkId>${networkId}</networkId>
430 <networkStackId>${networkStackId}</networkStackId>
431 <networkType>${networkType}</networkType>
432 <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
433 <skipAAI>true</skipAAI>
435 <requestId>${requestId}</requestId>
436 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
438 <messageId>${messageId}</messageId>
439 <notificationUrl>${notificationUrl}</notificationUrl>
440 </deleteNetworkRequest>
443 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest, isDebugEnabled)
445 String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest)
446 utils.logAudit(buildDeleteNetworkRequestAsString)
447 utils.log("DEBUG", Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
449 String restURL = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
450 execution.setVariable("URN_mso_adapters_network_rest_endpoint", restURL + "/" + networkId)
451 utils.log("DEBUG", "URN_mso_adapters_network_rest_endpoint - " + "\n" + restURL + "/" + networkId, isDebugEnabled)
453 execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString)
454 utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled)
456 catch (Exception ex) {
458 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage()
459 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
460 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
466 * This method is used instead of an HTTP Connector task because the
467 * connector does not allow DELETE with a body.
469 public void sendRequestToVnfAdapter(Execution execution) {
470 def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' +
471 'execution=' + execution.getId() +
473 def isDebugEnabled = execution.getVariable('isDebugLogEnabled')
474 logDebug('Entered ' + method, isDebugEnabled)
478 String vnfAdapterUrl = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
479 String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest")
481 RESTConfig config = new RESTConfig(vnfAdapterUrl)
482 RESTClient client = new RESTClient(config).
483 addHeader("Content-Type", "application/xml").
484 addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO"));
486 APIResponse response;
488 response = client.httpDelete(vnfAdapterRequest)
490 execution.setVariable(Prefix + "networkReturnCode", response.getStatusCode())
491 execution.setVariable(Prefix + "deleteNetworkResponse", response.getResponseBodyAsString())
493 } catch (Exception ex) {
495 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage()
496 logError(exceptionMessage)
497 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
498 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
504 public void prepareSDNCRequest (Execution execution) {
505 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
506 execution.setVariable("prefix", Prefix)
508 utils.log("DEBUG", " ***** Inside prepareSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
512 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
513 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
515 String networkId = ""
516 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
517 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
519 if (networkId == 'null') {networkId = ""}
521 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
523 // get/set 'msoRequestId' and 'mso-request-id'
\r
524 String requestId = execution.getVariable("msoRequestId")
525 if (requestId != null) {
526 execution.setVariable("mso-request-id", requestId)
\r
528 requestId = execution.getVariable("mso-request-id")
\r
530 execution.setVariable(Prefix + "requestId", requestId)
532 utils.log("DEBUG", Prefix + "requestId " + requestId, isDebugEnabled)
533 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
535 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
536 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
537 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
538 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
539 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
540 utils.logAudit(sndcTopologyDeleteRequesAsString)
541 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
542 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
544 } catch (Exception ex) {
546 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
547 logError(exceptionMessage)
548 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
549 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
555 public void prepareRpcSDNCRequest (Execution execution) {
556 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
557 execution.setVariable("prefix", Prefix)
559 utils.log("DEBUG", " ***** Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled)
563 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
564 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
566 String networkId = ""
567 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
568 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
570 if (networkId == 'null') {networkId = ""}
572 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
574 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
575 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
576 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
577 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null)
578 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
579 utils.logAudit(sndcTopologyDeleteRequesAsString)
580 execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString)
581 utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
583 } catch (Exception ex) {
585 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage()
586 logError(exceptionMessage)
587 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
588 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
595 public void prepareRpcSDNCDeactivate(Execution execution) {
596 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
597 execution.setVariable("prefix",Prefix)
599 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
604 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
605 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
606 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
607 String networkId = ""
608 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
609 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
611 if (networkId == 'null') {networkId = ""}
612 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
614 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null)
615 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
616 execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
617 utils.log("DEBUG", " Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
620 } catch (Exception ex) {
621 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage()
622 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
623 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
629 // **************************************************
630 // Post or Validate Response Section
631 // **************************************************
633 public void validateNetworkResponse (Execution execution) {
634 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
635 execution.setVariable("prefix", Prefix)
637 utils.log("DEBUG", " ***** Inside validateNetworkResponse of DoDeleteNetworkInstance *****", isDebugEnabled)
640 String returnCode = execution.getVariable(Prefix + "networkReturnCode")
641 String networkResponse = execution.getVariable(Prefix + "deleteNetworkResponse")
643 utils.log("DEBUG", " Network Adapter responseCode: " + returnCode, isDebugEnabled)
644 utils.log("DEBUG", "Network Adapter Response - " + "\n" + networkResponse, isDebugEnabled)
645 utils.logAudit(networkResponse)
647 String errorMessage = ""
648 if (returnCode == "200") {
649 utils.log("DEBUG", " Network Adapter Response is successful - " + "\n" + networkResponse, isDebugEnabled)
651 // prepare rollback data
652 String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","")
653 if ((rollbackData == null) || (rollbackData.isEmpty())) {
654 utils.log("DEBUG", " Network Adapter 'rollback' data is not Sent: " + "\n" + networkResponse, isDebugEnabled)
655 execution.setVariable(Prefix + "rollbackNetworkRequest", "")
657 String rollbackNetwork =
658 """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network">
\r
660 </NetworkAdapter:rollbackNetwork>"""
661 String rollbackNetworkXml = utils.formatXml(rollbackNetwork)
662 execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml)
663 utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled)
667 } else { // network error
668 if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx
669 if (networkResponse.contains("deleteNetworkError") ) {
670 networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '')
671 errorMessage = utils.getNodeText1(networkResponse, "message")
672 errorMessage = "Received error from Network Adapter: " + errorMessage
673 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
675 } else { // CatchAll exception
676 if (returnCode == "500") {
677 errorMessage = "JBWEB000065: HTTP Status 500."
679 errorMessage = "Return code is " + returnCode
681 errorMessage = "Received error from Network Adapter: " + errorMessage
682 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
686 } else { // CatchAll exception
687 String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode
688 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
694 } catch (BpmnError e) {
697 } catch (Exception ex) {
699 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, validateNetworkResponse() - " + ex.getMessage()
700 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
701 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
707 public void validateSDNCResponse (Execution execution) {
708 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
709 execution.setVariable("prefix", Prefix)
711 utils.log("DEBUG", " ***** Inside validateSDNCResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
713 String response = execution.getVariable(Prefix + "deleteSDNCResponse")
714 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
715 WorkflowException workflowException = execution.getVariable("WorkflowException")
717 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
718 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
720 String deleteSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deleteSDNCResponse"))
721 deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
722 execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml)
724 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess'
725 execution.setVariable(Prefix + "isSdncRollbackNeeded", true) //
726 execution.setVariable(Prefix + "isPONR", true)
727 utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled)
729 utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled)
730 throw new BpmnError("MSOWorkflowException")
735 public void validateRpcSDNCDeactivateResponse (Execution execution) {
736 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
737 execution.setVariable("prefix",Prefix)
739 utils.log("DEBUG", " ***** Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
741 String response = execution.getVariable(Prefix + "deactivateSDNCResponse")
742 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
743 WorkflowException workflowException = execution.getVariable("WorkflowException")
745 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
746 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
748 String assignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deactivateSDNCResponse"))
749 assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
750 execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml)
752 if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess'
753 execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true)
754 utils.log("DEBUG", "Successfully Validated Rpc SDNC Activate Response", isDebugEnabled)
757 utils.log("DEBUG", "Did NOT Successfully Validated Rpc SDNC Deactivate Response", isDebugEnabled)
758 throw new BpmnError("MSOWorkflowException")
763 public void prepareRpcSDNCDeactivateRollback(Execution execution) {
764 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
765 execution.setVariable("prefix",Prefix)
767 utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
772 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
773 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
774 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
775 String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse")
776 String networkId = utils.getNodeText1(deactivateSDNCResponse, "network-id")
777 if (networkId == 'null') {networkId = ""}
778 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
780 // 2. prepare rollback topology via SDNC Adapter SUBFLOW call
781 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "ActivateNetworkInstance", cloudRegionId, networkId, null)
782 String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
783 execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString)
784 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'activate-ActivateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled)
787 } catch (Exception ex) {
788 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage()
789 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
790 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
796 public void prepareRollbackData(Execution execution) {
797 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
798 execution.setVariable("prefix",Prefix)
800 utils.log("DEBUG", " ***** Inside prepareRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
804 Map<String, String> rollbackData = new HashMap<String, String>();
805 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
806 if (rollbackNetworkRequest != null) {
807 if (rollbackNetworkRequest != "") {
808 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
811 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
812 if (rollbackDeactivateSDNCRequest != null) {
813 if (rollbackDeactivateSDNCRequest != "") {
814 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
817 execution.setVariable("rollbackData", rollbackData)
818 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
820 execution.setVariable("WorkflowException", execution.getVariable("WorkflowException"))
821 utils.log("DEBUG", "** WorkflowException : " + execution.getVariable("WorkflowException"), isDebugEnabled)
823 } catch (Exception ex) {
824 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage()
825 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
826 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
832 public void postProcessResponse (Execution execution) {
833 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
834 execution.setVariable("prefix", Prefix)
836 utils.log("DEBUG", " ***** Inside postProcessResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled)
840 utils.log("DEBUG", " ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"), isDebugEnabled)
841 if (execution.getVariable(Prefix + "isException") == false) {
842 execution.setVariable(Prefix + "Success", true)
843 execution.setVariable("WorkflowException", null)
844 if (execution.getVariable(Prefix + "isSilentSuccess") == true) {
845 execution.setVariable("rolledBack", false)
847 execution.setVariable("rolledBack", true)
849 prepareSuccessRollbackData(execution) // populate rollbackData
852 execution.setVariable(Prefix + "Success", false)
853 execution.setVariable("rollbackData", null)
854 String exceptionMessage = " Exception encountered in MSO Bpmn. "
855 if (execution.getVariable("workflowException") != null) { // Output of Rollback flow.
856 utils.log("DEBUG", " ***** workflowException: " + execution.getVariable("workflowException"), isDebugEnabled)
857 WorkflowException wfex = execution.getVariable("workflowException")
858 exceptionMessage = wfex.getErrorMessage()
860 if (execution.getVariable(Prefix + "WorkflowException") != null) {
861 WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException")
862 exceptionMessage = pwfex.getErrorMessage()
864 if (execution.getVariable("WorkflowException") != null) {
865 WorkflowException pwfex = execution.getVariable("WorkflowException")
866 exceptionMessage = pwfex.getErrorMessage()
871 // going to the Main flow: a-la-carte or macro
872 utils.log("DEBUG", " ***** postProcessResponse(), BAD !!!", isDebugEnabled)
873 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
874 throw new BpmnError("MSOWorkflowException")
878 } catch(BpmnError b){
879 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
882 } catch (Exception ex) {
884 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage()
885 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
886 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
887 throw new BpmnError("MSOWorkflowException")
893 public void prepareSuccessRollbackData(Execution execution) {
894 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
895 execution.setVariable("prefix",Prefix)
897 utils.log("DEBUG", " ***** Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
901 if (execution.getVariable("sdncVersion") == '1702') {
902 prepareRpcSDNCDeactivateRollback(execution)
903 prepareRpcSDNCUnassignRollback(execution)
905 prepareSDNCRollback(execution)
908 Map<String, String> rollbackData = new HashMap<String, String>();
909 String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
910 if (rollbackSDNCRequest != null) {
911 if (rollbackSDNCRequest != "") {
912 rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest"))
915 String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
916 if (rollbackNetworkRequest != null) {
917 if (rollbackNetworkRequest != "") {
918 rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest"))
921 String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")
922 if (rollbackDeactivateSDNCRequest != null) {
923 if (rollbackDeactivateSDNCRequest != "") {
924 rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest"))
927 execution.setVariable("rollbackData", rollbackData)
929 utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled)
930 execution.setVariable("WorkflowException", null)
933 } catch (Exception ex) {
934 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage()
935 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
936 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
942 public void prepareRpcSDNCUnassignRollback(Execution execution) {
943 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
944 execution.setVariable("prefix",Prefix)
946 utils.log("DEBUG", " ***** Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
951 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
952 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
954 String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse")
955 String networkId = utils.getNodeText1(deleteSDNCResponse, "network-id")
956 if (networkId == 'null') {networkId = ""}
957 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
959 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
960 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
961 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
962 String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null)
963 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest)
964 utils.logAudit(sndcTopologyDeleteRequesAsString)
965 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
966 utils.log("DEBUG", Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
967 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
970 } catch (Exception ex) {
971 String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage()
972 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
973 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
979 public void prepareSDNCRollback (Execution execution) {
980 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
981 execution.setVariable("prefix", Prefix)
983 utils.log("DEBUG", " ***** Inside prepareSDNCRollback of DoDeleteNetworkInstance ***** ", isDebugEnabled)
988 String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
989 String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
991 String networkId = ""
992 if (utils.nodeExists(deleteNetworkInput, "network-id")) {
993 networkId = utils.getNodeText1(deleteNetworkInput, "network-id")
995 if (networkId == 'null') {networkId = ""}
997 String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id")
999 // get/set 'msoRequestId' and 'mso-request-id'
\r
1000 String requestId = execution.getVariable("msoRequestId")
1001 if (requestId != null) {
1002 execution.setVariable("mso-request-id", requestId)
\r
1004 requestId = execution.getVariable("mso-request-id")
\r
1006 execution.setVariable(Prefix + "requestId", requestId)
1008 String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse")
1010 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
1011 String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc")
1012 // 1. prepare delete topology via SDNC Adapter SUBFLOW call
1013 String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null)
1014 String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
1015 utils.logAudit(sndcTopologyDeleteRequesAsString)
1016 execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString)
1017 utils.log("DEBUG", Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
1018 utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled)
1021 } catch (Exception ex) {
1023 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage()
1024 logError(exceptionMessage)
1025 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1026 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1032 public void setExceptionFlag(Execution execution){
1033 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1034 execution.setVariable("prefix",Prefix)
1036 utils.log("DEBUG", " ***** Inside setExceptionFlag() of DoDeleteNetworkInstance ***** ", isDebugEnabled)
1040 execution.setVariable(Prefix + "isException", true)
1042 if (execution.getVariable("SavedWorkflowException1") != null) {
1043 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1"))
1045 execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException"))
1047 utils.log("DEBUG", Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled)
1049 } catch(Exception ex){
1050 String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage()
1051 utils.log("DEBUG", exceptionMessage, isDebugEnabled)
1052 exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
1058 // *******************************
1059 // Build Error Section
1060 // *******************************
1062 public void processJavaException(Execution execution){
1063 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
1064 execution.setVariable("prefix",Prefix)
1066 utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
1067 utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
1068 utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
1069 execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated
1070 exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
1072 }catch(Exception e){
1073 utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
1074 execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated
1075 exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method")
1077 utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled)