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>DoCreateAllottedResourceBRG.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
39 * @param - vgmuxBearerIP
42 * @param - rollbackData (localRB->null)
43 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
44 * @param - WorkflowException - O
45 * @param - allottedResourceId
46 * @param - allottedResourceName
49 public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
51 String Prefix="DCARBRG_"
52 ExceptionUtil exceptionUtil = new ExceptionUtil()
53 JsonUtils jsonUtil = new JsonUtils()
55 public void preProcessRequest (Execution execution) {
57 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
59 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
62 execution.setVariable("prefix", Prefix)
65 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
66 if (isBlank(sdncCallbackUrl)) {
67 msg = "URN_mso_workflow_sdncadapter_callback is null"
68 utils.log("DEBUG", msg, isDebugEnabled)
69 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
71 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
72 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
75 if (isBlank(execution.getVariable("serviceInstanceId"))){
76 msg = "Input serviceInstanceId is null"
77 utils.log("DEBUG", msg, isDebugEnabled)
78 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
80 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
81 msg = "Input parentServiceInstanceId is null"
82 utils.log("DEBUG", msg, isDebugEnabled)
83 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
85 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
86 msg = "Input allottedResourceModelInfo is null"
87 utils.log("DEBUG", msg, isDebugEnabled)
88 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
90 if (isBlank(execution.getVariable("vni"))) {
91 msg = "Input vni is null"
92 utils.log("DEBUG", msg, isDebugEnabled)
93 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
95 if (isBlank(execution.getVariable("vgmuxBearerIP"))) {
96 msg = "Input vgmuxBearerIP is null"
97 utils.log("DEBUG", msg, isDebugEnabled)
98 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
100 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
101 msg = "Input brgWanMacAddress is null"
102 utils.log("DEBUG", msg, isDebugEnabled)
103 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
105 if (isBlank(execution.getVariable("allottedResourceRole"))) {
106 msg = "Input allottedResourceRole is null"
107 utils.log("DEBUG", msg, isDebugEnabled)
108 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
110 if (isBlank(execution.getVariable("allottedResourceType"))) {
111 msg = "Input allottedResourceType is null"
112 utils.log("DEBUG", msg, isDebugEnabled)
113 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
116 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
118 } catch (Exception ex){
119 msg = "Exception in preProcessRequest " + ex.getMessage()
120 utils.log("DEBUG", msg, isDebugEnabled)
121 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
123 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
126 public void getAaiAR (Execution execution) {
128 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
129 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
131 String arType = execution.getVariable("allottedResourceType")
132 String arRole = execution.getVariable("allottedResourceRole")
134 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
135 String orchStatus = arUtils.getAROrchStatus(execution)
139 if (orchStatus != null) // AR was found
141 if ("true".equals(execution.getVariable("failExists")))
143 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
147 if ("Active".equals(orchStatus))
149 execution.setVariable("foundActiveAR", true)
151 else // blanks included
153 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
157 if (!isBlank(errorMsg)) {
158 utils.log("DEBUG", errorMsg, isDebugEnabled)
159 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
161 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
164 public void createAaiAR(Execution execution) {
166 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
167 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
170 String allottedResourceId = execution.getVariable("allottedResourceId")
171 if (isBlank(allottedResourceId))
173 allottedResourceId = UUID.randomUUID().toString()
174 execution.setVariable("allottedResourceId", allottedResourceId)
180 AaiUtil aaiUriUtil = new AaiUtil(this)
181 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
182 String siResourceLink= execution.getVariable("PSI_resourceLink")
185 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
187 if(!isBlank(siResourceLink)) {
188 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
189 String[] split = siResourceLink.split("/aai/")
190 siUri = "/aai/" + split[1]
194 msg = "Parent Service Link in AAI is null"
195 utils.log("DEBUG", msg, isDebugEnabled)
196 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
199 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
200 execution.setVariable("aaiARPath", arUrl)
201 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
203 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
205 String arType = execution.getVariable("allottedResourceType")
206 String arRole = execution.getVariable("allottedResourceRole")
207 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
208 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
209 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
210 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
211 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
213 if (modelInvariantId == null) {
214 modelInvariantId = ""
216 if (modelVersionId == null) {
219 if (modelCustomizationId == null) {
220 modelCustomizationId = ""
224 """<allotted-resource xmlns="${namespace}">
225 <id>${allottedResourceId}</id>
226 <description></description>
227 <type>${arType}</type>
228 <role>${arRole}</role>
229 <selflink></selflink>
230 <model-invariant-id>${modelInvariantId}</model-invariant-id>
231 <model-version-id>${modelVersionId}</model-version-id>
232 <model-customization-id>${modelCustomizationId}</model-customization-id>
233 <orchestration-status>PendingCreate</orchestration-status>
234 <operation-status></operation-status>
237 <related-to>service-instance</related-to>
238 <related-link>${CSI_resourceLink}</related-link>
241 </allotted-resource>""".trim()
243 execution.setVariable("AaiARPayload", payload)
244 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
246 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
247 int responseCode = response.getStatusCode()
248 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
250 String aaiResponse = response.getResponseBodyAsString()
251 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
252 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
254 //200 OK 201 CREATED 202 ACCEPTED
255 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
257 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
260 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
261 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
262 throw new BpmnError("MSOWorkflowException")
265 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
267 } catch (Exception ex) {
268 msg = "Exception in createAaiAR " + ex.getMessage()
269 utils.log("DEBUG", msg, isDebugEnabled)
270 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
273 //start rollback set up
274 RollbackData rollbackData = new RollbackData()
275 def disableRollback = execution.getVariable("disableRollback")
276 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
277 rollbackData.put(Prefix, "rollbackAAI", "true")
278 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
279 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
280 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
281 rollbackData.put(Prefix, "aaiARPath", arUrl)
282 execution.setVariable("rollbackData", rollbackData)
283 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
286 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
288 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
290 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
291 String sdncReq = null
295 String allottedResourceId = execution.getVariable("allottedResourceId")
296 String serviceInstanceId = execution.getVariable("serviceInstanceId")
297 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
298 String callbackUrl = execution.getVariable("sdncCallbackUrl")
299 String requestId = execution.getVariable("msoRequestId")
301 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
302 String vni = execution.getVariable("vni")
303 String vgmuxBearerIP = execution.getVariable("vgmuxBearerIP")
305 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
306 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
307 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
308 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
309 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
310 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
312 if (modelInvariantId == null) {
313 modelInvariantId = ""
315 if (modelVersion == null) {
318 if (modelUUId == null) {
321 if (modelName == null) {
324 if (modelCustomizationId == null) {
325 modelCustomizationId = ""
329 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
330 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
331 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
332 <sdncadapter:RequestHeader>
333 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
334 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
335 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
336 <sdncadapter:SvcOperation>brg-topology-operation</sdncadapter:SvcOperation>
337 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
338 </sdncadapter:RequestHeader>
339 <sdncadapterworkflow:SDNCRequestData>
340 <request-information>
341 <request-id>${requestId}</request-id>
342 <request-action>CreateBRGInstance</request-action>
347 </request-information>
348 <service-information>
349 <service-id></service-id>
350 <subscription-service-type></subscription-service-type>
351 <ecomp-model-information></ecomp-model-information>
352 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
354 <global-customer-id></global-customer-id>
355 </service-information>
356 <allotted-resource-information>
357 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
358 <allotted-resource-type>brg</allotted-resource-type>
359 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
360 <ecomp-model-information>
361 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
362 <model-uuid>${modelUUId}</model-uuid>
363 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
364 <model-version>${modelVersion}</model-version>
365 <model-name>${modelName}</model-name>
366 </ecomp-model-information>
367 </allotted-resource-information>
369 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
371 <vgmux-bearer-ip>${vgmuxBearerIP}</vgmux-bearer-ip>
373 </sdncadapterworkflow:SDNCRequestData>
374 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
376 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
377 sdncReq = utils.formatXml(sdncReq)
379 } catch(Exception ex) {
380 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
381 utils.log("DEBUG", msg, isDebugEnabled)
382 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
384 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
388 public void preProcessSDNCAssign(Execution execution) {
390 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
392 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
395 String sdncRequestId = UUID.randomUUID().toString()
396 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
397 execution.setVariable("sdncAssignRequest", sdncAssignReq)
398 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
399 def sdncRequestId2 = UUID.randomUUID().toString()
400 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
401 def rollbackData = execution.getVariable("rollbackData")
402 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
403 execution.setVariable("rollbackData", rollbackData)
405 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
406 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
408 } catch (BpmnError e) {
410 } catch(Exception ex) {
411 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
412 utils.log("DEBUG", msg, isDebugEnabled)
413 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
415 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
418 public void preProcessSDNCCreate(Execution execution) {
420 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
422 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
425 String sdncRequestId = UUID.randomUUID().toString()
426 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
427 execution.setVariable("sdncCreateRequest", sdncCreateReq)
428 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
429 def sdncRequestId2 = UUID.randomUUID().toString()
430 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
431 def rollbackData = execution.getVariable("rollbackData")
432 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
433 execution.setVariable("rollbackData", rollbackData)
435 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
436 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
438 } catch (BpmnError e) {
440 } catch(Exception ex) {
441 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
442 utils.log("DEBUG", msg, isDebugEnabled)
443 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
445 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
448 public void preProcessSDNCActivate(Execution execution) {
450 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
452 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
455 String sdncRequestId = UUID.randomUUID().toString()
456 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
457 execution.setVariable("sdncActivateRequest", sdncActivateReq)
458 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
459 def sdncRequestId2 = UUID.randomUUID().toString()
460 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
461 def rollbackData = execution.getVariable("rollbackData")
462 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
463 execution.setVariable("rollbackData", rollbackData)
465 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
466 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
468 } catch (BpmnError e) {
470 } catch(Exception ex) {
471 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
472 utils.log("DEBUG", msg, isDebugEnabled)
473 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
475 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
478 public void validateSDNCResp(Execution execution, String response, String method){
480 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
481 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
485 WorkflowException workflowException = execution.getVariable("WorkflowException")
486 utils.logAudit("workflowException: " + workflowException)
488 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
489 utils.logAudit("SDNCResponse: " + response)
491 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
492 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
494 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
495 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
497 if (!"get".equals(method))
499 def rollbackData = execution.getVariable("rollbackData")
500 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
501 execution.setVariable("rollbackData", rollbackData)
505 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
506 throw new BpmnError("MSOWorkflowException")
508 } catch (BpmnError e) {
510 } catch(Exception ex) {
511 msg = "Exception in validateSDNCResp. " + ex.getMessage()
512 utils.log("DEBUG", msg, isDebugLogEnabled)
513 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
515 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
518 public void preProcessSDNCGet(Execution execution){
519 def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
520 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
523 def callbackUrl = execution.getVariable("sdncCallbackUrl")
524 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
525 // or from "object-path" in SDNC response for assign when AR does not exist in AA
527 String serviceOperation = ""
529 if (execution.getVariable("foundActiveAR")) {
530 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
531 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
532 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
536 String response = execution.getVariable("sdncAssignResponse")
537 String data = utils.getNodeXml(response, "response-data")
538 data = data.replaceAll("<", "<")
539 data = data.replaceAll(">", ">")
540 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
541 serviceOperation = utils.getNodeText1(data, "object-path")
542 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
545 String serviceInstanceId = execution.getVariable("serviceInstanceId")
546 String sdncRequestId = UUID.randomUUID().toString()
548 String tsleep = execution.getVariable("junitSleepMs")
550 //workaround for sdnc replication issue
551 sleep(tsleep == null ? 5000 : tsleep as Long)
553 //neeed the same url as used by vfmodules
554 String SDNCGetRequest =
555 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
556 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
557 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
558 <sdncadapter:RequestHeader>
559 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
560 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
561 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
562 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
563 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
564 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
565 </sdncadapter:RequestHeader>
566 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
567 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
569 execution.setVariable("sdncGetRequest", SDNCGetRequest)
572 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
573 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
575 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
578 public void updateAaiAROrchStatus(Execution execution, String status){
579 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
580 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
581 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
582 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
583 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
584 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
587 public void generateOutputs(Execution execution)
589 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
590 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
592 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
593 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
594 String arData = utils.getNodeXml(sdncGetResponse, "brg-topology")
595 arData = utils.removeXmlNamespaces(arData)
597 String brga = utils.getNodeXml(arData, "brg-assignments")
598 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
599 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
600 } catch (BpmnError e) {
601 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
602 } catch(Exception ex) {
603 String msg = "Exception in generateOutputs " + ex.getMessage()
604 utils.log("DEBUG", msg, isDebugEnabled)
606 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
610 public void preProcessRollback (Execution execution) {
611 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
612 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
615 Object workflowException = execution.getVariable("WorkflowException");
617 if (workflowException instanceof WorkflowException) {
618 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
619 execution.setVariable("prevWorkflowException", workflowException);
620 //execution.setVariable("WorkflowException", null);
622 } catch (BpmnError e) {
623 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
624 } catch(Exception ex) {
625 String msg = "Exception in preProcessRollback. " + ex.getMessage()
626 utils.log("DEBUG", msg, isDebugEnabled)
628 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
631 public void postProcessRollback (Execution execution) {
632 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
633 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
636 Object workflowException = execution.getVariable("prevWorkflowException");
637 if (workflowException instanceof WorkflowException) {
638 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
639 execution.setVariable("WorkflowException", workflowException);
641 execution.setVariable("rollbackData", null)
642 } catch (BpmnError b) {
643 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
645 } catch(Exception ex) {
646 msg = "Exception in postProcessRollback. " + ex.getMessage()
647 utils.log("DEBUG", msg, isDebugEnabled)
649 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)