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)
92 String sdncReplDelay = execution.getVariable('URN_mso_workflow_sdnc_replication_delay')
93 if (isBlank(sdncReplDelay)) {
94 msg = "URN_mso_workflow_sdnc_replication_delay is null"
95 utils.log("DEBUG", msg, isDebugEnabled)
96 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
98 execution.setVariable("sdncReplDelay", sdncReplDelay)
99 utils.log("DEBUG","SDNC replication delay: " + sdncReplDelay, isDebugEnabled)
102 if (isBlank(execution.getVariable("serviceInstanceId"))){
103 msg = "Input serviceInstanceId is null"
104 utils.log("DEBUG", msg, isDebugEnabled)
105 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
107 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
108 msg = "Input parentServiceInstanceId is null"
109 utils.log("DEBUG", msg, isDebugEnabled)
110 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
112 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
113 msg = "Input allottedResourceModelInfo is null"
114 utils.log("DEBUG", msg, isDebugEnabled)
115 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
117 if (isBlank(execution.getVariable("vni"))) {
118 msg = "Input vni is null"
119 utils.log("DEBUG", msg, isDebugEnabled)
120 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
122 if (isBlank(execution.getVariable("vgmuxBearerIP"))) {
123 msg = "Input vgmuxBearerIP is null"
124 utils.log("DEBUG", msg, isDebugEnabled)
125 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
127 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
128 msg = "Input brgWanMacAddress is null"
129 utils.log("DEBUG", msg, isDebugEnabled)
130 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
132 if (isBlank(execution.getVariable("allottedResourceRole"))) {
133 msg = "Input allottedResourceRole is null"
134 utils.log("DEBUG", msg, isDebugEnabled)
135 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
137 if (isBlank(execution.getVariable("allottedResourceType"))) {
138 msg = "Input allottedResourceType is null"
139 utils.log("DEBUG", msg, isDebugEnabled)
140 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
143 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
145 } catch (Exception ex){
146 msg = "Exception in preProcessRequest " + ex.getMessage()
147 utils.log("DEBUG", msg, isDebugEnabled)
148 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
150 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
153 public void getAaiAR (Execution execution) {
155 def isDebugEnabled = execution.getVariable(DebugFlag)
156 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
158 String arType = execution.getVariable("allottedResourceType")
159 String arRole = execution.getVariable("allottedResourceRole")
161 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
162 String orchStatus = arUtils.getAROrchStatus(execution)
166 if (orchStatus != null) // AR was found
168 if ("true".equals(execution.getVariable("failExists")))
170 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
174 if ("Active".equals(orchStatus))
176 execution.setVariable("foundActiveAR", true)
178 else // blanks included
180 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
184 if (!isBlank(errorMsg)) {
185 utils.log("DEBUG", errorMsg, isDebugEnabled)
186 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
188 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
191 public void createAaiAR(Execution execution) {
193 def isDebugEnabled=execution.getVariable(DebugFlag)
194 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
197 String allottedResourceId = execution.getVariable("allottedResourceId")
198 if (isBlank(allottedResourceId))
200 allottedResourceId = UUID.randomUUID().toString()
201 execution.setVariable("allottedResourceId", allottedResourceId)
207 AaiUtil aaiUriUtil = new AaiUtil(this)
208 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
209 String siResourceLink= execution.getVariable("PSI_resourceLink")
212 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
214 if(!isBlank(siResourceLink)) {
215 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
216 String[] split = siResourceLink.split("/aai/")
217 siUri = "/aai/" + split[1]
221 msg = "Parent Service Link in AAI is null"
222 utils.log("DEBUG", msg, isDebugEnabled)
223 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
226 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
227 execution.setVariable("aaiARPath", arUrl)
228 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
230 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
232 String arType = execution.getVariable("allottedResourceType")
233 String arRole = execution.getVariable("allottedResourceRole")
234 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
235 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
236 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
237 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
238 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
240 if (modelInvariantId == null) {
241 modelInvariantId = ""
243 if (modelVersionId == null) {
246 if (modelCustomizationId == null) {
247 modelCustomizationId = ""
251 """<allotted-resource xmlns="${namespace}">
252 <id>${allottedResourceId}</id>
253 <description></description>
254 <type>${arType}</type>
255 <role>${arRole}</role>
256 <selflink></selflink>
257 <model-invariant-id>${modelInvariantId}</model-invariant-id>
258 <model-version-id>${modelVersionId}</model-version-id>
259 <model-customization-id>${modelCustomizationId}</model-customization-id>
260 <orchestration-status>PendingCreate</orchestration-status>
261 <operation-status></operation-status>
264 <related-to>service-instance</related-to>
265 <related-link>${CSI_resourceLink}</related-link>
268 </allotted-resource>""".trim()
270 execution.setVariable("AaiARPayload", payload)
271 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
273 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
274 int responseCode = response.getStatusCode()
275 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
277 String aaiResponse = response.getResponseBodyAsString()
278 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
279 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
281 //200 OK 201 CREATED 202 ACCEPTED
282 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
284 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
287 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
288 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
289 throw new BpmnError("MSOWorkflowException")
292 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
294 } catch (Exception ex) {
295 msg = "Exception in createAaiAR " + ex.getMessage()
296 utils.log("DEBUG", msg, isDebugEnabled)
297 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
300 //start rollback set up
301 RollbackData rollbackData = new RollbackData()
302 def disableRollback = execution.getVariable("disableRollback")
303 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
304 rollbackData.put(Prefix, "rollbackAAI", "true")
305 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
306 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
307 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
308 rollbackData.put(Prefix, "aaiARPath", arUrl)
309 execution.setVariable("rollbackData", rollbackData)
310 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
313 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
315 def isDebugEnabled = execution.getVariable(DebugFlag)
317 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
318 String sdncReq = null
322 String allottedResourceId = execution.getVariable("allottedResourceId")
323 String serviceInstanceId = execution.getVariable("serviceInstanceId")
324 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
325 String callbackUrl = execution.getVariable("sdncCallbackUrl")
326 String requestId = execution.getVariable("msoRequestId")
328 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
329 String vni = execution.getVariable("vni")
330 String vgmuxBearerIP = execution.getVariable("vgmuxBearerIP")
332 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
333 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
334 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
335 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
336 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
337 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
339 if (modelInvariantId == null) {
340 modelInvariantId = ""
342 if (modelVersion == null) {
345 if (modelUUId == null) {
348 if (modelName == null) {
351 if (modelCustomizationId == null) {
352 modelCustomizationId = ""
356 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
357 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
358 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
359 <sdncadapter:RequestHeader>
360 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
361 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
362 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
363 <sdncadapter:SvcOperation>brg-topology-operation</sdncadapter:SvcOperation>
364 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
365 </sdncadapter:RequestHeader>
366 <sdncadapterworkflow:SDNCRequestData>
367 <request-information>
368 <request-id>${requestId}</request-id>
369 <request-action>CreateBRGInstance</request-action>
374 </request-information>
375 <service-information>
376 <service-id></service-id>
377 <subscription-service-type></subscription-service-type>
378 <onap-model-information></onap-model-information>
379 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
381 <global-customer-id></global-customer-id>
382 </service-information>
383 <allotted-resource-information>
384 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
385 <allotted-resource-type>brg</allotted-resource-type>
386 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
387 <onap-model-information>
388 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
389 <model-uuid>${modelUUId}</model-uuid>
390 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
391 <model-version>${modelVersion}</model-version>
392 <model-name>${modelName}</model-name>
393 </onap-model-information>
394 </allotted-resource-information>
396 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
398 <vgmux-bearer-ip>${vgmuxBearerIP}</vgmux-bearer-ip>
400 </sdncadapterworkflow:SDNCRequestData>
401 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
403 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
404 sdncReq = utils.formatXml(sdncReq)
406 } catch(Exception ex) {
407 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
408 utils.log("DEBUG", msg, isDebugEnabled)
409 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
411 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
415 public void preProcessSDNCAssign(Execution execution) {
417 def isDebugEnabled = execution.getVariable(DebugFlag)
419 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
422 String sdncRequestId = UUID.randomUUID().toString()
423 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
424 execution.setVariable("sdncAssignRequest", sdncAssignReq)
425 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
426 def sdncRequestId2 = UUID.randomUUID().toString()
427 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
428 def rollbackData = execution.getVariable("rollbackData")
429 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
430 execution.setVariable("rollbackData", rollbackData)
432 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
433 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
435 } catch (BpmnError e) {
437 } catch(Exception ex) {
438 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
439 utils.log("DEBUG", msg, isDebugEnabled)
440 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
442 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
445 public void preProcessSDNCCreate(Execution execution) {
447 def isDebugEnabled = execution.getVariable(DebugFlag)
449 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
452 String sdncRequestId = UUID.randomUUID().toString()
453 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
454 execution.setVariable("sdncCreateRequest", sdncCreateReq)
455 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
456 def sdncRequestId2 = UUID.randomUUID().toString()
457 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
458 def rollbackData = execution.getVariable("rollbackData")
459 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
460 execution.setVariable("rollbackData", rollbackData)
462 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
463 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
465 } catch (BpmnError e) {
467 } catch(Exception ex) {
468 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
469 utils.log("DEBUG", msg, isDebugEnabled)
470 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
472 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
475 public void preProcessSDNCActivate(Execution execution) {
477 def isDebugEnabled = execution.getVariable(DebugFlag)
479 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
482 String sdncRequestId = UUID.randomUUID().toString()
483 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
484 execution.setVariable("sdncActivateRequest", sdncActivateReq)
485 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
486 def sdncRequestId2 = UUID.randomUUID().toString()
487 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
488 def rollbackData = execution.getVariable("rollbackData")
489 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
490 execution.setVariable("rollbackData", rollbackData)
492 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
493 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
495 } catch (BpmnError e) {
497 } catch(Exception ex) {
498 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
499 utils.log("DEBUG", msg, isDebugEnabled)
500 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
502 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
505 public void validateSDNCResp(Execution execution, String response, String method){
507 def isDebugLogEnabled=execution.getVariable(DebugFlag)
508 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
512 WorkflowException workflowException = execution.getVariable("WorkflowException")
513 utils.logAudit("workflowException: " + workflowException)
515 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
516 utils.logAudit("SDNCResponse: " + response)
518 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
519 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
521 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
522 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
524 if (!"get".equals(method))
526 def rollbackData = execution.getVariable("rollbackData")
527 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
528 execution.setVariable("rollbackData", rollbackData)
532 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
533 throw new BpmnError("MSOWorkflowException")
535 } catch (BpmnError e) {
537 } catch(Exception ex) {
538 msg = "Exception in validateSDNCResp. " + ex.getMessage()
539 utils.log("DEBUG", msg, isDebugLogEnabled)
540 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
542 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
545 public void preProcessSDNCGet(Execution execution){
546 def isDebugLogEnabled = execution.getVariable(DebugFlag)
547 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
550 def callbackUrl = execution.getVariable("sdncCallbackUrl")
551 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
552 // or from "object-path" in SDNC response for assign when AR does not exist in AA
554 String serviceOperation = ""
556 if (execution.getVariable("foundActiveAR")) {
557 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
558 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
559 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
563 String response = execution.getVariable("sdncAssignResponse")
564 String data = utils.getNodeXml(response, "response-data")
565 data = data.replaceAll("<", "<")
566 data = data.replaceAll(">", ">")
567 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
568 serviceOperation = utils.getNodeText1(data, "object-path")
569 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
572 String serviceInstanceId = execution.getVariable("serviceInstanceId")
573 String sdncRequestId = UUID.randomUUID().toString()
575 //neeed the same url as used by vfmodules
576 String SDNCGetRequest =
577 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
578 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
579 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
580 <sdncadapter:RequestHeader>
581 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
582 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
583 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
584 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
585 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
586 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
587 </sdncadapter:RequestHeader>
588 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
589 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
591 execution.setVariable("sdncGetRequest", SDNCGetRequest)
594 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
595 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
597 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
600 public void updateAaiAROrchStatus(Execution execution, String status){
601 def isDebugEnabled = execution.getVariable(DebugFlag)
602 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
603 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
604 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
605 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
606 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
609 public void generateOutputs(Execution execution)
611 def isDebugEnabled=execution.getVariable(DebugFlag)
612 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
614 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
615 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
616 String arData = utils.getNodeXml(sdncGetResponse, "brg-topology")
617 arData = utils.removeXmlNamespaces(arData)
619 String brga = utils.getNodeXml(arData, "brg-assignments")
620 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
621 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
622 } catch (BpmnError e) {
623 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
624 } catch(Exception ex) {
625 String msg = "Exception in generateOutputs " + ex.getMessage()
626 utils.log("DEBUG", msg, isDebugEnabled)
628 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
632 public void preProcessRollback (Execution execution) {
633 def isDebugEnabled=execution.getVariable(DebugFlag)
634 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
637 Object workflowException = execution.getVariable("WorkflowException");
639 if (workflowException instanceof WorkflowException) {
640 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
641 execution.setVariable("prevWorkflowException", workflowException);
642 //execution.setVariable("WorkflowException", null);
644 } catch (BpmnError e) {
645 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
646 } catch(Exception ex) {
647 String msg = "Exception in preProcessRollback. " + ex.getMessage()
648 utils.log("DEBUG", msg, isDebugEnabled)
650 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
653 public void postProcessRollback (Execution execution) {
654 def isDebugEnabled=execution.getVariable(DebugFlag)
655 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
658 Object workflowException = execution.getVariable("prevWorkflowException");
659 if (workflowException instanceof WorkflowException) {
660 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
661 execution.setVariable("WorkflowException", workflowException);
663 execution.setVariable("rollbackData", null)
664 } catch (BpmnError b) {
665 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
667 } catch(Exception ex) {
668 msg = "Exception in postProcessRollback. " + ex.getMessage()
669 utils.log("DEBUG", msg, isDebugEnabled)
671 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)