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=========================================================
21 package org.onap.so.bpmn.vcpe.scripts;
23 import org.onap.so.bpmn.common.scripts.*;
24 import org.onap.so.bpmn.common.scripts.AaiUtil
25 import org.onap.so.bpmn.core.RollbackData
26 import org.onap.so.bpmn.core.WorkflowException
27 import org.onap.so.bpmn.core.UrnPropertiesReader
28 import org.onap.so.bpmn.core.json.JsonUtils
29 import org.onap.so.rest.APIResponse
31 import java.util.UUID;
32 import org.camunda.bpm.engine.delegate.BpmnError
33 import org.camunda.bpm.engine.delegate.DelegateExecution
34 import org.apache.commons.lang3.*
35 import org.springframework.web.util.UriUtils;
36 import static org.apache.commons.lang3.StringUtils.*
38 import org.onap.so.logger.MessageEnum
39 import org.onap.so.logger.MsoLogger
40 import org.onap.so.client.aai.AAIResourcesClient
41 import org.onap.so.client.aai.AAIObjectType
42 import org.onap.so.client.aai.entities.AAIResultWrapper
43 import org.onap.so.client.aai.entities.Relationships
44 import org.onap.so.client.aai.entities.uri.AAIResourceUri
45 import org.onap.so.client.aai.entities.uri.AAIUriFactory
46 import org.json.JSONObject
47 import javax.ws.rs.NotFoundException
49 * This groovy class supports the <class>DoCreateAllottedResourceBRG.bpmn</class> process.
54 * @param - msoRequestId
55 * @param - isDEbugLogEnabled
56 * @param - disableRollback
57 * @param - failExists - O
58 * @param - serviceInstanceId
59 * @param - globalCustomerId - O
60 * @param - subscriptionServiceType - O
61 * @param - parentServiceInstanceId
62 * @param - allottedReourceId - O
63 * @param - allottedResourceModelInfo
64 * @param - allottedResourceRole
65 * @param - allottedResourceType
66 * @param - brgWanMacAddress
68 * @param - vgmuxBearerIP
71 * @param - rollbackData (localRB->null)
72 * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
73 * @param - WorkflowException - O
74 * @param - allottedResourceId
75 * @param - allottedResourceName
78 public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{
79 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateAllottedResourceBRG.class);
81 String Prefix="DCARBRG_"
82 ExceptionUtil exceptionUtil = new ExceptionUtil()
83 JsonUtils jsonUtil = new JsonUtils()
85 public void preProcessRequest (DelegateExecution execution) {
89 msoLogger.trace("start preProcessRequest")
92 execution.setVariable("prefix", Prefix)
95 String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
96 if (isBlank(sdncCallbackUrl)) {
97 msg = "mso.workflow.sdncadapter.callback is null"
99 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
101 execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
102 msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl)
104 String sdncReplDelay = UrnPropertiesReader.getVariable("mso.workflow.sdnc.replication.delay",execution)
105 if (isBlank(sdncReplDelay)) {
106 msg = "mso.workflow.sdnc.replication.delay is null"
108 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
110 execution.setVariable("sdncReplDelay", sdncReplDelay)
111 msoLogger.debug("SDNC replication delay: " + sdncReplDelay)
114 if (isBlank(execution.getVariable("serviceInstanceId"))){
115 msg = "Input serviceInstanceId is null"
117 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
119 if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
120 msg = "Input parentServiceInstanceId is null"
122 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
124 if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
125 msg = "Input allottedResourceModelInfo is null"
127 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
129 if (isBlank(execution.getVariable("vni"))) {
130 msg = "Input vni is null"
132 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
134 if (isBlank(execution.getVariable("vgmuxBearerIP"))) {
135 msg = "Input vgmuxBearerIP is null"
137 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
139 if (isBlank(execution.getVariable("brgWanMacAddress"))) {
140 msg = "Input brgWanMacAddress is null"
142 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
144 if (isBlank(execution.getVariable("allottedResourceRole"))) {
145 msg = "Input allottedResourceRole is null"
147 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
149 if (isBlank(execution.getVariable("allottedResourceType"))) {
150 msg = "Input allottedResourceType is null"
152 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
155 msoLogger.debug("Rethrowing MSOWorkflowException")
157 } catch (Exception ex){
158 msg = "Exception in preProcessRequest " + ex.getMessage()
160 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
162 msoLogger.trace("end preProcessRequest")
166 * Gets the service instance uri from aai
168 public void getServiceInstance(DelegateExecution execution) {
169 msoLogger.trace("getServiceInstance ")
171 String serviceInstanceId = execution.getVariable('serviceInstanceId')
173 AAIResourcesClient resourceClient = new AAIResourcesClient()
174 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId)
176 if(resourceClient.exists(uri)){
177 execution.setVariable("CSI_resourceLink", uri.build().toString())
179 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
182 }catch(BpmnError e) {
184 }catch (Exception ex){
185 String msg = "Exception in getServiceInstance. " + ex.getMessage()
187 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
189 msoLogger.trace("Exit getServiceInstance ")
192 public void getAaiAR (DelegateExecution execution) {
195 msoLogger.trace("start getAaiAR")
197 String arType = execution.getVariable("allottedResourceType")
198 String arRole = execution.getVariable("allottedResourceRole")
200 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
201 String orchStatus = arUtils.getAROrchStatus(execution)
205 if (orchStatus != null) // AR was found
207 if ("true".equals(execution.getVariable("failExists")))
209 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
213 if ("Active".equals(orchStatus))
215 execution.setVariable("foundActiveAR", true)
217 else // blanks included
219 errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus
223 if (!isBlank(errorMsg)) {
224 msoLogger.debug(errorMsg)
225 exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
227 msoLogger.trace("end getAaiAR")
230 public void getParentServiceInstance(DelegateExecution execution) {
231 msoLogger.trace("getParentServiceInstance ")
233 String serviceInstanceId = execution.getVariable('parentServiceInstanceId')
235 AAIResourcesClient resourceClient = new AAIResourcesClient()
236 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.NODES_QUERY, "").queryParam("search-node-type", "service-instance").queryParam("filter", "service-instance-id:EQUALS:" + serviceInstanceId)
237 String json = resourceClient.get(uri).getJson()
239 JSONObject obj = new JSONObject(json)
240 if(obj.has("result-data")){
241 JSONObject ob = obj.getJSONArray("result-data").getJSONObject(0)
242 String resourceLink = ob.getString("resource-link")
243 AAIResourceUri siUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, new URI(resourceLink))
245 execution.setVariable("PSI_resourceLink", siUri)
247 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai")
250 }catch(BpmnError e) {
252 }catch (Exception ex){
253 String msg = "Exception in getParentServiceInstance. " + ex.getMessage()
255 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
257 msoLogger.trace("Exit getParentServiceInstance ")
261 public void createAaiAR(DelegateExecution execution) {
264 msoLogger.trace("start createAaiAR")
267 String allottedResourceId = execution.getVariable("allottedResourceId")
268 if (isBlank(allottedResourceId))
270 allottedResourceId = UUID.randomUUID().toString()
271 execution.setVariable("allottedResourceId", allottedResourceId)
277 AaiUtil aaiUriUtil = new AaiUtil(this)
278 AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink")
279 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
280 execution.setVariable("aaiARPath", arUtils.createARUrl(execution, siResourceLink, allottedResourceId))
281 msoLogger.debug("GET AllottedResource AAI URL is:\n" + arUrl)
283 String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl)
285 String arType = execution.getVariable("allottedResourceType")
286 String arRole = execution.getVariable("allottedResourceRole")
287 String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
288 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
289 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
290 String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
291 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
293 if (modelInvariantId == null) {
294 modelInvariantId = ""
296 if (modelVersionId == null) {
299 if (modelCustomizationId == null) {
300 modelCustomizationId = ""
304 """<allotted-resource xmlns="${namespace}">
305 <id>${MsoUtils.xmlEscape(allottedResourceId)}</id>
306 <description></description>
307 <type>${MsoUtils.xmlEscape(arType)}</type>
308 <role>${MsoUtils.xmlEscape(arRole)}</role>
309 <selflink></selflink>
310 <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantId)}</model-invariant-id>
311 <model-version-id>${MsoUtils.xmlEscape(modelVersionId)}</model-version-id>
312 <model-customization-id>${MsoUtils.xmlEscape(modelCustomizationId)}</model-customization-id>
313 <orchestration-status>PendingCreate</orchestration-status>
314 <operation-status></operation-status>
317 <related-to>service-instance</related-to>
318 <related-link>${MsoUtils.xmlEscape(CSI_resourceLink)}</related-link>
321 </allotted-resource>""".trim()
323 execution.setVariable("AaiARPayload", payload)
324 msoLogger.debug(" payload to create AllottedResource in AAI:" + "\n" + payload)
326 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload)
327 int responseCode = response.getStatusCode()
328 msoLogger.debug("AllottedResource AAI PUT responseCode:" + responseCode)
330 String aaiResponse = response.getResponseBodyAsString()
331 msoLogger.debug("AllottedResource AAI PUT responseStr:" + aaiResponse)
333 //200 OK 201 CREATED 202 ACCEPTED
334 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
336 msoLogger.debug("AAI PUT AllottedResource received a Good Response")
339 msoLogger.debug("AAI Put AllottedResouce received a Bad Response Code: " + responseCode)
340 exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
341 throw new BpmnError("MSOWorkflowException")
344 msoLogger.debug("Rethrowing MSOWorkflowException")
346 } catch (Exception ex) {
347 msg = "Exception in createAaiAR " + ex.getMessage()
349 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
352 //start rollback set up
353 RollbackData rollbackData = new RollbackData()
354 def disableRollback = execution.getVariable("disableRollback")
355 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
356 rollbackData.put(Prefix, "rollbackAAI", "true")
357 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
358 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
359 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
360 rollbackData.put(Prefix, "aaiARPath", arUrl)
361 execution.setVariable("rollbackData", rollbackData)
362 msoLogger.trace("end createAaiAR")
365 public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) {
369 msoLogger.trace("start buildSDNCRequest")
370 String sdncReq = null
374 String allottedResourceId = execution.getVariable("allottedResourceId")
375 String serviceInstanceId = execution.getVariable("serviceInstanceId")
376 String globalCustomerId = execution.getVariable("globalCustomerId")
377 String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
378 String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
379 String callbackUrl = execution.getVariable("sdncCallbackUrl")
380 String requestId = execution.getVariable("msoRequestId")
382 String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
383 String vni = execution.getVariable("vni")
384 String vgmuxBearerIP = execution.getVariable("vgmuxBearerIP")
386 String arModelInfo = execution.getVariable("allottedResourceModelInfo")
387 String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
388 String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
389 String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
390 String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
391 String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
393 if (modelInvariantId == null) {
394 modelInvariantId = ""
396 if (modelVersion == null) {
399 if (modelUUId == null) {
402 if (modelName == null) {
405 if (modelCustomizationId == null) {
406 modelCustomizationId = ""
410 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
411 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
412 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
413 <sdncadapter:RequestHeader>
414 <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>
415 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
416 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
417 <sdncadapter:SvcOperation>brg-topology-operation</sdncadapter:SvcOperation>
418 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
419 </sdncadapter:RequestHeader>
420 <sdncadapterworkflow:SDNCRequestData>
421 <request-information>
422 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
423 <request-action>CreateBRGInstance</request-action>
428 </request-information>
429 <service-information>
430 <service-id></service-id>
431 <subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type>
432 <onap-model-information></onap-model-information>
433 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
435 <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
436 </service-information>
437 <allotted-resource-information>
438 <allotted-resource-id>${MsoUtils.xmlEscape(allottedResourceId)}</allotted-resource-id>
439 <allotted-resource-type>brg</allotted-resource-type>
440 <parent-service-instance-id>${MsoUtils.xmlEscape(parentServiceInstanceId)}</parent-service-instance-id>
441 <onap-model-information>
442 <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantId)}</model-invariant-uuid>
443 <model-uuid>${MsoUtils.xmlEscape(modelUUId)}</model-uuid>
444 <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationId)}</model-customization-uuid>
445 <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
446 <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
447 </onap-model-information>
448 </allotted-resource-information>
450 <brg-wan-mac-address>${MsoUtils.xmlEscape(brgWanMacAddress)}</brg-wan-mac-address>
451 <vni>${MsoUtils.xmlEscape(vni)}</vni>
452 <vgmux-bearer-ip>${MsoUtils.xmlEscape(vgmuxBearerIP)}</vgmux-bearer-ip>
454 </sdncadapterworkflow:SDNCRequestData>
455 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
457 msoLogger.debug("sdncRequest:\n" + sdncReq)
458 sdncReq = utils.formatXml(sdncReq)
460 } catch(Exception ex) {
461 msg = "Exception in buildSDNCRequest. " + ex.getMessage()
463 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
465 msoLogger.trace("end buildSDNCRequest")
469 public void preProcessSDNCAssign(DelegateExecution execution) {
473 msoLogger.trace("start preProcessSDNCAssign")
476 String sdncRequestId = UUID.randomUUID().toString()
477 String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
478 execution.setVariable("sdncAssignRequest", sdncAssignReq)
479 msoLogger.debug("sdncAssignRequest: " + sdncAssignReq)
480 def sdncRequestId2 = UUID.randomUUID().toString()
481 String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
482 def rollbackData = execution.getVariable("rollbackData")
483 rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
484 execution.setVariable("rollbackData", rollbackData)
486 msoLogger.debug("sdncAssignRollbackReq:\n" + sdncAssignRollbackReq)
487 msoLogger.debug("rollbackData:\n" + rollbackData.toString())
489 } catch (BpmnError e) {
491 } catch(Exception ex) {
492 msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
494 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
496 msoLogger.trace("end preProcessSDNCAssign")
499 public void preProcessSDNCCreate(DelegateExecution execution) {
503 msoLogger.trace("start preProcessSDNCCreate")
506 String sdncRequestId = UUID.randomUUID().toString()
507 String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
508 execution.setVariable("sdncCreateRequest", sdncCreateReq)
509 msoLogger.debug("sdncCreateReq: " + sdncCreateReq)
510 def sdncRequestId2 = UUID.randomUUID().toString()
511 String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
512 def rollbackData = execution.getVariable("rollbackData")
513 rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
514 execution.setVariable("rollbackData", rollbackData)
516 msoLogger.debug("sdncCreateRollbackReq:\n" + sdncCreateRollbackReq)
517 msoLogger.debug("rollbackData:\n" + rollbackData.toString())
519 } catch (BpmnError e) {
521 } catch(Exception ex) {
522 msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
524 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
526 msoLogger.trace("end preProcessSDNCCreate")
529 public void preProcessSDNCActivate(DelegateExecution execution) {
533 msoLogger.trace("start preProcessSDNCActivate")
536 String sdncRequestId = UUID.randomUUID().toString()
537 String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
538 execution.setVariable("sdncActivateRequest", sdncActivateReq)
539 msoLogger.debug("sdncActivateReq: " + sdncActivateReq)
540 def sdncRequestId2 = UUID.randomUUID().toString()
541 String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
542 def rollbackData = execution.getVariable("rollbackData")
543 rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
544 execution.setVariable("rollbackData", rollbackData)
546 msoLogger.debug("sdncActivateRollbackReq:\n" + sdncActivateRollbackReq)
547 msoLogger.debug("rollbackData:\n" + rollbackData.toString())
549 } catch (BpmnError e) {
551 } catch(Exception ex) {
552 msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
554 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
556 msoLogger.trace("end preProcessSDNCActivate")
559 public void validateSDNCResp(DelegateExecution execution, String response, String method){
562 msoLogger.trace("ValidateSDNCResponse Process")
566 WorkflowException workflowException = execution.getVariable("WorkflowException")
567 msoLogger.debug("workflowException: " + workflowException)
569 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
570 msoLogger.debug("SDNCResponse: " + response)
572 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
573 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
575 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
576 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response)
578 if (!"get".equals(method))
580 def rollbackData = execution.getVariable("rollbackData")
581 rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true")
582 execution.setVariable("rollbackData", rollbackData)
586 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
587 throw new BpmnError("MSOWorkflowException")
589 } catch (BpmnError e) {
591 } catch(Exception ex) {
592 msg = "Exception in validateSDNCResp. " + ex.getMessage()
594 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
596 msoLogger.trace("End ValidateSDNCResp Process")
599 public void preProcessSDNCGet(DelegateExecution execution){
601 msoLogger.trace("start preProcessSDNCGet")
604 def callbackUrl = execution.getVariable("sdncCallbackUrl")
605 // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
606 // or from "object-path" in SDNC response for assign when AR does not exist in AA
608 String serviceOperation = ""
610 if (execution.getVariable("foundActiveAR")) {
611 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
612 serviceOperation = utils.getNodeText(aaiQueryResponse, "selflink")
613 msoLogger.debug("AR service operation/aaiARSelfLink: " + serviceOperation)
617 String response = execution.getVariable("sdncAssignResponse")
618 String data = utils.getNodeXml(response, "response-data")
619 msoLogger.debug("Assign responseData: " + data)
620 serviceOperation = utils.getNodeText(data, "object-path")
621 msoLogger.debug("AR service operation:" + serviceOperation)
624 String serviceInstanceId = execution.getVariable("serviceInstanceId")
625 String sdncRequestId = UUID.randomUUID().toString()
627 //neeed the same url as used by vfmodules
628 String SDNCGetRequest =
629 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
630 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
631 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
632 <sdncadapter:RequestHeader>
633 <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>
634 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
635 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
636 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
637 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
638 <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
639 </sdncadapter:RequestHeader>
640 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
641 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
643 execution.setVariable("sdncGetRequest", SDNCGetRequest)
646 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
647 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
649 msoLogger.trace("end preProcessSDNCGet")
652 public void updateAaiAROrchStatus(DelegateExecution execution, String status){
654 msoLogger.trace("start updateAaiAROrchStatus")
655 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
656 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
657 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
658 msoLogger.trace("end updateAaiAROrchStatus")
661 public void generateOutputs(DelegateExecution execution)
664 msoLogger.trace("start generateOutputs")
666 String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
667 msoLogger.debug("resp:" + sdncGetResponse)
668 String arData = utils.getNodeXml(sdncGetResponse, "brg-topology")
669 arData = utils.removeXmlNamespaces(arData)
671 String brga = utils.getNodeXml(arData, "brg-assignments")
672 String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
673 execution.setVariable("allotedResourceName", utils.getNodeText(ari, "allotted-resource-name"))
674 } catch (BpmnError e) {
675 msoLogger.debug("BPMN Error in generateOutputs ")
676 } catch(Exception ex) {
677 String msg = "Exception in generateOutputs " + ex.getMessage()
680 msoLogger.trace("end generateOutputs")
684 public void preProcessRollback (DelegateExecution execution) {
686 msoLogger.trace("start preProcessRollback")
689 Object workflowException = execution.getVariable("WorkflowException");
691 if (workflowException instanceof WorkflowException) {
692 msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage())
693 execution.setVariable("prevWorkflowException", workflowException);
694 //execution.setVariable("WorkflowException", null);
696 } catch (BpmnError e) {
697 msoLogger.debug("BPMN Error during preProcessRollback")
698 } catch(Exception ex) {
699 String msg = "Exception in preProcessRollback. " + ex.getMessage()
702 msoLogger.trace("end preProcessRollback")
705 public void postProcessRollback (DelegateExecution execution) {
707 msoLogger.trace("start postProcessRollback")
710 Object workflowException = execution.getVariable("prevWorkflowException");
711 if (workflowException instanceof WorkflowException) {
712 msoLogger.debug("Setting prevException to WorkflowException: ")
713 execution.setVariable("WorkflowException", workflowException);
715 execution.setVariable("rollbackData", null)
716 } catch (BpmnError b) {
717 msoLogger.debug("BPMN Error during postProcessRollback")
719 } catch(Exception ex) {
720 msg = "Exception in postProcessRollback. " + ex.getMessage()
723 msoLogger.trace("end postProcessRollback")