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.delegate.DelegateExecution
32 import org.apache.commons.lang3.*
33 import org.springframework.web.util.UriUtils;
34 import static org.apache.commons.lang3.StringUtils.*
38 * This groovy class supports the <class>DoCreateAllottedResourceBRG.bpmn</class> process.
43 * @param - msoRequestId
44 * @param - isDEbugLogEnabled
45 * @param - disableRollback
46 * @param - failExists - O
47 * @param - serviceInstanceId
48 * @param - 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
57 * @param - vgmuxBearerIP
60 * @param - rollbackData (localRB->null)
61 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
62 * @param - WorkflowException - O
63 * @param - allottedResourceId
64 * @param - allottedResourceName
67 public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
69 private static final String DebugFlag = "isDebugLogEnabled"
71 String Prefix="DCARBRG_"
72 ExceptionUtil exceptionUtil = new ExceptionUtil()
73 JsonUtils jsonUtil = new JsonUtils()
75 public void preProcessRequest (DelegateExecution execution) {
77 def isDebugEnabled = execution.getVariable(DebugFlag)
79 utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
82 execution.setVariable("prefix", Prefix)
85 String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
86 if (isBlank(sdncCallbackUrl)) {
87 msg = "URN_mso_workflow_sdncadapter_callback is null"
88 utils.log("DEBUG", msg, isDebugEnabled)
89 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
91 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
92 utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
94 String sdncReplDelay = execution.getVariable('URN_mso_workflow_sdnc_replication_delay')
95 if (isBlank(sdncReplDelay)) {
96 msg = "URN_mso_workflow_sdnc_replication_delay is null"
97 utils.log("DEBUG", msg, isDebugEnabled)
98 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
100 execution.setVariable("sdncReplDelay", sdncReplDelay)
101 utils.log("DEBUG","SDNC replication delay: " + sdncReplDelay, isDebugEnabled)
104 if (isBlank(execution.getVariable("serviceInstanceId"))){
105 msg = "Input serviceInstanceId is null"
106 utils.log("DEBUG", msg, isDebugEnabled)
107 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
109 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
110 msg = "Input parentServiceInstanceId is null"
111 utils.log("DEBUG", msg, isDebugEnabled)
112 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
114 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
115 msg = "Input allottedResourceModelInfo is null"
116 utils.log("DEBUG", msg, isDebugEnabled)
117 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
119 if (isBlank(execution.getVariable("vni"))) {
120 msg = "Input vni is null"
121 utils.log("DEBUG", msg, isDebugEnabled)
122 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
124 if (isBlank(execution.getVariable("vgmuxBearerIP"))) {
125 msg = "Input vgmuxBearerIP is null"
126 utils.log("DEBUG", msg, isDebugEnabled)
127 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
129 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
130 msg = "Input brgWanMacAddress is null"
131 utils.log("DEBUG", msg, isDebugEnabled)
132 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
134 if (isBlank(execution.getVariable("allottedResourceRole"))) {
135 msg = "Input allottedResourceRole is null"
136 utils.log("DEBUG", msg, isDebugEnabled)
137 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
139 if (isBlank(execution.getVariable("allottedResourceType"))) {
140 msg = "Input allottedResourceType is null"
141 utils.log("DEBUG", msg, isDebugEnabled)
142 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
145 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
147 } catch (Exception ex){
148 msg = "Exception in preProcessRequest " + ex.getMessage()
149 utils.log("DEBUG", msg, isDebugEnabled)
150 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
152 utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
155 public void getAaiAR (DelegateExecution execution) {
157 def isDebugEnabled = execution.getVariable(DebugFlag)
158 utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled)
160 String arType = execution.getVariable("allottedResourceType")
161 String arRole = execution.getVariable("allottedResourceRole")
163 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
164 String orchStatus = arUtils.getAROrchStatus(execution)
168 if (orchStatus != null) // AR was found
170 if ("true".equals(execution.getVariable("failExists")))
172 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
176 if ("Active".equals(orchStatus))
178 execution.setVariable("foundActiveAR", true)
180 else // blanks included
182 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
186 if (!isBlank(errorMsg)) {
187 utils.log("DEBUG", errorMsg, isDebugEnabled)
188 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
190 utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled)
193 public void createAaiAR(DelegateExecution execution) {
195 def isDebugEnabled=execution.getVariable(DebugFlag)
196 utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled)
199 String allottedResourceId = execution.getVariable("allottedResourceId")
200 if (isBlank(allottedResourceId))
202 allottedResourceId = UUID.randomUUID().toString()
203 execution.setVariable("allottedResourceId", allottedResourceId)
209 AaiUtil aaiUriUtil = new AaiUtil(this)
210 String aaiEndpoint = execution.getVariable("URN_aai_endpoint")
211 String siResourceLink= execution.getVariable("PSI_resourceLink")
214 utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled)
216 if(!isBlank(siResourceLink)) {
217 utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled)
218 String[] split = siResourceLink.split("/aai/")
219 siUri = "/aai/" + split[1]
223 msg = "Parent Service Link in AAI is null"
224 utils.log("DEBUG", msg, isDebugEnabled)
225 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
228 arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8")
229 execution.setVariable("aaiARPath", arUrl)
230 utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled)
232 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
234 String arType = execution.getVariable("allottedResourceType")
235 String arRole = execution.getVariable("allottedResourceRole")
236 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
237 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
238 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
239 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
240 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
242 if (modelInvariantId == null) {
243 modelInvariantId = ""
245 if (modelVersionId == null) {
248 if (modelCustomizationId == null) {
249 modelCustomizationId = ""
253 """<allotted-resource xmlns="${namespace}">
254 <id>${allottedResourceId}</id>
255 <description></description>
256 <type>${arType}</type>
257 <role>${arRole}</role>
258 <selflink></selflink>
259 <model-invariant-id>${modelInvariantId}</model-invariant-id>
260 <model-version-id>${modelVersionId}</model-version-id>
261 <model-customization-id>${modelCustomizationId}</model-customization-id>
262 <orchestration-status>PendingCreate</orchestration-status>
263 <operation-status></operation-status>
266 <related-to>service-instance</related-to>
267 <related-link>${CSI_resourceLink}</related-link>
270 </allotted-resource>""".trim()
272 execution.setVariable("AaiARPayload", payload)
273 utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled)
275 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
276 int responseCode = response.getStatusCode()
277 utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled)
279 String aaiResponse = response.getResponseBodyAsString()
280 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
281 utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled)
283 //200 OK 201 CREATED 202 ACCEPTED
284 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
286 utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled)
289 utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled)
290 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
291 throw new BpmnError("MSOWorkflowException")
294 utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
296 } catch (Exception ex) {
297 msg = "Exception in createAaiAR " + ex.getMessage()
298 utils.log("DEBUG", msg, isDebugEnabled)
299 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
302 //start rollback set up
303 RollbackData rollbackData = new RollbackData()
304 def disableRollback = execution.getVariable("disableRollback")
305 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
306 rollbackData.put(Prefix, "rollbackAAI", "true")
307 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
308 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
309 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
310 rollbackData.put(Prefix, "aaiARPath", arUrl)
311 execution.setVariable("rollbackData", rollbackData)
312 utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled)
315 public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) {
317 def isDebugEnabled = execution.getVariable(DebugFlag)
319 utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled)
320 String sdncReq = null
324 String allottedResourceId = execution.getVariable("allottedResourceId")
325 String serviceInstanceId = execution.getVariable("serviceInstanceId")
326 String globalCustomerId = execution.getVariable("globalCustomerId")
327 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
328 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
329 String callbackUrl = execution.getVariable("sdncCallbackUrl")
330 String requestId = execution.getVariable("msoRequestId")
332 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
333 String vni = execution.getVariable("vni")
334 String vgmuxBearerIP = execution.getVariable("vgmuxBearerIP")
336 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
337 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
338 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
339 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
340 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
341 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
343 if (modelInvariantId == null) {
344 modelInvariantId = ""
346 if (modelVersion == null) {
349 if (modelUUId == null) {
352 if (modelName == null) {
355 if (modelCustomizationId == null) {
356 modelCustomizationId = ""
360 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
361 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
362 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
363 <sdncadapter:RequestHeader>
364 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
365 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
366 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
367 <sdncadapter:SvcOperation>brg-topology-operation</sdncadapter:SvcOperation>
368 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
369 </sdncadapter:RequestHeader>
370 <sdncadapterworkflow:SDNCRequestData>
371 <request-information>
372 <request-id>${requestId}</request-id>
373 <request-action>CreateBRGInstance</request-action>
378 </request-information>
379 <service-information>
380 <service-id></service-id>
381 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
382 <onap-model-information></onap-model-information>
383 <service-instance-id>${serviceInstanceId}</service-instance-id>
385 <global-customer-id>${globalCustomerId}</global-customer-id>
386 </service-information>
387 <allotted-resource-information>
388 <allotted-resource-id>${allottedResourceId}</allotted-resource-id>
389 <allotted-resource-type>brg</allotted-resource-type>
390 <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id>
391 <onap-model-information>
392 <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
393 <model-uuid>${modelUUId}</model-uuid>
394 <model-customization-uuid>${modelCustomizationId}</model-customization-uuid>
395 <model-version>${modelVersion}</model-version>
396 <model-name>${modelName}</model-name>
397 </onap-model-information>
398 </allotted-resource-information>
400 <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address>
402 <vgmux-bearer-ip>${vgmuxBearerIP}</vgmux-bearer-ip>
404 </sdncadapterworkflow:SDNCRequestData>
405 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
407 utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled)
408 sdncReq = utils.formatXml(sdncReq)
410 } catch(Exception ex) {
411 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
412 utils.log("DEBUG", msg, isDebugEnabled)
413 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
415 utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled)
419 public void preProcessSDNCAssign(DelegateExecution execution) {
421 def isDebugEnabled = execution.getVariable(DebugFlag)
423 utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled)
426 String sdncRequestId = UUID.randomUUID().toString()
427 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
428 execution.setVariable("sdncAssignRequest", sdncAssignReq)
429 utils.logAudit("sdncAssignRequest: " + sdncAssignReq)
430 def sdncRequestId2 = UUID.randomUUID().toString()
431 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
432 def rollbackData = execution.getVariable("rollbackData")
433 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
434 execution.setVariable("rollbackData", rollbackData)
436 utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled)
437 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
439 } catch (BpmnError e) {
441 } catch(Exception ex) {
442 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
443 utils.log("DEBUG", msg, isDebugEnabled)
444 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
446 utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled)
449 public void preProcessSDNCCreate(DelegateExecution execution) {
451 def isDebugEnabled = execution.getVariable(DebugFlag)
453 utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled)
456 String sdncRequestId = UUID.randomUUID().toString()
457 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
458 execution.setVariable("sdncCreateRequest", sdncCreateReq)
459 utils.logAudit("sdncCreateReq: " + sdncCreateReq)
460 def sdncRequestId2 = UUID.randomUUID().toString()
461 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
462 def rollbackData = execution.getVariable("rollbackData")
463 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
464 execution.setVariable("rollbackData", rollbackData)
466 utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled)
467 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
469 } catch (BpmnError e) {
471 } catch(Exception ex) {
472 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
473 utils.log("DEBUG", msg, isDebugEnabled)
474 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
476 utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled)
479 public void preProcessSDNCActivate(DelegateExecution execution) {
481 def isDebugEnabled = execution.getVariable(DebugFlag)
483 utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled)
486 String sdncRequestId = UUID.randomUUID().toString()
487 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
488 execution.setVariable("sdncActivateRequest", sdncActivateReq)
489 utils.logAudit("sdncActivateReq: " + sdncActivateReq)
490 def sdncRequestId2 = UUID.randomUUID().toString()
491 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
492 def rollbackData = execution.getVariable("rollbackData")
493 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
494 execution.setVariable("rollbackData", rollbackData)
496 utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled)
497 utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled)
499 } catch (BpmnError e) {
501 } catch(Exception ex) {
502 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
503 utils.log("DEBUG", msg, isDebugEnabled)
504 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
506 utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled)
509 public void validateSDNCResp(DelegateExecution execution, String response, String method){
511 def isDebugLogEnabled=execution.getVariable(DebugFlag)
512 utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled)
516 WorkflowException workflowException = execution.getVariable("WorkflowException")
517 utils.logAudit("workflowException: " + workflowException)
519 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
520 utils.logAudit("SDNCResponse: " + response)
522 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
523 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
525 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
526 utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled)
528 if (!"get".equals(method))
530 def rollbackData = execution.getVariable("rollbackData")
531 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
532 execution.setVariable("rollbackData", rollbackData)
536 utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
537 throw new BpmnError("MSOWorkflowException")
539 } catch (BpmnError e) {
541 } catch(Exception ex) {
542 msg = "Exception in validateSDNCResp. " + ex.getMessage()
543 utils.log("DEBUG", msg, isDebugLogEnabled)
544 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
546 logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled)
549 public void preProcessSDNCGet(DelegateExecution execution){
550 def isDebugLogEnabled = execution.getVariable(DebugFlag)
551 utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled)
554 def callbackUrl = execution.getVariable("sdncCallbackUrl")
555 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
556 // or from "object-path" in SDNC response for assign when AR does not exist in AA
558 String serviceOperation = ""
560 if (execution.getVariable("foundActiveAR")) {
561 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
562 serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink")
563 utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled)
567 String response = execution.getVariable("sdncAssignResponse")
568 String data = utils.getNodeXml(response, "response-data")
569 data = data.replaceAll("<", "<")
570 data = data.replaceAll(">", ">")
571 utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled)
572 serviceOperation = utils.getNodeText1(data, "object-path")
573 utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled)
576 String serviceInstanceId = execution.getVariable("serviceInstanceId")
577 String sdncRequestId = UUID.randomUUID().toString()
579 //neeed the same url as used by vfmodules
580 String SDNCGetRequest =
581 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
582 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
583 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
584 <sdncadapter:RequestHeader>
585 <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
586 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
587 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
588 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
589 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
590 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
591 </sdncadapter:RequestHeader>
592 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
593 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
595 execution.setVariable("sdncGetRequest", SDNCGetRequest)
598 utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
599 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
601 utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled)
604 public void updateAaiAROrchStatus(DelegateExecution execution, String status){
605 def isDebugEnabled = execution.getVariable(DebugFlag)
606 utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled)
607 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
608 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
609 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
610 utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled)
613 public void generateOutputs(DelegateExecution execution)
615 def isDebugEnabled=execution.getVariable(DebugFlag)
616 utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled)
618 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
619 utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled)
620 String arData = utils.getNodeXml(sdncGetResponse, "brg-topology")
621 arData = utils.removeXmlNamespaces(arData)
623 String brga = utils.getNodeXml(arData, "brg-assignments")
624 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
625 execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name"))
626 } catch (BpmnError e) {
627 utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled)
628 } catch(Exception ex) {
629 String msg = "Exception in generateOutputs " + ex.getMessage()
630 utils.log("DEBUG", msg, isDebugEnabled)
632 utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled)
636 public void preProcessRollback (DelegateExecution execution) {
637 def isDebugEnabled=execution.getVariable(DebugFlag)
638 utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled)
641 Object workflowException = execution.getVariable("WorkflowException");
643 if (workflowException instanceof WorkflowException) {
644 utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
645 execution.setVariable("prevWorkflowException", workflowException);
646 //execution.setVariable("WorkflowException", null);
648 } catch (BpmnError e) {
649 utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled)
650 } catch(Exception ex) {
651 String msg = "Exception in preProcessRollback. " + ex.getMessage()
652 utils.log("DEBUG", msg, isDebugEnabled)
654 utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled)
657 public void postProcessRollback (DelegateExecution execution) {
658 def isDebugEnabled=execution.getVariable(DebugFlag)
659 utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled)
662 Object workflowException = execution.getVariable("prevWorkflowException");
663 if (workflowException instanceof WorkflowException) {
664 utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled)
665 execution.setVariable("WorkflowException", workflowException);
667 execution.setVariable("rollbackData", null)
668 } catch (BpmnError b) {
669 utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled)
671 } catch(Exception ex) {
672 msg = "Exception in postProcessRollback. " + ex.getMessage()
673 utils.log("DEBUG", msg, isDebugEnabled)
675 utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled)