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)
97 if (isBlank(execution.getVariable("serviceInstanceId"))){
98 msg = "Input serviceInstanceId is null"
99 utils.log("DEBUG", msg, isDebugEnabled)
100 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
102 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
103 msg = "Input parentServiceInstanceId is null"
104 utils.log("DEBUG", msg, isDebugEnabled)
105 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
107 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
108 msg = "Input allottedResourceModelInfo is null"
109 utils.log("DEBUG", msg, isDebugEnabled)
110 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
112 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
113 msg = "Input brgWanMacAddress is null"
114 utils.log("DEBUG", msg, isDebugEnabled)
115 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
117 if (isBlank(execution.getVariable("allottedResourceRole"))) {
118 msg = "Input allottedResourceRole is null"
119 utils.log("DEBUG", msg, isDebugEnabled)
120 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
122 if (isBlank(execution.getVariable("allottedResourceType"))) {
123 msg = "Input allottedResourceType is null"
124 utils.log("DEBUG", msg, isDebugEnabled)
125 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
128 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
130 } catch (Exception ex){
131 msg = "Exception in preProcessRequest " + ex.getMessage()
132 utils.log("DEBUG", msg, isDebugEnabled)
133 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
135 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
138 public void getAaiAR (Execution execution) {
140 def isDebugEnabled = execution.getVariable(DebugFlag)
141 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
143 String arType = execution.getVariable("allottedResourceType")
144 String arRole = execution.getVariable("allottedResourceRole")
146 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
147 String orchStatus = arUtils.getAROrchStatus(execution)
151 if (orchStatus != null) // AR was found
153 if ("true".equals(execution.getVariable("failExists")))
155 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
159 if ("Active".equals(orchStatus))
161 execution.setVariable("foundActiveAR", true)
163 else // blanks included
165 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
169 if (!isBlank(errorMsg)) {
170 utils.log("DEBUG", errorMsg, isDebugEnabled)
171 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
173 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
176 public void createAaiAR(Execution execution) {
178 def isDebugEnabled=execution.getVariable(DebugFlag)
179 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
182 String allottedResourceId = execution.getVariable("allottedResourceId")
183 if (isBlank(allottedResourceId))
185 allottedResourceId = UUID.randomUUID().toString()
186 execution.setVariable("allottedResourceId", allottedResourceId)
192 AaiUtil aaiUriUtil = new AaiUtil(this)
193 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
194 String siResourceLink= execution.getVariable("PSI_resourceLink")
197 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
199 if(!isBlank(siResourceLink)) {
200 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
201 String[] split = siResourceLink.split("/aai/")
202 siUri = "/aai/" + split[1]
206 msg = "Parent Service Link in AAI is null"
207 utils.log("DEBUG", msg, isDebugEnabled)
208 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
211 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
212 execution.setVariable("aaiARPath", arUrl)
213 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
215 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
217 String arType = execution.getVariable("allottedResourceType")
218 String arRole = execution.getVariable("allottedResourceRole")
219 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
220 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
221 utils.log("DEBUG", "arModelInfo is:\n" + arModelInfo, isDebugEnabled)
222 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
223 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
224 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
226 if (modelInvariantId == null) {
227 modelInvariantId = ""
229 if (modelVersionId == null) {
232 if (modelCustomizationId == null) {
233 modelCustomizationId = ""
237 """<allotted-resource xmlns="${namespace}">
238 <id>${allottedResourceId}</id>
239 <description></description>
240 <type>${arType}</type>
241 <role>${arRole}</role>
242 <selflink></selflink>
243 <model-invariant-id>${modelInvariantId}</model-invariant-id>
244 <model-version-id>${modelVersionId}</model-version-id>
245 <model-customization-id>${modelCustomizationId}</model-customization-id>
246 <orchestration-status>PendingCreate</orchestration-status>
247 <operation-status></operation-status>
250 <related-to>service-instance</related-to>
251 <related-link>${CSI_resourceLink}</related-link>
254 </allotted-resource>""".trim()
256 execution.setVariable("AaiARPayload", payload)
257 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
259 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
260 int responseCode = response.getStatusCode()
261 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
263 String aaiResponse = response.getResponseBodyAsString()
264 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
265 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
267 //200 OK 201 CREATED 202 ACCEPTED
268 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
270 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
273 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
274 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
275 throw new BpmnError("MSOWorkflowException")
278 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
280 } catch (Exception ex) {
281 msg = "Exception in createAaiAR " + ex.getMessage()
282 utils.log("DEBUG", msg, isDebugEnabled)
283 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
286 //start rollback set up
287 RollbackData rollbackData = new RollbackData()
288 def disableRollback = execution.getVariable("disableRollback")
289 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
290 rollbackData.put(Prefix, "rollbackAAI", "true")
291 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
292 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
293 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
294 rollbackData.put(Prefix, "aaiARPath", arUrl)
295 execution.setVariable("rollbackData", rollbackData)
296 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
299 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
301 def isDebugEnabled = execution.getVariable(DebugFlag)
303 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
304 String sdncReq = null
308 String allottedResourceId = execution.getVariable("allottedResourceId")
309 String serviceInstanceId = execution.getVariable("serviceInstanceId")
310 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
311 String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId")
312 String callbackUrl = execution.getVariable("sdncCallbackUrl")
313 String requestId = execution.getVariable("msoRequestId")
315 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
317 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
318 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
319 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
320 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
321 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
322 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
324 if (modelInvariantId == null) {
325 modelInvariantId = ""
327 if (modelVersion == null) {
330 if (modelUUId == null) {
333 if (modelName == null) {
336 if (modelCustomizationId == null) {
337 modelCustomizationId = ""
341 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
342 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
343 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
344 <sdncadapter:RequestHeader>
345 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
346 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
347 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
348 <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation>
349 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
350 </sdncadapter:RequestHeader>
351 <sdncadapterworkflow:SDNCRequestData>
352 <request-information>
353 <request-id>${requestId}</request-id>
354 <request-action>CreateTunnelXConnInstance</request-action>
359 </request-information>
360 <service-information>
361 <service-id></service-id>
362 <subscription-service-type></subscription-service-type>
363 <onap-model-information></onap-model-information>
364 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
366 <global-customer-id></global-customer-id>
367 </service-information>
368 <allotted-resource-information>
369 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
370 <allotted-resource-type>tunnelxconn</allotted-resource-type>
371 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
372 <onap-model-information>
373 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
374 <model-uuid>${modelUUId}</model-uuid>
375 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
376 <model-version>${modelVersion}</model-version>
377 <model-name>${modelName}</model-name>
378 </onap-model-information>
379 </allotted-resource-information>
380 <tunnelxconn-request-input>
381 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
382 </tunnelxconn-request-input>
383 </sdncadapterworkflow:SDNCRequestData>
384 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
386 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
387 sdncReq = utils.formatXml(sdncReq)
389 } catch(Exception ex) {
390 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
391 utils.log("DEBUG", msg, isDebugEnabled)
392 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
394 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
398 public void preProcessSDNCAssign(Execution execution) {
400 def isDebugEnabled = execution.getVariable(DebugFlag)
402 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
405 String sdncRequestId = UUID.randomUUID().toString()
406 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
407 execution.setVariable("sdncAssignRequest", sdncAssignReq)
408 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
409 def sdncRequestId2 = UUID.randomUUID().toString()
410 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
411 def rollbackData = execution.getVariable("rollbackData")
412 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
413 execution.setVariable("rollbackData", rollbackData)
415 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
416 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
418 } catch (BpmnError e) {
420 } catch(Exception ex) {
421 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
422 utils.log("DEBUG", msg, isDebugEnabled)
423 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
425 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
428 public void preProcessSDNCCreate(Execution execution) {
430 def isDebugEnabled = execution.getVariable(DebugFlag)
432 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
435 String sdncRequestId = UUID.randomUUID().toString()
436 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
437 execution.setVariable("sdncCreateRequest", sdncCreateReq)
438 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
439 def sdncRequestId2 = UUID.randomUUID().toString()
440 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
441 def rollbackData = execution.getVariable("rollbackData")
442 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
443 execution.setVariable("rollbackData", rollbackData)
445 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
446 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
448 } catch (BpmnError e) {
450 } catch(Exception ex) {
451 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
452 utils.log("DEBUG", msg, isDebugEnabled)
453 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
455 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
458 public void preProcessSDNCActivate(Execution execution) {
460 def isDebugEnabled = execution.getVariable(DebugFlag)
462 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
465 String sdncRequestId = UUID.randomUUID().toString()
466 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
467 execution.setVariable("sdncActivateRequest", sdncActivateReq)
468 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
469 def sdncRequestId2 = UUID.randomUUID().toString()
470 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
471 def rollbackData = execution.getVariable("rollbackData")
472 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
473 execution.setVariable("rollbackData", rollbackData)
475 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
476 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
478 } catch (BpmnError e) {
480 } catch(Exception ex) {
481 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
482 utils.log("DEBUG", msg, isDebugEnabled)
483 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
485 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
488 public void validateSDNCResp(Execution execution, String response, String method){
490 def isDebugLogEnabled=execution.getVariable(DebugFlag)
491 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
495 WorkflowException workflowException = execution.getVariable("WorkflowException")
496 utils.logAudit("workflowException: " + workflowException)
498 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
499 utils.logAudit("SDNCResponse: " + response)
501 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
502 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
504 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
505 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
507 if (!"get".equals(method))
509 def rollbackData = execution.getVariable("rollbackData")
510 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
511 execution.setVariable("rollbackData", rollbackData)
515 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
516 throw new BpmnError("MSOWorkflowException")
518 } catch (BpmnError e) {
520 } catch(Exception ex) {
521 msg = "Exception in validateSDNCResp. " + ex.getMessage()
522 utils.log("DEBUG", msg, isDebugLogEnabled)
523 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
525 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
528 public void preProcessSDNCGet(Execution execution){
529 def isDebugLogEnabled = execution.getVariable(DebugFlag)
530 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
533 def callbackUrl = execution.getVariable("sdncCallbackUrl")
534 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
535 // or from "object-path" in SDNC response for assign when AR does not exist in AA
537 String serviceOperation = ""
539 if (execution.getVariable("foundActiveAR")) {
540 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
541 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
542 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
546 String response = execution.getVariable("sdncAssignResponse")
547 String data = utils.getNodeXml(response, "response-data")
548 data = data.replaceAll("<", "<")
549 data = data.replaceAll(">", ">")
550 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
551 serviceOperation = utils.getNodeText1(data, "object-path")
552 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
555 String serviceInstanceId = execution.getVariable("serviceInstanceId")
556 String sdncRequestId = UUID.randomUUID().toString()
558 String tsleep = execution.getVariable("junitSleepMs")
560 //workaround for sdnc replication issue
561 sleep(tsleep == null ? 5000 : tsleep as Long)
563 //neeed the same url as used by vfmodules
564 String SDNCGetRequest =
565 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
566 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
567 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
568 <sdncadapter:RequestHeader>
569 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
570 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
571 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
572 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
573 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
574 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
575 </sdncadapter:RequestHeader>
576 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
577 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
579 execution.setVariable("sdncGetRequest", SDNCGetRequest)
582 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
583 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
585 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
588 public void updateAaiAROrchStatus(Execution execution, String status){
589 def isDebugEnabled = execution.getVariable(DebugFlag)
590 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
591 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
592 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
593 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
594 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
597 public void generateOutputs(Execution execution)
599 def isDebugEnabled=execution.getVariable(DebugFlag)
600 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
602 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
603 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
604 String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology")
605 arData = utils.removeXmlNamespaces(arData)
607 String txca = utils.getNodeXml(arData, "tunnelxconn-assignments")
608 execution.setVariable("vni", utils.getNodeText1(txca, "vni"))
609 execution.setVariable("vgmuxBearerIP", utils.getNodeText1(txca, "vgmux_bearer_ip"))
610 execution.setVariable("vgmuxLanIP", utils.getNodeText1(txca, "vgmux_lan_ip"))
612 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
613 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
614 } catch (BpmnError e) {
615 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
616 } catch(Exception ex) {
617 String msg = "Exception in generateOutputs " + ex.getMessage()
618 utils.log("DEBUG", msg, isDebugEnabled)
620 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
624 public void preProcessRollback (Execution execution) {
625 def isDebugEnabled=execution.getVariable(DebugFlag)
626 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
629 Object workflowException = execution.getVariable("WorkflowException");
631 if (workflowException instanceof WorkflowException) {
632 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
633 execution.setVariable("prevWorkflowException", workflowException);
634 //execution.setVariable("WorkflowException", null);
636 } catch (BpmnError e) {
637 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
638 } catch(Exception ex) {
639 String msg = "Exception in preProcessRollback. " + ex.getMessage()
640 utils.log("DEBUG", msg, isDebugEnabled)
642 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
645 public void postProcessRollback (Execution execution) {
646 def isDebugEnabled=execution.getVariable(DebugFlag)
647 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
650 Object workflowException = execution.getVariable("prevWorkflowException");
651 if (workflowException instanceof WorkflowException) {
652 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
653 execution.setVariable("WorkflowException", workflowException);
655 execution.setVariable("rollbackData", null)
656 } catch (BpmnError b) {
657 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
659 } catch(Exception ex) {
660 msg = "Exception in postProcessRollback. " + ex.getMessage()
661 utils.log("DEBUG", msg, isDebugEnabled)
663 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)