2 * © 2016 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
4 package org.openecomp.mso.bpmn.vcpe.scripts;
6 import org.openecomp.mso.bpmn.common.scripts.*;
7 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
8 import org.openecomp.mso.bpmn.core.RollbackData
9 import org.openecomp.mso.bpmn.core.WorkflowException
10 import org.openecomp.mso.bpmn.core.json.JsonUtils
11 import org.openecomp.mso.rest.APIResponse
13 import java.util.UUID;
14 import org.camunda.bpm.engine.delegate.BpmnError
15 import org.camunda.bpm.engine.runtime.Execution
16 import org.apache.commons.lang3.*
17 import org.springframework.web.util.UriUtils;
18 import static org.apache.commons.lang3.StringUtils.*
22 * This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process.
27 * @param - msoRequestId
28 * @param - isDEbugLogEnabled
29 * @param - disableRollback
30 * @param - failExists - O
31 * @param - serviceInstanceId
32 * @param - parentServiceInstanceId
33 * @param - allottedReourceId - O
34 * @param - allottedResourceModelInfo
35 * @param - allottedResourceRole
36 * @param - allottedResourceType
37 * @param - brgWanMacAddress
40 * @param - rollbackData (localRB->null)
41 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
42 * @param - WorkflowException - O
43 * @param - allottedResourceId
44 * @param - allottedResourceName
46 * @param - vgmuxBearerIP
50 public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
52 String Prefix="DCARTXC_"
53 ExceptionUtil exceptionUtil = new ExceptionUtil()
54 JsonUtils jsonUtil = new JsonUtils()
56 public void preProcessRequest (Execution execution) {
58 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
60 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
63 execution.setVariable("prefix", Prefix)
66 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
67 if (isBlank(sdncCallbackUrl)) {
68 msg = "URN_mso_workflow_sdncadapter_callback is null"
69 utils.log("DEBUG", msg, isDebugEnabled)
70 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
72 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
73 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
76 if (isBlank(execution.getVariable("serviceInstanceId"))){
77 msg = "Input serviceInstanceId is null"
78 utils.log("DEBUG", msg, isDebugEnabled)
79 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
81 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
82 msg = "Input parentServiceInstanceId is null"
83 utils.log("DEBUG", msg, isDebugEnabled)
84 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
86 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
87 msg = "Input allottedResourceModelInfo is null"
88 utils.log("DEBUG", msg, isDebugEnabled)
89 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
91 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
92 msg = "Input brgWanMacAddress is null"
93 utils.log("DEBUG", msg, isDebugEnabled)
94 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
96 if (isBlank(execution.getVariable("allottedResourceRole"))) {
97 msg = "Input allottedResourceRole is null"
98 utils.log("DEBUG", msg, isDebugEnabled)
99 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
101 if (isBlank(execution.getVariable("allottedResourceType"))) {
102 msg = "Input allottedResourceType is null"
103 utils.log("DEBUG", msg, isDebugEnabled)
104 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
107 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
109 } catch (Exception ex){
110 msg = "Exception in preProcessRequest " + ex.getMessage()
111 utils.log("DEBUG", msg, isDebugEnabled)
112 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
114 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
117 public void getAaiAR (Execution execution) {
119 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
120 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
122 String arType = execution.getVariable("allottedResourceType")
123 String arRole = execution.getVariable("allottedResourceRole")
125 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
126 String orchStatus = arUtils.getAROrchStatus(execution)
130 if (orchStatus != null) // AR was found
132 if ("true".equals(execution.getVariable("failExists")))
134 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
138 if ("Active".equals(orchStatus))
140 execution.setVariable("foundActiveAR", true)
142 else // blanks included
144 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
148 if (!isBlank(errorMsg)) {
149 utils.log("DEBUG", errorMsg, isDebugEnabled)
150 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
152 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
155 public void createAaiAR(Execution execution) {
157 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
158 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
161 String allottedResourceId = execution.getVariable("allottedResourceId")
162 if (isBlank(allottedResourceId))
164 allottedResourceId = UUID.randomUUID().toString()
165 execution.setVariable("allottedResourceId", allottedResourceId)
171 AaiUtil aaiUriUtil = new AaiUtil(this)
172 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
173 String siResourceLink= execution.getVariable("PSI_resourceLink")
176 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
178 if(!isBlank(siResourceLink)) {
179 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
180 String[] split = siResourceLink.split("/aai/")
181 siUri = "/aai/" + split[1]
185 msg = "Parent Service Link in AAI is null"
186 utils.log("DEBUG", msg, isDebugEnabled)
187 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
190 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
191 execution.setVariable("aaiARPath", arUrl)
192 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
194 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
196 String arType = execution.getVariable("allottedResourceType")
197 String arRole = execution.getVariable("allottedResourceRole")
198 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
199 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
200 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
201 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
202 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
204 if (modelInvariantId == null) {
205 modelInvariantId = ""
207 if (modelVersionId == null) {
210 if (modelCustomizationId == null) {
211 modelCustomizationId = ""
215 """<allotted-resource xmlns="${namespace}">
216 <id>${allottedResourceId}</id>
217 <description></description>
218 <type>${arType}</type>
219 <role>${arRole}</role>
220 <selflink></selflink>
221 <model-invariant-id>${modelInvariantId}</model-invariant-id>
222 <model-version-id>${modelVersionId}</model-version-id>
223 <model-customization-id>${modelCustomizationId}</model-customization-id>
224 <orchestration-status>PendingCreate</orchestration-status>
225 <operation-status></operation-status>
228 <related-to>service-instance</related-to>
229 <related-link>${CSI_resourceLink}</related-link>
232 </allotted-resource>""".trim()
234 execution.setVariable("AaiARPayload", payload)
235 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
237 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
238 int responseCode = response.getStatusCode()
239 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
241 String aaiResponse = response.getResponseBodyAsString()
242 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
243 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
245 //200 OK 201 CREATED 202 ACCEPTED
246 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
248 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
251 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
252 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
253 throw new BpmnError("MSOWorkflowException")
256 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
258 } catch (Exception ex) {
259 msg = "Exception in createAaiAR " + ex.getMessage()
260 utils.log("DEBUG", msg, isDebugEnabled)
261 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
264 //start rollback set up
265 RollbackData rollbackData = new RollbackData()
266 def disableRollback = execution.getVariable("disableRollback")
267 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
268 rollbackData.put(Prefix, "rollbackAAI", "true")
269 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
270 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
271 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
272 rollbackData.put(Prefix, "aaiARPath", arUrl)
273 execution.setVariable("rollbackData", rollbackData)
274 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
277 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
279 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
281 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
282 String sdncReq = null
286 String allottedResourceId = execution.getVariable("allottedResourceId")
287 String serviceInstanceId = execution.getVariable("serviceInstanceId")
288 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
289 String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId")
290 String callbackUrl = execution.getVariable("sdncCallbackUrl")
291 String requestId = execution.getVariable("msoRequestId")
293 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
295 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
296 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
297 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
298 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
299 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
300 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
302 if (modelInvariantId == null) {
303 modelInvariantId = ""
305 if (modelVersion == null) {
308 if (modelUUId == null) {
311 if (modelName == null) {
314 if (modelCustomizationId == null) {
315 modelCustomizationId = ""
319 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
320 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
321 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
322 <sdncadapter:RequestHeader>
323 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
324 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
325 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
326 <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation>
327 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
328 </sdncadapter:RequestHeader>
329 <sdncadapterworkflow:SDNCRequestData>
330 <request-information>
331 <request-id>${requestId}</request-id>
332 <request-action>CreateTunnelXConnInstance</request-action>
337 </request-information>
338 <service-information>
339 <service-id></service-id>
340 <subscription-service-type></subscription-service-type>
341 <ecomp-model-information></ecomp-model-information>
342 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
344 <global-customer-id></global-customer-id>
345 </service-information>
346 <allotted-resource-information>
347 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
348 <allotted-resource-type>tunnelxconn</allotted-resource-type>
349 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
350 <ecomp-model-information>
351 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
352 <model-uuid>${modelUUId}</model-uuid>
353 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
354 <model-version>${modelVersion}</model-version>
355 <model-name>${modelName}</model-name>
356 </ecomp-model-information>
357 </allotted-resource-information>
358 <tunnelxconn-request-input>
359 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
360 </tunnelxconn-request-input>
361 </sdncadapterworkflow:SDNCRequestData>
362 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
364 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
365 sdncReq = utils.formatXml(sdncReq)
367 } catch(Exception ex) {
368 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
369 utils.log("DEBUG", msg, isDebugEnabled)
370 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
372 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
376 public void preProcessSDNCAssign(Execution execution) {
378 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
380 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
383 String sdncRequestId = UUID.randomUUID().toString()
384 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
385 execution.setVariable("sdncAssignRequest", sdncAssignReq)
386 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
387 def sdncRequestId2 = UUID.randomUUID().toString()
388 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
389 def rollbackData = execution.getVariable("rollbackData")
390 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
391 execution.setVariable("rollbackData", rollbackData)
393 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
394 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
396 } catch (BpmnError e) {
398 } catch(Exception ex) {
399 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
400 utils.log("DEBUG", msg, isDebugEnabled)
401 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
403 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
406 public void preProcessSDNCCreate(Execution execution) {
408 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
410 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
413 String sdncRequestId = UUID.randomUUID().toString()
414 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
415 execution.setVariable("sdncCreateRequest", sdncCreateReq)
416 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
417 def sdncRequestId2 = UUID.randomUUID().toString()
418 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
419 def rollbackData = execution.getVariable("rollbackData")
420 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
421 execution.setVariable("rollbackData", rollbackData)
423 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
424 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
426 } catch (BpmnError e) {
428 } catch(Exception ex) {
429 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
430 utils.log("DEBUG", msg, isDebugEnabled)
431 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
433 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
436 public void preProcessSDNCActivate(Execution execution) {
438 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
440 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
443 String sdncRequestId = UUID.randomUUID().toString()
444 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
445 execution.setVariable("sdncActivateRequest", sdncActivateReq)
446 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
447 def sdncRequestId2 = UUID.randomUUID().toString()
448 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
449 def rollbackData = execution.getVariable("rollbackData")
450 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
451 execution.setVariable("rollbackData", rollbackData)
453 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
454 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
456 } catch (BpmnError e) {
458 } catch(Exception ex) {
459 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
460 utils.log("DEBUG", msg, isDebugEnabled)
461 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
463 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
466 public void validateSDNCResp(Execution execution, String response, String method){
468 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
469 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
473 WorkflowException workflowException = execution.getVariable("WorkflowException")
474 utils.logAudit("workflowException: " + workflowException)
476 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
477 utils.logAudit("SDNCResponse: " + response)
479 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
480 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
482 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
483 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
485 if (!"get".equals(method))
487 def rollbackData = execution.getVariable("rollbackData")
488 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
489 execution.setVariable("rollbackData", rollbackData)
493 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
494 throw new BpmnError("MSOWorkflowException")
496 } catch (BpmnError e) {
498 } catch(Exception ex) {
499 msg = "Exception in validateSDNCResp. " + ex.getMessage()
500 utils.log("DEBUG", msg, isDebugEnabled)
501 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
503 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
506 public void preProcessSDNCGet(Execution execution){
507 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
508 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
511 def callbackUrl = execution.getVariable("sdncCallbackUrl")
512 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
513 // or from "object-path" in SDNC response for assign when AR does not exist in AA
515 String serviceOperation = ""
517 if (execution.getVariable("foundActiveAR")) {
518 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
519 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
520 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
524 String response = execution.getVariable("sdncAssignResponse")
525 String data = utils.getNodeXml(response, "response-data")
526 data = data.replaceAll("<", "<")
527 data = data.replaceAll(">", ">")
528 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
529 serviceOperation = utils.getNodeText1(data, "object-path")
530 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
533 String serviceInstanceId = execution.getVariable("serviceInstanceId")
534 String sdncRequestId = UUID.randomUUID().toString()
536 String tsleep = execution.getVariable("junitSleepMs")
538 //workaround for sdnc replication issue
539 sleep(tsleep == null ? 5000 : tsleep as Long)
541 //neeed the same url as used by vfmodules
542 String SDNCGetRequest =
543 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
544 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
545 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
546 <sdncadapter:RequestHeader>
547 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
548 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
549 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
550 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
551 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
552 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
553 </sdncadapter:RequestHeader>
554 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
555 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
557 execution.setVariable("sdncGetRequest", SDNCGetRequest)
560 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
561 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
563 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
566 public void updateAaiAROrchStatus(Execution execution, String status){
567 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
568 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
569 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
570 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
571 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
572 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
575 public void generateOutputs(Execution execution)
577 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
578 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
580 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
581 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
582 String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology")
583 arData = utils.removeXmlNamespaces(arData)
585 String txca = utils.getNodeXml(arData, "tunnelxconn-assignments")
586 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
587 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
588 execution.setVariable("vni", utils.getNodeText1(ari, "vni"))
589 execution.setVariable("vgmuxBearerIp", utils.getNodeText1(ari, "vgmux_bearer_ip"))
590 execution.setVariable("vgmuxLanIP", utils.getNodeText1(ari, "vgmux_lan_ip"))
591 } catch (BpmnError e) {
592 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
593 } catch(Exception ex) {
594 String msg = "Exception in generateOutputs " + ex.getMessage()
595 utils.log("DEBUG", msg, isDebugEnabled)
597 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
601 public void preProcessRollback (Execution execution) {
602 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
603 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
606 Object workflowException = execution.getVariable("WorkflowException");
608 if (workflowException instanceof WorkflowException) {
609 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
610 execution.setVariable("prevWorkflowException", workflowException);
611 //execution.setVariable("WorkflowException", null);
613 } catch (BpmnError e) {
614 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
615 } catch(Exception ex) {
616 String msg = "Exception in preProcessRollback. " + ex.getMessage()
617 utils.log("DEBUG", msg, isDebugEnabled)
619 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
622 public void postProcessRollback (Execution execution) {
623 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
624 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
627 Object workflowException = execution.getVariable("prevWorkflowException");
628 if (workflowException instanceof WorkflowException) {
629 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
630 execution.setVariable("WorkflowException", workflowException);
632 execution.setVariable("rollbackData", null)
633 } catch (BpmnError b) {
634 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
636 } catch(Exception ex) {
637 msg = "Exception in postProcessRollback. " + ex.getMessage()
638 utils.log("DEBUG", msg, isDebugEnabled)
640 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)