2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.openecomp.mso.bpmn.vcpe.scripts;
22 import org.openecomp.mso.bpmn.common.scripts.*;
23 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
24 import org.openecomp.mso.bpmn.core.RollbackData
25 import org.openecomp.mso.bpmn.core.WorkflowException
26 import org.openecomp.mso.bpmn.core.json.JsonUtils
27 import org.openecomp.mso.rest.APIResponse
29 import java.util.UUID;
30 import org.camunda.bpm.engine.delegate.BpmnError
31 import org.camunda.bpm.engine.runtime.Execution
32 import org.apache.commons.lang3.*
33 import org.springframework.web.util.UriUtils;
34 import static org.apache.commons.lang3.StringUtils.*
38 * This groovy class supports the <class>DoCreateAllottedResourceBRG.bpmn</class> process.
43 * @param - msoRequestId
44 * @param - isDEbugLogEnabled
45 * @param - disableRollback
46 * @param - failExists - O
47 * @param - serviceInstanceId
48 * @param - parentServiceInstanceId
49 * @param - allottedReourceId - O
50 * @param - allottedResourceModelInfo
51 * @param - allottedResourceRole
52 * @param - allottedResourceType
53 * @param - brgWanMacAddress
55 * @param - vgmuxBearerIP
58 * @param - rollbackData (localRB->null)
59 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
60 * @param - WorkflowException - O
61 * @param - allottedResourceId
62 * @param - allottedResourceName
65 public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
67 private static final String DebugFlag = "isDebugLogEnabled"
69 String Prefix="DCARBRG_"
70 ExceptionUtil exceptionUtil = new ExceptionUtil()
71 JsonUtils jsonUtil = new JsonUtils()
73 public void preProcessRequest (Execution execution) {
75 def isDebugEnabled = execution.getVariable(DebugFlag)
77 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
80 execution.setVariable("prefix", Prefix)
83 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
84 if (isBlank(sdncCallbackUrl)) {
85 msg = "URN_mso_workflow_sdncadapter_callback is null"
86 utils.log("DEBUG", msg, isDebugEnabled)
87 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
89 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
90 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
93 if (isBlank(execution.getVariable("serviceInstanceId"))){
94 msg = "Input serviceInstanceId is null"
95 utils.log("DEBUG", msg, isDebugEnabled)
96 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
98 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
99 msg = "Input parentServiceInstanceId is null"
100 utils.log("DEBUG", msg, isDebugEnabled)
101 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
103 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
104 msg = "Input allottedResourceModelInfo is null"
105 utils.log("DEBUG", msg, isDebugEnabled)
106 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
108 if (isBlank(execution.getVariable("vni"))) {
109 msg = "Input vni is null"
110 utils.log("DEBUG", msg, isDebugEnabled)
111 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
113 if (isBlank(execution.getVariable("vgmuxBearerIP"))) {
114 msg = "Input vgmuxBearerIP is null"
115 utils.log("DEBUG", msg, isDebugEnabled)
116 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
118 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
119 msg = "Input brgWanMacAddress is null"
120 utils.log("DEBUG", msg, isDebugEnabled)
121 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
123 if (isBlank(execution.getVariable("allottedResourceRole"))) {
124 msg = "Input allottedResourceRole is null"
125 utils.log("DEBUG", msg, isDebugEnabled)
126 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
128 if (isBlank(execution.getVariable("allottedResourceType"))) {
129 msg = "Input allottedResourceType is null"
130 utils.log("DEBUG", msg, isDebugEnabled)
131 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
134 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
136 } catch (Exception ex){
137 msg = "Exception in preProcessRequest " + ex.getMessage()
138 utils.log("DEBUG", msg, isDebugEnabled)
139 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
141 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
144 public void getAaiAR (Execution execution) {
146 def isDebugEnabled = execution.getVariable(DebugFlag)
147 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
149 String arType = execution.getVariable("allottedResourceType")
150 String arRole = execution.getVariable("allottedResourceRole")
152 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
153 String orchStatus = arUtils.getAROrchStatus(execution)
157 if (orchStatus != null) // AR was found
159 if ("true".equals(execution.getVariable("failExists")))
161 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
165 if ("Active".equals(orchStatus))
167 execution.setVariable("foundActiveAR", true)
169 else // blanks included
171 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
175 if (!isBlank(errorMsg)) {
176 utils.log("DEBUG", errorMsg, isDebugEnabled)
177 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
179 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
182 public void createAaiAR(Execution execution) {
184 def isDebugEnabled=execution.getVariable(DebugFlag)
185 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
188 String allottedResourceId = execution.getVariable("allottedResourceId")
189 if (isBlank(allottedResourceId))
191 allottedResourceId = UUID.randomUUID().toString()
192 execution.setVariable("allottedResourceId", allottedResourceId)
198 AaiUtil aaiUriUtil = new AaiUtil(this)
199 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
200 String siResourceLink= execution.getVariable("PSI_resourceLink")
203 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
205 if(!isBlank(siResourceLink)) {
206 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
207 String[] split = siResourceLink.split("/aai/")
208 siUri = "/aai/" + split[1]
212 msg = "Parent Service Link in AAI is null"
213 utils.log("DEBUG", msg, isDebugEnabled)
214 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
217 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
218 execution.setVariable("aaiARPath", arUrl)
219 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
221 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
223 String arType = execution.getVariable("allottedResourceType")
224 String arRole = execution.getVariable("allottedResourceRole")
225 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
226 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
227 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
228 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
229 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
231 if (modelInvariantId == null) {
232 modelInvariantId = ""
234 if (modelVersionId == null) {
237 if (modelCustomizationId == null) {
238 modelCustomizationId = ""
242 """<allotted-resource xmlns="${namespace}">
243 <id>${allottedResourceId}</id>
244 <description></description>
245 <type>${arType}</type>
246 <role>${arRole}</role>
247 <selflink></selflink>
248 <model-invariant-id>${modelInvariantId}</model-invariant-id>
249 <model-version-id>${modelVersionId}</model-version-id>
250 <model-customization-id>${modelCustomizationId}</model-customization-id>
251 <orchestration-status>PendingCreate</orchestration-status>
252 <operation-status></operation-status>
255 <related-to>service-instance</related-to>
256 <related-link>${CSI_resourceLink}</related-link>
259 </allotted-resource>""".trim()
261 execution.setVariable("AaiARPayload", payload)
262 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
264 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
265 int responseCode = response.getStatusCode()
266 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
268 String aaiResponse = response.getResponseBodyAsString()
269 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
270 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
272 //200 OK 201 CREATED 202 ACCEPTED
273 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
275 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
278 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
279 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
280 throw new BpmnError("MSOWorkflowException")
283 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
285 } catch (Exception ex) {
286 msg = "Exception in createAaiAR " + ex.getMessage()
287 utils.log("DEBUG", msg, isDebugEnabled)
288 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
291 //start rollback set up
292 RollbackData rollbackData = new RollbackData()
293 def disableRollback = execution.getVariable("disableRollback")
294 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
295 rollbackData.put(Prefix, "rollbackAAI", "true")
296 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
297 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
298 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
299 rollbackData.put(Prefix, "aaiARPath", arUrl)
300 execution.setVariable("rollbackData", rollbackData)
301 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
304 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
306 def isDebugEnabled = execution.getVariable(DebugFlag)
308 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
309 String sdncReq = null
313 String allottedResourceId = execution.getVariable("allottedResourceId")
314 String serviceInstanceId = execution.getVariable("serviceInstanceId")
315 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
316 String callbackUrl = execution.getVariable("sdncCallbackUrl")
317 String requestId = execution.getVariable("msoRequestId")
319 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
320 String vni = execution.getVariable("vni")
321 String vgmuxBearerIP = execution.getVariable("vgmuxBearerIP")
323 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
324 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
325 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
326 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
327 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
328 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
330 if (modelInvariantId == null) {
331 modelInvariantId = ""
333 if (modelVersion == null) {
336 if (modelUUId == null) {
339 if (modelName == null) {
342 if (modelCustomizationId == null) {
343 modelCustomizationId = ""
347 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
348 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
349 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
350 <sdncadapter:RequestHeader>
351 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
352 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
353 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
354 <sdncadapter:SvcOperation>brg-topology-operation</sdncadapter:SvcOperation>
355 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
356 </sdncadapter:RequestHeader>
357 <sdncadapterworkflow:SDNCRequestData>
358 <request-information>
359 <request-id>${requestId}</request-id>
360 <request-action>CreateBRGInstance</request-action>
365 </request-information>
366 <service-information>
367 <service-id></service-id>
368 <subscription-service-type></subscription-service-type>
369 <ecomp-model-information></ecomp-model-information>
370 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
372 <global-customer-id></global-customer-id>
373 </service-information>
374 <allotted-resource-information>
375 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
376 <allotted-resource-type>brg</allotted-resource-type>
377 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
378 <ecomp-model-information>
379 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
380 <model-uuid>${modelUUId}</model-uuid>
381 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
382 <model-version>${modelVersion}</model-version>
383 <model-name>${modelName}</model-name>
384 </ecomp-model-information>
385 </allotted-resource-information>
387 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
389 <vgmux-bearer-ip>${vgmuxBearerIP}</vgmux-bearer-ip>
391 </sdncadapterworkflow:SDNCRequestData>
392 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
394 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
395 sdncReq = utils.formatXml(sdncReq)
397 } catch(Exception ex) {
398 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
399 utils.log("DEBUG", msg, isDebugEnabled)
400 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
402 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
406 public void preProcessSDNCAssign(Execution execution) {
408 def isDebugEnabled = execution.getVariable(DebugFlag)
410 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
413 String sdncRequestId = UUID.randomUUID().toString()
414 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
415 execution.setVariable("sdncAssignRequest", sdncAssignReq)
416 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
417 def sdncRequestId2 = UUID.randomUUID().toString()
418 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
419 def rollbackData = execution.getVariable("rollbackData")
420 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
421 execution.setVariable("rollbackData", rollbackData)
423 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
424 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
426 } catch (BpmnError e) {
428 } catch(Exception ex) {
429 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
430 utils.log("DEBUG", msg, isDebugEnabled)
431 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
433 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
436 public void preProcessSDNCCreate(Execution execution) {
438 def isDebugEnabled = execution.getVariable(DebugFlag)
440 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
443 String sdncRequestId = UUID.randomUUID().toString()
444 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
445 execution.setVariable("sdncCreateRequest", sdncCreateReq)
446 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
447 def sdncRequestId2 = UUID.randomUUID().toString()
448 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
449 def rollbackData = execution.getVariable("rollbackData")
450 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
451 execution.setVariable("rollbackData", rollbackData)
453 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
454 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
456 } catch (BpmnError e) {
458 } catch(Exception ex) {
459 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
460 utils.log("DEBUG", msg, isDebugEnabled)
461 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
463 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
466 public void preProcessSDNCActivate(Execution execution) {
468 def isDebugEnabled = execution.getVariable(DebugFlag)
470 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
473 String sdncRequestId = UUID.randomUUID().toString()
474 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
475 execution.setVariable("sdncActivateRequest", sdncActivateReq)
476 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
477 def sdncRequestId2 = UUID.randomUUID().toString()
478 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
479 def rollbackData = execution.getVariable("rollbackData")
480 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
481 execution.setVariable("rollbackData", rollbackData)
483 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
484 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
486 } catch (BpmnError e) {
488 } catch(Exception ex) {
489 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
490 utils.log("DEBUG", msg, isDebugEnabled)
491 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
493 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
496 public void validateSDNCResp(Execution execution, String response, String method){
498 def isDebugLogEnabled=execution.getVariable(DebugFlag)
499 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
503 WorkflowException workflowException = execution.getVariable("WorkflowException")
504 utils.logAudit("workflowException: " + workflowException)
506 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
507 utils.logAudit("SDNCResponse: " + response)
509 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
510 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
512 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
513 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
515 if (!"get".equals(method))
517 def rollbackData = execution.getVariable("rollbackData")
518 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
519 execution.setVariable("rollbackData", rollbackData)
523 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
524 throw new BpmnError("MSOWorkflowException")
526 } catch (BpmnError e) {
528 } catch(Exception ex) {
529 msg = "Exception in validateSDNCResp. " + ex.getMessage()
530 utils.log("DEBUG", msg, isDebugLogEnabled)
531 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
533 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
536 public void preProcessSDNCGet(Execution execution){
537 def isDebugLogEnabled = execution.getVariable(DebugFlag)
538 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
541 def callbackUrl = execution.getVariable("sdncCallbackUrl")
542 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
543 // or from "object-path" in SDNC response for assign when AR does not exist in AA
545 String serviceOperation = ""
547 if (execution.getVariable("foundActiveAR")) {
548 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
549 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
550 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
554 String response = execution.getVariable("sdncAssignResponse")
555 String data = utils.getNodeXml(response, "response-data")
556 data = data.replaceAll("<", "<")
557 data = data.replaceAll(">", ">")
558 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
559 serviceOperation = utils.getNodeText1(data, "object-path")
560 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
563 String serviceInstanceId = execution.getVariable("serviceInstanceId")
564 String sdncRequestId = UUID.randomUUID().toString()
566 String tsleep = execution.getVariable("junitSleepMs")
568 //workaround for sdnc replication issue
569 sleep(tsleep == null ? 5000 : tsleep as Long)
571 //neeed the same url as used by vfmodules
572 String SDNCGetRequest =
573 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
574 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
575 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
576 <sdncadapter:RequestHeader>
577 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
578 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
579 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
580 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
581 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
582 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
583 </sdncadapter:RequestHeader>
584 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
585 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
587 execution.setVariable("sdncGetRequest", SDNCGetRequest)
590 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
591 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
593 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
596 public void updateAaiAROrchStatus(Execution execution, String status){
597 def isDebugEnabled = execution.getVariable(DebugFlag)
598 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
599 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
600 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
601 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
602 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
605 public void generateOutputs(Execution execution)
607 def isDebugEnabled=execution.getVariable(DebugFlag)
608 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
610 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
611 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
612 String arData = utils.getNodeXml(sdncGetResponse, "brg-topology")
613 arData = utils.removeXmlNamespaces(arData)
615 String brga = utils.getNodeXml(arData, "brg-assignments")
616 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
617 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
618 } catch (BpmnError e) {
619 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
620 } catch(Exception ex) {
621 String msg = "Exception in generateOutputs " + ex.getMessage()
622 utils.log("DEBUG", msg, isDebugEnabled)
624 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
628 public void preProcessRollback (Execution execution) {
629 def isDebugEnabled=execution.getVariable(DebugFlag)
630 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
633 Object workflowException = execution.getVariable("WorkflowException");
635 if (workflowException instanceof WorkflowException) {
636 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
637 execution.setVariable("prevWorkflowException", workflowException);
638 //execution.setVariable("WorkflowException", null);
640 } catch (BpmnError e) {
641 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
642 } catch(Exception ex) {
643 String msg = "Exception in preProcessRollback. " + ex.getMessage()
644 utils.log("DEBUG", msg, isDebugEnabled)
646 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
649 public void postProcessRollback (Execution execution) {
650 def isDebugEnabled=execution.getVariable(DebugFlag)
651 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
654 Object workflowException = execution.getVariable("prevWorkflowException");
655 if (workflowException instanceof WorkflowException) {
656 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
657 execution.setVariable("WorkflowException", workflowException);
659 execution.setVariable("rollbackData", null)
660 } catch (BpmnError b) {
661 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
663 } catch(Exception ex) {
664 msg = "Exception in postProcessRollback. " + ex.getMessage()
665 utils.log("DEBUG", msg, isDebugEnabled)
667 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)