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>DoCreateAllottedResourceTXC.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
56 * @param - rollbackData (localRB->null)
57 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
58 * @param - WorkflowException - O
59 * @param - allottedResourceId
60 * @param - allottedResourceName
62 * @param - vgmuxBearerIP
66 public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
68 private static final String DebugFlag = "isDebugLogEnabled"
70 String Prefix="DCARTXC_"
71 ExceptionUtil exceptionUtil = new ExceptionUtil()
72 JsonUtils jsonUtil = new JsonUtils()
74 public void preProcessRequest (Execution execution) {
76 def isDebugEnabled = execution.getVariable(DebugFlag)
78 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
81 String msoRequestId = execution.getVariable("msoRequestId")
82 utils.log("DEBUG", " msoRequestId = " + msoRequestId, isDebugEnabled)
84 execution.setVariable("prefix", Prefix)
87 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
88 if (isBlank(sdncCallbackUrl)) {
89 msg = "URN_mso_workflow_sdncadapter_callback is null"
90 utils.log("DEBUG", msg, isDebugEnabled)
91 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
93 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
94 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
96 String sdncReplDelay = execution.getVariable('URN_mso_workflow_sdnc_replication_delay')
97 if (isBlank(sdncReplDelay)) {
98 msg = "URN_mso_workflow_sdnc_replication_delay is null"
99 utils.log("DEBUG", msg, isDebugEnabled)
100 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
102 execution.setVariable("sdncReplDelay", sdncReplDelay)
103 utils.log("DEBUG","SDNC replication delay: " + sdncReplDelay, isDebugEnabled)
106 if (isBlank(execution.getVariable("serviceInstanceId"))){
107 msg = "Input serviceInstanceId is null"
108 utils.log("DEBUG", msg, isDebugEnabled)
109 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
111 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
112 msg = "Input parentServiceInstanceId is null"
113 utils.log("DEBUG", msg, isDebugEnabled)
114 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
116 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
117 msg = "Input allottedResourceModelInfo is null"
118 utils.log("DEBUG", msg, isDebugEnabled)
119 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
121 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
122 msg = "Input brgWanMacAddress is null"
123 utils.log("DEBUG", msg, isDebugEnabled)
124 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
126 if (isBlank(execution.getVariable("allottedResourceRole"))) {
127 msg = "Input allottedResourceRole is null"
128 utils.log("DEBUG", msg, isDebugEnabled)
129 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
131 if (isBlank(execution.getVariable("allottedResourceType"))) {
132 msg = "Input allottedResourceType is null"
133 utils.log("DEBUG", msg, isDebugEnabled)
134 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
137 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
139 } catch (Exception ex){
140 msg = "Exception in preProcessRequest " + ex.getMessage()
141 utils.log("DEBUG", msg, isDebugEnabled)
142 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
144 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
147 public void getAaiAR (Execution execution) {
149 def isDebugEnabled = execution.getVariable(DebugFlag)
150 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
152 String arType = execution.getVariable("allottedResourceType")
153 String arRole = execution.getVariable("allottedResourceRole")
155 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
156 String orchStatus = arUtils.getAROrchStatus(execution)
160 if (orchStatus != null) // AR was found
162 if ("true".equals(execution.getVariable("failExists")))
164 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
168 if ("Active".equals(orchStatus))
170 execution.setVariable("foundActiveAR", true)
172 else // blanks included
174 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
178 if (!isBlank(errorMsg)) {
179 utils.log("DEBUG", errorMsg, isDebugEnabled)
180 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
182 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
185 public void createAaiAR(Execution execution) {
187 def isDebugEnabled=execution.getVariable(DebugFlag)
188 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
191 String allottedResourceId = execution.getVariable("allottedResourceId")
192 if (isBlank(allottedResourceId))
194 allottedResourceId = UUID.randomUUID().toString()
195 execution.setVariable("allottedResourceId", allottedResourceId)
201 AaiUtil aaiUriUtil = new AaiUtil(this)
202 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
203 String siResourceLink= execution.getVariable("PSI_resourceLink")
206 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
208 if(!isBlank(siResourceLink)) {
209 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
210 String[] split = siResourceLink.split("/aai/")
211 siUri = "/aai/" + split[1]
215 msg = "Parent Service Link in AAI is null"
216 utils.log("DEBUG", msg, isDebugEnabled)
217 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
220 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
221 execution.setVariable("aaiARPath", arUrl)
222 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
224 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
226 String arType = execution.getVariable("allottedResourceType")
227 String arRole = execution.getVariable("allottedResourceRole")
228 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
229 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
230 utils.log("DEBUG", "arModelInfo is:\n" + arModelInfo, isDebugEnabled)
231 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
232 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
233 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
235 if (modelInvariantId == null) {
236 modelInvariantId = ""
238 if (modelVersionId == null) {
241 if (modelCustomizationId == null) {
242 modelCustomizationId = ""
246 """<allotted-resource xmlns="${namespace}">
247 <id>${allottedResourceId}</id>
248 <description></description>
249 <type>${arType}</type>
250 <role>${arRole}</role>
251 <selflink></selflink>
252 <model-invariant-id>${modelInvariantId}</model-invariant-id>
253 <model-version-id>${modelVersionId}</model-version-id>
254 <model-customization-id>${modelCustomizationId}</model-customization-id>
255 <orchestration-status>PendingCreate</orchestration-status>
256 <operation-status></operation-status>
259 <related-to>service-instance</related-to>
260 <related-link>${CSI_resourceLink}</related-link>
263 </allotted-resource>""".trim()
265 execution.setVariable("AaiARPayload", payload)
266 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
268 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
269 int responseCode = response.getStatusCode()
270 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
272 String aaiResponse = response.getResponseBodyAsString()
273 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
274 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
276 //200 OK 201 CREATED 202 ACCEPTED
277 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
279 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
282 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
283 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
284 throw new BpmnError("MSOWorkflowException")
287 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
289 } catch (Exception ex) {
290 msg = "Exception in createAaiAR " + ex.getMessage()
291 utils.log("DEBUG", msg, isDebugEnabled)
292 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
295 //start rollback set up
296 RollbackData rollbackData = new RollbackData()
297 def disableRollback = execution.getVariable("disableRollback")
298 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
299 rollbackData.put(Prefix, "rollbackAAI", "true")
300 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
301 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
302 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
303 rollbackData.put(Prefix, "aaiARPath", arUrl)
304 execution.setVariable("rollbackData", rollbackData)
305 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
308 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
310 def isDebugEnabled = execution.getVariable(DebugFlag)
312 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
313 String sdncReq = null
317 String allottedResourceId = execution.getVariable("allottedResourceId")
318 String serviceInstanceId = execution.getVariable("serviceInstanceId")
319 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
320 String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId")
321 String callbackUrl = execution.getVariable("sdncCallbackUrl")
322 String requestId = execution.getVariable("msoRequestId")
324 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
326 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
327 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
328 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
329 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
330 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
331 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
333 if (modelInvariantId == null) {
334 modelInvariantId = ""
336 if (modelVersion == null) {
339 if (modelUUId == null) {
342 if (modelName == null) {
345 if (modelCustomizationId == null) {
346 modelCustomizationId = ""
350 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
351 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
352 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
353 <sdncadapter:RequestHeader>
354 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
355 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
356 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
357 <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation>
358 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
359 </sdncadapter:RequestHeader>
360 <sdncadapterworkflow:SDNCRequestData>
361 <request-information>
362 <request-id>${requestId}</request-id>
363 <request-action>CreateTunnelXConnInstance</request-action>
368 </request-information>
369 <service-information>
370 <service-id></service-id>
371 <subscription-service-type></subscription-service-type>
372 <onap-model-information></onap-model-information>
373 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
375 <global-customer-id></global-customer-id>
376 </service-information>
377 <allotted-resource-information>
378 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
379 <allotted-resource-type>tunnelxconn</allotted-resource-type>
380 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
381 <onap-model-information>
382 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
383 <model-uuid>${modelUUId}</model-uuid>
384 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
385 <model-version>${modelVersion}</model-version>
386 <model-name>${modelName}</model-name>
387 </onap-model-information>
388 </allotted-resource-information>
389 <tunnelxconn-request-input>
390 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
391 </tunnelxconn-request-input>
392 </sdncadapterworkflow:SDNCRequestData>
393 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
395 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
396 sdncReq = utils.formatXml(sdncReq)
398 } catch(Exception ex) {
399 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
400 utils.log("DEBUG", msg, isDebugEnabled)
401 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
403 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
407 public void preProcessSDNCAssign(Execution execution) {
409 def isDebugEnabled = execution.getVariable(DebugFlag)
411 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
414 String sdncRequestId = UUID.randomUUID().toString()
415 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
416 execution.setVariable("sdncAssignRequest", sdncAssignReq)
417 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
418 def sdncRequestId2 = UUID.randomUUID().toString()
419 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
420 def rollbackData = execution.getVariable("rollbackData")
421 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
422 execution.setVariable("rollbackData", rollbackData)
424 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
425 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
427 } catch (BpmnError e) {
429 } catch(Exception ex) {
430 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
431 utils.log("DEBUG", msg, isDebugEnabled)
432 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
434 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
437 public void preProcessSDNCCreate(Execution execution) {
439 def isDebugEnabled = execution.getVariable(DebugFlag)
441 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
444 String sdncRequestId = UUID.randomUUID().toString()
445 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
446 execution.setVariable("sdncCreateRequest", sdncCreateReq)
447 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
448 def sdncRequestId2 = UUID.randomUUID().toString()
449 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
450 def rollbackData = execution.getVariable("rollbackData")
451 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
452 execution.setVariable("rollbackData", rollbackData)
454 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
455 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
457 } catch (BpmnError e) {
459 } catch(Exception ex) {
460 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
461 utils.log("DEBUG", msg, isDebugEnabled)
462 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
464 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
467 public void preProcessSDNCActivate(Execution execution) {
469 def isDebugEnabled = execution.getVariable(DebugFlag)
471 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
474 String sdncRequestId = UUID.randomUUID().toString()
475 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
476 execution.setVariable("sdncActivateRequest", sdncActivateReq)
477 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
478 def sdncRequestId2 = UUID.randomUUID().toString()
479 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
480 def rollbackData = execution.getVariable("rollbackData")
481 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
482 execution.setVariable("rollbackData", rollbackData)
484 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
485 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
487 } catch (BpmnError e) {
489 } catch(Exception ex) {
490 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
491 utils.log("DEBUG", msg, isDebugEnabled)
492 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
494 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
497 public void validateSDNCResp(Execution execution, String response, String method){
499 def isDebugLogEnabled=execution.getVariable(DebugFlag)
500 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
504 WorkflowException workflowException = execution.getVariable("WorkflowException")
505 utils.logAudit("workflowException: " + workflowException)
507 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
508 utils.logAudit("SDNCResponse: " + response)
510 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
511 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
513 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
514 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
516 if (!"get".equals(method))
518 def rollbackData = execution.getVariable("rollbackData")
519 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
520 execution.setVariable("rollbackData", rollbackData)
524 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
525 throw new BpmnError("MSOWorkflowException")
527 } catch (BpmnError e) {
529 } catch(Exception ex) {
530 msg = "Exception in validateSDNCResp. " + ex.getMessage()
531 utils.log("DEBUG", msg, isDebugLogEnabled)
532 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
534 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
537 public void preProcessSDNCGet(Execution execution){
538 def isDebugLogEnabled = execution.getVariable(DebugFlag)
539 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
542 def callbackUrl = execution.getVariable("sdncCallbackUrl")
543 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
544 // or from "object-path" in SDNC response for assign when AR does not exist in AA
546 String serviceOperation = ""
548 if (execution.getVariable("foundActiveAR")) {
549 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
550 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
551 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
555 String response = execution.getVariable("sdncAssignResponse")
556 String data = utils.getNodeXml(response, "response-data")
557 data = data.replaceAll("<", "<")
558 data = data.replaceAll(">", ">")
559 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
560 serviceOperation = utils.getNodeText1(data, "object-path")
561 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
564 String serviceInstanceId = execution.getVariable("serviceInstanceId")
565 String sdncRequestId = UUID.randomUUID().toString()
567 //neeed the same url as used by vfmodules
568 String SDNCGetRequest =
569 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
570 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
571 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
572 <sdncadapter:RequestHeader>
573 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
574 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
575 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
576 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
577 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
578 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
579 </sdncadapter:RequestHeader>
580 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
581 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
583 execution.setVariable("sdncGetRequest", SDNCGetRequest)
586 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
587 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
589 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
592 public void updateAaiAROrchStatus(Execution execution, String status){
593 def isDebugEnabled = execution.getVariable(DebugFlag)
594 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
595 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
596 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
597 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
598 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
601 public void generateOutputs(Execution execution)
603 def isDebugEnabled=execution.getVariable(DebugFlag)
604 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
606 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
607 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
608 String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology")
609 arData = utils.removeXmlNamespaces(arData)
611 String txca = utils.getNodeXml(arData, "tunnelxconn-assignments")
612 execution.setVariable("vni", utils.getNodeText1(txca, "vni"))
613 execution.setVariable("vgmuxBearerIP", utils.getNodeText1(txca, "vgmux-bearer-ip"))
614 execution.setVariable("vgmuxLanIP", utils.getNodeText1(txca, "vgmux-lan-ip"))
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)