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 if ((msoRequestId == null) || ("testRequestId".equals(msoRequestId)) || ("testRequestId123".equals(msoRequestId)))
86 utils.log("DEBUG"," ***** NOT sleeping 30 seconds for Junit *****", isDebugEnabled)
90 utils.log("DEBUG"," ***** sleeping 30 seconds for AAI replication *****", isDebugEnabled)
92 utils.log("DEBUG"," ***** sleep over *****", isDebugEnabled)
95 execution.setVariable("prefix", Prefix)
98 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
99 if (isBlank(sdncCallbackUrl)) {
100 msg = "URN_mso_workflow_sdncadapter_callback is null"
101 utils.log("DEBUG", msg, isDebugEnabled)
102 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
104 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
105 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
108 if (isBlank(execution.getVariable("serviceInstanceId"))){
109 msg = "Input serviceInstanceId is null"
110 utils.log("DEBUG", msg, isDebugEnabled)
111 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
113 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
114 msg = "Input parentServiceInstanceId is null"
115 utils.log("DEBUG", msg, isDebugEnabled)
116 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
118 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
119 msg = "Input allottedResourceModelInfo is null"
120 utils.log("DEBUG", msg, isDebugEnabled)
121 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
123 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
124 msg = "Input brgWanMacAddress is null"
125 utils.log("DEBUG", msg, isDebugEnabled)
126 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
128 if (isBlank(execution.getVariable("allottedResourceRole"))) {
129 msg = "Input allottedResourceRole is null"
130 utils.log("DEBUG", msg, isDebugEnabled)
131 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
133 if (isBlank(execution.getVariable("allottedResourceType"))) {
134 msg = "Input allottedResourceType is null"
135 utils.log("DEBUG", msg, isDebugEnabled)
136 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
139 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
141 } catch (Exception ex){
142 msg = "Exception in preProcessRequest " + ex.getMessage()
143 utils.log("DEBUG", msg, isDebugEnabled)
144 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
146 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
149 public void getAaiAR (Execution execution) {
151 def isDebugEnabled = execution.getVariable(DebugFlag)
152 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
154 String arType = execution.getVariable("allottedResourceType")
155 String arRole = execution.getVariable("allottedResourceRole")
157 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
158 String orchStatus = arUtils.getAROrchStatus(execution)
162 if (orchStatus != null) // AR was found
164 if ("true".equals(execution.getVariable("failExists")))
166 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
170 if ("Active".equals(orchStatus))
172 execution.setVariable("foundActiveAR", true)
174 else // blanks included
176 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
180 if (!isBlank(errorMsg)) {
181 utils.log("DEBUG", errorMsg, isDebugEnabled)
182 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
184 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
187 public void createAaiAR(Execution execution) {
189 def isDebugEnabled=execution.getVariable(DebugFlag)
190 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
193 String allottedResourceId = execution.getVariable("allottedResourceId")
194 if (isBlank(allottedResourceId))
196 allottedResourceId = UUID.randomUUID().toString()
197 execution.setVariable("allottedResourceId", allottedResourceId)
203 AaiUtil aaiUriUtil = new AaiUtil(this)
204 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
205 String siResourceLink= execution.getVariable("PSI_resourceLink")
208 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
210 if(!isBlank(siResourceLink)) {
211 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
212 String[] split = siResourceLink.split("/aai/")
213 siUri = "/aai/" + split[1]
217 msg = "Parent Service Link in AAI is null"
218 utils.log("DEBUG", msg, isDebugEnabled)
219 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
222 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
223 execution.setVariable("aaiARPath", arUrl)
224 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
226 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
228 String arType = execution.getVariable("allottedResourceType")
229 String arRole = execution.getVariable("allottedResourceRole")
230 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
231 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
232 utils.log("DEBUG", "arModelInfo is:\n" + arModelInfo, isDebugEnabled)
233 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
234 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
235 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
237 if (modelInvariantId == null) {
238 modelInvariantId = ""
240 if (modelVersionId == null) {
243 if (modelCustomizationId == null) {
244 modelCustomizationId = ""
248 """<allotted-resource xmlns="${namespace}">
249 <id>${allottedResourceId}</id>
250 <description></description>
251 <type>${arType}</type>
252 <role>${arRole}</role>
253 <selflink></selflink>
254 <model-invariant-id>${modelInvariantId}</model-invariant-id>
255 <model-version-id>${modelVersionId}</model-version-id>
256 <model-customization-id>${modelCustomizationId}</model-customization-id>
257 <orchestration-status>PendingCreate</orchestration-status>
258 <operation-status></operation-status>
261 <related-to>service-instance</related-to>
262 <related-link>${CSI_resourceLink}</related-link>
265 </allotted-resource>""".trim()
267 execution.setVariable("AaiARPayload", payload)
268 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
270 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
271 int responseCode = response.getStatusCode()
272 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
274 String aaiResponse = response.getResponseBodyAsString()
275 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
276 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
278 //200 OK 201 CREATED 202 ACCEPTED
279 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
281 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
284 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
285 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
286 throw new BpmnError("MSOWorkflowException")
289 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
291 } catch (Exception ex) {
292 msg = "Exception in createAaiAR " + ex.getMessage()
293 utils.log("DEBUG", msg, isDebugEnabled)
294 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
297 //start rollback set up
298 RollbackData rollbackData = new RollbackData()
299 def disableRollback = execution.getVariable("disableRollback")
300 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
301 rollbackData.put(Prefix, "rollbackAAI", "true")
302 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
303 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
304 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
305 rollbackData.put(Prefix, "aaiARPath", arUrl)
306 execution.setVariable("rollbackData", rollbackData)
307 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
310 public String buildSDNCRequest(Execution execution, String action, String sdncRequestId) {
312 def isDebugEnabled = execution.getVariable(DebugFlag)
314 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
315 String sdncReq = null
319 String allottedResourceId = execution.getVariable("allottedResourceId")
320 String serviceInstanceId = execution.getVariable("serviceInstanceId")
321 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
322 String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId")
323 String callbackUrl = execution.getVariable("sdncCallbackUrl")
324 String requestId = execution.getVariable("msoRequestId")
326 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
328 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
329 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
330 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
331 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
332 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
333 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
335 if (modelInvariantId == null) {
336 modelInvariantId = ""
338 if (modelVersion == null) {
341 if (modelUUId == null) {
344 if (modelName == null) {
347 if (modelCustomizationId == null) {
348 modelCustomizationId = ""
352 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
353 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
354 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
355 <sdncadapter:RequestHeader>
356 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
357 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
358 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
359 <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation>
360 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
361 </sdncadapter:RequestHeader>
362 <sdncadapterworkflow:SDNCRequestData>
363 <request-information>
364 <request-id>${requestId}</request-id>
365 <request-action>CreateTunnelXConnInstance</request-action>
370 </request-information>
371 <service-information>
372 <service-id></service-id>
373 <subscription-service-type></subscription-service-type>
374 <onap-model-information></onap-model-information>
375 <service-instance-id>${parentServiceInstanceId}</service-instance-id>
377 <global-customer-id></global-customer-id>
378 </service-information>
379 <allotted-resource-information>
380 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
381 <allotted-resource-type>tunnelxconn</allotted-resource-type>
382 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
383 <onap-model-information>
384 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
385 <model-uuid>${modelUUId}</model-uuid>
386 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
387 <model-version>${modelVersion}</model-version>
388 <model-name>${modelName}</model-name>
389 </onap-model-information>
390 </allotted-resource-information>
391 <tunnelxconn-request-input>
392 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
393 </tunnelxconn-request-input>
394 </sdncadapterworkflow:SDNCRequestData>
395 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
397 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
398 sdncReq = utils.formatXml(sdncReq)
400 } catch(Exception ex) {
401 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
402 utils.log("DEBUG", msg, isDebugEnabled)
403 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
405 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
409 public void preProcessSDNCAssign(Execution execution) {
411 def isDebugEnabled = execution.getVariable(DebugFlag)
413 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
416 String sdncRequestId = UUID.randomUUID().toString()
417 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
418 execution.setVariable("sdncAssignRequest", sdncAssignReq)
419 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
420 def sdncRequestId2 = UUID.randomUUID().toString()
421 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
422 def rollbackData = execution.getVariable("rollbackData")
423 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
424 execution.setVariable("rollbackData", rollbackData)
426 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
427 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
429 } catch (BpmnError e) {
431 } catch(Exception ex) {
432 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
433 utils.log("DEBUG", msg, isDebugEnabled)
434 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
436 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
439 public void preProcessSDNCCreate(Execution execution) {
441 def isDebugEnabled = execution.getVariable(DebugFlag)
443 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
446 String sdncRequestId = UUID.randomUUID().toString()
447 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
448 execution.setVariable("sdncCreateRequest", sdncCreateReq)
449 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
450 def sdncRequestId2 = UUID.randomUUID().toString()
451 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
452 def rollbackData = execution.getVariable("rollbackData")
453 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
454 execution.setVariable("rollbackData", rollbackData)
456 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
457 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
459 } catch (BpmnError e) {
461 } catch(Exception ex) {
462 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
463 utils.log("DEBUG", msg, isDebugEnabled)
464 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
466 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
469 public void preProcessSDNCActivate(Execution execution) {
471 def isDebugEnabled = execution.getVariable(DebugFlag)
473 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
476 String sdncRequestId = UUID.randomUUID().toString()
477 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
478 execution.setVariable("sdncActivateRequest", sdncActivateReq)
479 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
480 def sdncRequestId2 = UUID.randomUUID().toString()
481 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
482 def rollbackData = execution.getVariable("rollbackData")
483 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
484 execution.setVariable("rollbackData", rollbackData)
486 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
487 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
489 } catch (BpmnError e) {
491 } catch(Exception ex) {
492 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
493 utils.log("DEBUG", msg, isDebugEnabled)
494 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
496 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
499 public void validateSDNCResp(Execution execution, String response, String method){
501 def isDebugLogEnabled=execution.getVariable(DebugFlag)
502 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
506 WorkflowException workflowException = execution.getVariable("WorkflowException")
507 utils.logAudit("workflowException: " + workflowException)
509 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
510 utils.logAudit("SDNCResponse: " + response)
512 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
513 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
515 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
516 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
518 if (!"get".equals(method))
520 def rollbackData = execution.getVariable("rollbackData")
521 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
522 execution.setVariable("rollbackData", rollbackData)
526 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
527 throw new BpmnError("MSOWorkflowException")
529 } catch (BpmnError e) {
531 } catch(Exception ex) {
532 msg = "Exception in validateSDNCResp. " + ex.getMessage()
533 utils.log("DEBUG", msg, isDebugLogEnabled)
534 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
536 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
539 public void preProcessSDNCGet(Execution execution){
540 def isDebugLogEnabled = execution.getVariable(DebugFlag)
541 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
544 def callbackUrl = execution.getVariable("sdncCallbackUrl")
545 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
546 // or from "object-path" in SDNC response for assign when AR does not exist in AA
548 String serviceOperation = ""
550 if (execution.getVariable("foundActiveAR")) {
551 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
552 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
553 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
557 String response = execution.getVariable("sdncAssignResponse")
558 String data = utils.getNodeXml(response, "response-data")
559 data = data.replaceAll("<", "<")
560 data = data.replaceAll(">", ">")
561 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
562 serviceOperation = utils.getNodeText1(data, "object-path")
563 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
566 String serviceInstanceId = execution.getVariable("serviceInstanceId")
567 String sdncRequestId = UUID.randomUUID().toString()
569 String tsleep = execution.getVariable("junitSleepMs")
571 //workaround for sdnc replication issue
572 sleep(tsleep == null ? 5000 : tsleep as Long)
574 //neeed the same url as used by vfmodules
575 String SDNCGetRequest =
576 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
577 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
578 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
579 <sdncadapter:RequestHeader>
580 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
581 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
582 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
583 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
584 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
585 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
586 </sdncadapter:RequestHeader>
587 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
588 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
590 execution.setVariable("sdncGetRequest", SDNCGetRequest)
593 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
594 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
596 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
599 public void updateAaiAROrchStatus(Execution execution, String status){
600 def isDebugEnabled = execution.getVariable(DebugFlag)
601 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
602 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
603 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
604 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
605 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
608 public void generateOutputs(Execution execution)
610 def isDebugEnabled=execution.getVariable(DebugFlag)
611 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
613 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
614 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
615 String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology")
616 arData = utils.removeXmlNamespaces(arData)
618 String txca = utils.getNodeXml(arData, "tunnelxconn-assignments")
619 execution.setVariable("vni", utils.getNodeText1(txca, "vni"))
620 execution.setVariable("vgmuxBearerIP", utils.getNodeText1(txca, "vgmux_bearer_ip"))
621 execution.setVariable("vgmuxLanIP", utils.getNodeText1(txca, "vgmux_lan_ip"))
623 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
624 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
625 } catch (BpmnError e) {
626 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
627 } catch(Exception ex) {
628 String msg = "Exception in generateOutputs " + ex.getMessage()
629 utils.log("DEBUG", msg, isDebugEnabled)
631 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
635 public void preProcessRollback (Execution execution) {
636 def isDebugEnabled=execution.getVariable(DebugFlag)
637 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
640 Object workflowException = execution.getVariable("WorkflowException");
642 if (workflowException instanceof WorkflowException) {
643 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
644 execution.setVariable("prevWorkflowException", workflowException);
645 //execution.setVariable("WorkflowException", null);
647 } catch (BpmnError e) {
648 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
649 } catch(Exception ex) {
650 String msg = "Exception in preProcessRollback. " + ex.getMessage()
651 utils.log("DEBUG", msg, isDebugEnabled)
653 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
656 public void postProcessRollback (Execution execution) {
657 def isDebugEnabled=execution.getVariable(DebugFlag)
658 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
661 Object workflowException = execution.getVariable("prevWorkflowException");
662 if (workflowException instanceof WorkflowException) {
663 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
664 execution.setVariable("WorkflowException", workflowException);
666 execution.setVariable("rollbackData", null)
667 } catch (BpmnError b) {
668 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
670 } catch(Exception ex) {
671 msg = "Exception in postProcessRollback. " + ex.getMessage()
672 utils.log("DEBUG", msg, isDebugEnabled)
674 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)