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 - globalCustomerId - O
49 * @param - subscriptionServiceType - O
50 * @param - parentServiceInstanceId
51 * @param - allottedReourceId - O
52 * @param - allottedResourceModelInfo
53 * @param - allottedResourceRole
54 * @param - allottedResourceType
55 * @param - brgWanMacAddress
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
64 * @param - vgmuxBearerIP
68 public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
70 private static final String DebugFlag = "isDebugLogEnabled"
72 String Prefix="DCARTXC_"
73 ExceptionUtil exceptionUtil = new ExceptionUtil()
74 JsonUtils jsonUtil = new JsonUtils()
76 public void preProcessRequest (Execution execution) {
78 def isDebugEnabled = execution.getVariable(DebugFlag)
80 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
83 String msoRequestId = execution.getVariable("msoRequestId")
84 utils.log("DEBUG", " msoRequestId = " + msoRequestId, isDebugEnabled)
86 execution.setVariable("prefix", Prefix)
89 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
90 if (isBlank(sdncCallbackUrl)) {
91 msg = "URN_mso_workflow_sdncadapter_callback is null"
92 utils.log("DEBUG", msg, isDebugEnabled)
93 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
95 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
96 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
98 String sdncReplDelay = execution.getVariable('URN_mso_workflow_sdnc_replication_delay')
99 if (isBlank(sdncReplDelay)) {
100 msg = "URN_mso_workflow_sdnc_replication_delay is null"
101 utils.log("DEBUG", msg, isDebugEnabled)
102 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
104 execution.setVariable("sdncReplDelay", sdncReplDelay)
105 utils.log("DEBUG","SDNC replication delay: " + sdncReplDelay, 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 globalCustomerId = execution.getVariable("globalCustomerId")
322 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
323 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
324 String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId")
325 String callbackUrl = execution.getVariable("sdncCallbackUrl")
326 String requestId = execution.getVariable("msoRequestId")
328 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
330 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
331 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
332 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
333 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
334 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
335 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
337 if (modelInvariantId == null) {
338 modelInvariantId = ""
340 if (modelVersion == null) {
343 if (modelUUId == null) {
346 if (modelName == null) {
349 if (modelCustomizationId == null) {
350 modelCustomizationId = ""
354 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
355 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
356 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
357 <sdncadapter:RequestHeader>
358 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
359 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
360 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
361 <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation>
362 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
363 </sdncadapter:RequestHeader>
364 <sdncadapterworkflow:SDNCRequestData>
365 <request-information>
366 <request-id>${requestId}</request-id>
367 <request-action>CreateTunnelXConnInstance</request-action>
372 </request-information>
373 <service-information>
374 <service-id></service-id>
375 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
376 <onap-model-information></onap-model-information>
377 <service-instance-id>${serviceInstanceId}</service-instance-id>
379 <global-customer-id>${globalCustomerId}</global-customer-id>
380 </service-information>
381 <allotted-resource-information>
382 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
383 <allotted-resource-type>tunnelxconn</allotted-resource-type>
384 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
385 <onap-model-information>
386 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
387 <model-uuid>${modelUUId}</model-uuid>
388 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
389 <model-version>${modelVersion}</model-version>
390 <model-name>${modelName}</model-name>
391 </onap-model-information>
392 </allotted-resource-information>
393 <tunnelxconn-request-input>
394 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
395 </tunnelxconn-request-input>
396 </sdncadapterworkflow:SDNCRequestData>
397 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
399 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
400 sdncReq = utils.formatXml(sdncReq)
402 } catch(Exception ex) {
403 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
404 utils.log("DEBUG", msg, isDebugEnabled)
405 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
407 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
411 public void preProcessSDNCAssign(Execution execution) {
413 def isDebugEnabled = execution.getVariable(DebugFlag)
415 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
418 String sdncRequestId = UUID.randomUUID().toString()
419 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
420 execution.setVariable("sdncAssignRequest", sdncAssignReq)
421 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
422 def sdncRequestId2 = UUID.randomUUID().toString()
423 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
424 def rollbackData = execution.getVariable("rollbackData")
425 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
426 execution.setVariable("rollbackData", rollbackData)
428 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
429 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
431 } catch (BpmnError e) {
433 } catch(Exception ex) {
434 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
435 utils.log("DEBUG", msg, isDebugEnabled)
436 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
438 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
441 public void preProcessSDNCCreate(Execution execution) {
443 def isDebugEnabled = execution.getVariable(DebugFlag)
445 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
448 String sdncRequestId = UUID.randomUUID().toString()
449 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
450 execution.setVariable("sdncCreateRequest", sdncCreateReq)
451 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
452 def sdncRequestId2 = UUID.randomUUID().toString()
453 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
454 def rollbackData = execution.getVariable("rollbackData")
455 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
456 execution.setVariable("rollbackData", rollbackData)
458 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
459 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
461 } catch (BpmnError e) {
463 } catch(Exception ex) {
464 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
465 utils.log("DEBUG", msg, isDebugEnabled)
466 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
468 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
471 public void preProcessSDNCActivate(Execution execution) {
473 def isDebugEnabled = execution.getVariable(DebugFlag)
475 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
478 String sdncRequestId = UUID.randomUUID().toString()
479 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
480 execution.setVariable("sdncActivateRequest", sdncActivateReq)
481 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
482 def sdncRequestId2 = UUID.randomUUID().toString()
483 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
484 def rollbackData = execution.getVariable("rollbackData")
485 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
486 execution.setVariable("rollbackData", rollbackData)
488 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
489 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
491 } catch (BpmnError e) {
493 } catch(Exception ex) {
494 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
495 utils.log("DEBUG", msg, isDebugEnabled)
496 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
498 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
501 public void validateSDNCResp(Execution execution, String response, String method){
503 def isDebugLogEnabled=execution.getVariable(DebugFlag)
504 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
508 WorkflowException workflowException = execution.getVariable("WorkflowException")
509 utils.logAudit("workflowException: " + workflowException)
511 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
512 utils.logAudit("SDNCResponse: " + response)
514 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
515 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
517 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
518 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
520 if (!"get".equals(method))
522 def rollbackData = execution.getVariable("rollbackData")
523 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
524 execution.setVariable("rollbackData", rollbackData)
528 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
529 throw new BpmnError("MSOWorkflowException")
531 } catch (BpmnError e) {
533 } catch(Exception ex) {
534 msg = "Exception in validateSDNCResp. " + ex.getMessage()
535 utils.log("DEBUG", msg, isDebugLogEnabled)
536 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
538 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
541 public void preProcessSDNCGet(Execution execution){
542 def isDebugLogEnabled = execution.getVariable(DebugFlag)
543 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
546 def callbackUrl = execution.getVariable("sdncCallbackUrl")
547 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
548 // or from "object-path" in SDNC response for assign when AR does not exist in AA
550 String serviceOperation = ""
552 if (execution.getVariable("foundActiveAR")) {
553 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
554 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
555 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
559 String response = execution.getVariable("sdncAssignResponse")
560 String data = utils.getNodeXml(response, "response-data")
561 data = data.replaceAll("<", "<")
562 data = data.replaceAll(">", ">")
563 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
564 serviceOperation = utils.getNodeText1(data, "object-path")
565 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
568 String serviceInstanceId = execution.getVariable("serviceInstanceId")
569 String sdncRequestId = UUID.randomUUID().toString()
571 //neeed the same url as used by vfmodules
572 String SDNCGetRequest =
573 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
574 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
575 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
576 <sdncadapter:RequestHeader>
577 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
578 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
579 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
580 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
581 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
582 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
583 </sdncadapter:RequestHeader>
584 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
585 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
587 execution.setVariable("sdncGetRequest", SDNCGetRequest)
590 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
591 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
593 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
596 public void updateAaiAROrchStatus(Execution execution, String status){
597 def isDebugEnabled = execution.getVariable(DebugFlag)
598 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
599 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
600 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
601 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
602 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
605 public void generateOutputs(Execution execution)
607 def isDebugEnabled=execution.getVariable(DebugFlag)
608 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
610 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
611 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
612 String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology")
613 arData = utils.removeXmlNamespaces(arData)
615 String txca = utils.getNodeXml(arData, "tunnelxconn-assignments")
616 execution.setVariable("vni", utils.getNodeText1(txca, "vni"))
617 execution.setVariable("vgmuxBearerIP", utils.getNodeText1(txca, "vgmux-bearer-ip"))
618 execution.setVariable("vgmuxLanIP", utils.getNodeText1(txca, "vgmux-lan-ip"))
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)