2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common.scripts;
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.onap.aai.domain.yang.L3Network
28 import org.onap.so.bpmn.core.WorkflowException
29 import org.onap.so.bpmn.core.json.JsonUtils
30 import org.onap.so.logger.ErrorCode;
31 import org.springframework.web.util.UriUtils
32 import org.onap.so.bpmn.core.UrnPropertiesReader
33 import org.onap.so.logger.MessageEnum
34 import org.slf4j.Logger
35 import org.slf4j.LoggerFactory
44 class SDNCAdapterUtils {
45 private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterUtils.class);
48 ExceptionUtil exceptionUtil = new ExceptionUtil()
49 JsonUtils jsonUtil = new JsonUtils()
51 private AbstractServiceTaskProcessor taskProcessor
53 public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
54 this.taskProcessor = taskProcessor
57 String SDNCAdapterFeatureRequest(DelegateExecution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
58 def utils=new MsoUtils()
60 def prefix = execution.getVariable('prefix')
61 def request = taskProcessor.getVariable(execution, requestName)
62 def requestInformation = utils.getNodeXml(request, 'request-information', false)
63 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
64 def featureInformation = utils.getNodeXml(request, 'feature-information', false)
65 def featureParameters = utils.getNodeXml(request, 'feature-parameters', false)
67 def requestId = execution.getVariable('testReqId') // for junits
69 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
72 def svcInstanceId = execution.getVariable("mso-service-instance-id")
74 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
75 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
76 def nnsFeatureInformation = utils.removeXmlNamespaces(featureInformation)
77 def nnsFeatureParameters = utils.removeXmlNamespaces(featureParameters)
79 String sdncAdapterFeatureRequest = """
80 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
81 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
82 <sdncadapter:RequestHeader>
83 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
84 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
85 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
86 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
87 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
88 </sdncadapter:RequestHeader>
89 <sdncadapterworkflow:SDNCRequestData>
90 ${nnsRequestInformation}
91 ${nnsServiceInformation}
92 ${nnsFeatureInformation}
93 ${nnsFeatureParameters}
94 </sdncadapterworkflow:SDNCRequestData>
95 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
96 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
98 sdncAdapterFeatureRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterFeatureRequest))
99 return sdncAdapterFeatureRequest
102 String SDNCAdapterActivateVnfRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) {
103 def utils=new MsoUtils()
105 def prefix = execution.getVariable('prefix')
106 def request = taskProcessor.getVariable(execution, prefix+'Request')
107 def requestInformation = utils.getNodeXml(request, 'request-information', false)
108 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
109 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
111 def requestId = execution.getVariable('testReqId') // for junits
113 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
116 def svcInstanceId = execution.getVariable("mso-service-instance-id")
118 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
119 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
120 def nnsVnfInformationList = utils.removeXmlNamespaces(vnfInformationList)
122 String sdncAdapterActivateVnfRequest = """
123 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
124 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
125 <sdncadapter:RequestHeader>
126 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
127 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
128 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
129 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
130 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
131 <sdncadapter:MsoAction>${MsoUtils.xmlEscape(msoAction)}</sdncadapter:MsoAction>
132 </sdncadapter:RequestHeader>
133 <sdncadapterworkflow:SDNCRequestData>
134 ${nnsRequestInformation}
135 ${nnsServiceInformation}
136 ${nnsVnfInformationList}
137 </sdncadapterworkflow:SDNCRequestData>
138 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
139 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
141 sdncAdapterActivateVnfRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterActivateVnfRequest))
142 return sdncAdapterActivateVnfRequest
145 String SDNCAdapterL3ToHigherLayerRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
146 def utils=new MsoUtils()
148 def prefix = execution.getVariable('prefix')
149 def request = taskProcessor.getVariable(execution, prefix+'Request')
151 String requestInformation = """<request-information>
152 <request-id>${MsoUtils.xmlEscape(execution.getVariable("mso-request-id"))}</request-id>
153 <request-action>torepl</request-action>
154 <source>${MsoUtils.xmlEscape(execution.getVariable(prefix+"source"))}</source>
155 <notification-url>${MsoUtils.xmlEscape(execution.getVariable(prefix+"notificationUrl"))}</notification-url>
156 </request-information>"""
158 // Change the value of the 'request-information'.'request-action' element
159 def xml = new XmlSlurper().parseText(requestInformation)
160 if("assign".equalsIgnoreCase(action)){
161 xml.'request-action'.replaceBody('createTrinityBonding')
162 }else if("activate".equalsIgnoreCase(action)){
163 xml.'request-action'.replaceBody('activateTrinityBonding')
164 }else if("delete".equalsIgnoreCase(action)){
165 xml.'request-action'.replaceBody('deleteTrinityBonding')
167 requestInformation = utils.removeXmlPreamble(groovy.xml.XmlUtil.serialize(xml))
168 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
170 def requestId = execution.getVariable('testReqId') // for junits
172 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
175 def svcInstanceId = execution.getVariable("mso-service-instance-id")
177 //Build Service Information
178 // Send serviceName from CANOPI to sdnc for service-type
179 String serviceInformation = """<service-information>
180 <service-type>${MsoUtils.xmlEscape(execution.getVariable(prefix+"serviceName"))}</service-type>
181 <service-instance-id>${MsoUtils.xmlEscape(svcInstanceId)}</service-instance-id>
182 <subscriber-name>${MsoUtils.xmlEscape(execution.getVariable(prefix+"subscriberName"))}</subscriber-name>
183 <subscriber-global-id>${MsoUtils.xmlEscape(execution.getVariable(prefix+"subscriberGlobalId"))}</subscriber-global-id>
184 </service-information>"""
186 //Build Additional Information - vpn or vni
187 // Send serviceType from CANOPI to SDNC for nbnc-request-information service-type
188 def service = execution.getVariable(prefix+"serviceType")
189 def customerId = execution.getVariable(prefix+"customerId")
190 def vpnId = execution.getVariable(prefix+"vpnId")
191 def vpnRt = execution.getVariable(prefix+"vpnRt")
192 def vpnService = execution.getVariable(prefix+"vpnService")
193 def vpnRegion = execution.getVariable(prefix+"vpnRegion")
194 def additionalInfo = ""
195 if("assign".equalsIgnoreCase(action)){
196 additionalInfo = """<vpn-data-list>
197 <vpn-id>${MsoUtils.xmlEscape(vpnId)}</vpn-id>
198 <vpn-rt>${MsoUtils.xmlEscape(vpnRt)}</vpn-rt>
199 <vpn-service>${MsoUtils.xmlEscape(vpnService)}</vpn-service>
200 <vpn-region>${MsoUtils.xmlEscape(vpnRegion)}</vpn-region>
202 }else if("activate".equalsIgnoreCase(action) || "delete".equalsIgnoreCase(action)){
203 def vniId = execution.getVariable(prefix+'vniId')
204 additionalInfo = "<vni-id>${MsoUtils.xmlEscape(vniId)}</vni-id>"
207 //Set Interface Status
208 def interfaceStatus = "DISABLE"
209 if("activate".equalsIgnoreCase(action)){
210 interfaceStatus = "ENABLE"
213 //Build SDNC Adapter Request
214 String sdncAdapterL3ToHLRequest = """
215 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
216 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
217 <sdncadapter:RequestHeader>
218 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
219 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
220 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
221 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
222 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
223 </sdncadapter:RequestHeader>
224 <sdncadapterworkflow:SDNCRequestData>
225 ${nnsRequestInformation}
226 ${serviceInformation}
227 <nbnc-request-information>
228 <service-type>${MsoUtils.xmlEscape(service)}</service-type>
229 <customer-id>${MsoUtils.xmlEscape(customerId)}</customer-id>
230 <interface-status>${MsoUtils.xmlEscape(interfaceStatus)}</interface-status>
232 </nbnc-request-information>
233 </sdncadapterworkflow:SDNCRequestData>
234 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
235 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
237 sdncAdapterL3ToHLRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterL3ToHLRequest))
239 return sdncAdapterL3ToHLRequest
244 private void SDNCAdapterActivateRequest(DelegateExecution execution, String resultVar, String svcAction,
245 String svcOperation, String additionalData) {
246 def utils=new MsoUtils()
248 def prefix = execution.getVariable('prefix')
249 def request = taskProcessor.getVariable(execution, prefix+'Request')
250 def requestInformation = utils.getNodeXml(request, 'request-information', false)
251 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
252 def serviceParameters = utils.getNodeXml(request, 'service-parameters', false)
254 def requestId = execution.getVariable('testReqId') // for junits
256 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
259 def svcInstanceId = execution.getVariable("mso-service-instance-id")
260 def msoAction = 'gammainternet'
262 def timeoutInMinutes = UrnPropertiesReader.getVariable('mso.sdnc.timeout.firewall.minutes',execution)
264 def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution)
265 if (callbackUrl == null || callbackUrl.trim() == "") {
266 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
267 'mso:workflow:sdncadapter:callback URN is not set', "BPMN",
268 ErrorCode.UnknownError.getValue());
269 workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code?
272 def l2HomingInformation = utils.getNodeXml(serviceParameters, 'l2-homing-information', false)
273 def internetEvcAccessInformation = utils.getNodeXml(serviceParameters, 'internet-evc-access-information', false)
274 def vrLan = utils.getNodeXml(serviceParameters, 'vr-lan', false)
275 def upceVmsServiceInformation = utils.getNodeXml(serviceParameters, 'ucpe-vms-service-information', false)
278 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
279 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
280 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
281 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
282 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
283 def nnsUpceVmsServiceInformation = utils.removeXmlNamespaces(upceVmsServiceInformation)
285 if (additionalData == null) {
289 boolean isAic3 = execution.getVariable("isAic3")
292 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
295 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
299 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
300 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
301 <sdncadapter:RequestHeader>
302 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
303 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
304 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction>
305 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(svcOperation)}</sdncadapter:SvcOperation>
306 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
307 <sdncadapter:MsoAction>${MsoUtils.xmlEscape(msoAction)}</sdncadapter:MsoAction>
308 </sdncadapter:RequestHeader>
309 <sdncadapterworkflow:SDNCRequestData>
311 ${nnsRequestInformation}
312 ${nnsServiceInformation}
313 ${nnsl2HomingInformation}
314 ${nnsInternetEvcAccessInformation}
316 ${nnsUpceVmsServiceInformation}
317 </sdncadapterworkflow:SDNCRequestData>
318 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
319 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
322 content = utils.removeXmlPreamble(utils.formatXML(content))
323 execution.setVariable(resultVar, content)
327 * Builds an SDNC "reserve" request and stores it in the specified execution
329 * @param execution the execution
330 * @param action the type of action: reserve, turnup, etc
331 * @param resultVar the execution variable in which the result will be stored
333 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar) {
334 sdncReservePrep(execution, action, resultVar, false)
338 * Builds an SDNC "reserve" request and stores it in the specified execution
340 * @param execution the execution
341 * @param action the type of action: reserve, turnup, etc
342 * @param resultVar the execution variable in which the result will be stored
343 * @param isAic3 boolean to indicate whether request is for AIC3.0
345 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar, boolean isAic3) {
346 sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3, this.taskProcessor)
350 * Builds a basic SDNC request and stores it in the specified execution variable.
351 * @param execution the execution
352 * @param resultVar the execution variable in which the result will be stored
353 * @param svcAction the svcAction element value
354 * @param svcOperation the svcOperation element value
355 * @param additionalData additional XML content to be inserted into the
356 * RequestData element (may be null)
358 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
359 String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) {
360 sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false, taskProcessor)
364 * Builds a basic SDNC request and stores it in the specified execution variable.
365 * @param execution the execution
366 * @param resultVar the execution variable in which the result will be stored
367 * @param svcAction the svcAction element value
368 * @param svcOperation the svcOperation element value
369 * @param additionalData additional XML content to be inserted into the RequestData element (may be null)
370 * @param isAic3 boolean to indicate whether request is for AIC3.0
372 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
373 String svcOperation, String additionalData, boolean isAic3, AbstractServiceTaskProcessor taskProcessor) {
374 def method = getClass().getSimpleName() + '.sdncPrep(' +
375 'execution=' + execution.getId() +
376 ', resultVar=' + resultVar +
377 ', svcAction=' + svcAction +
378 ', svcOperation=' + svcOperation +
379 ', additionalData=' + (additionalData == null ? "no" : "yes") +
382 logger.trace('Entered ' + method)
383 MsoUtils utils = taskProcessor.utils
385 def prefix = execution.getVariable('prefix')
386 def request = taskProcessor.getVariable(execution, prefix+'Request')
387 def requestInformation = utils.getNodeXml(request, 'request-information', false)
388 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
389 def serviceParameters = utils.getChildNodes(request, 'service-parameters')
390 def requestAction = utils.getNodeText(request, 'request-action')
392 def timeoutInMinutes = UrnPropertiesReader.getVariable('mso.sdnc.timeout.firewall.minutes',execution)
394 def requestId = execution.getVariable('testReqId') // for junits
396 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
399 def svcInstanceId = execution.getVariable("mso-service-instance-id")
400 def msoAction = 'gammainternet'
402 def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution)
403 if (callbackUrl == null || callbackUrl.trim() == "") {
404 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
405 'mso:workflow:sdncadapter:callback URN is not set', "BPMN",
406 ErrorCode.UnknownError.getValue());
407 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request")
410 def l2HomingInformation = utils.getNodeXml(request, 'l2-homing-information', false)
411 def internetEvcAccessInformation = utils.getNodeXml(request, 'internet-evc-access-information', false)
412 def vrLan = utils.getNodeXml(request, 'vr-lan', false)
413 def upceVmsServiceInfo = utils.getNodeXml(request, 'ucpe-vms-service-information', false)
414 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
416 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
417 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
418 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
419 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
420 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
421 def nnsUpceVmsServiceInfo = utils.removeXmlNamespaces(upceVmsServiceInfo)
422 def nnsVnfInformationList = utils.removeXmlNamespaces(vrLan)
423 def nnsinternetSvcChangeDetails = ""
425 if(requestAction!=null && requestAction.equals("ChangeLayer3ServiceProvRequest")){
426 def internetSvcChangeDetails = utils.removeXmlNamespaces(serviceParameters)
427 nnsinternetSvcChangeDetails = """<internet-service-change-details>
428 ${internetSvcChangeDetails}
429 </internet-service-change-details>"""
432 if (additionalData == null) {
437 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
440 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
445 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
446 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
447 <sdncadapter:RequestHeader>
448 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
449 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
450 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction>
451 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(svcOperation)}</sdncadapter:SvcOperation>
452 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
453 <sdncadapter:MsoAction>${MsoUtils.xmlEscape(msoAction)}</sdncadapter:MsoAction>
454 </sdncadapter:RequestHeader>
455 <sdncadapterworkflow:SDNCRequestData>
457 ${nnsRequestInformation}
458 ${nnsServiceInformation}
459 ${nnsl2HomingInformation}
460 ${nnsInternetEvcAccessInformation}
462 ${nnsUpceVmsServiceInfo}
463 ${nnsVnfInformationList}
464 ${nnsinternetSvcChangeDetails}
465 </sdncadapterworkflow:SDNCRequestData>
466 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
469 content = utils.removeXmlPreamble(utils.formatXML(content))
470 execution.setVariable(resultVar, content)
471 logger.debug(resultVar + ' = ' + System.lineSeparator() + content)
473 logger.trace('Exited ' + method)
474 } catch (BpmnError e) {
476 } catch (Exception e) {
477 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
478 'Caught exception in ' + method, "BPMN",
479 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
480 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error")
484 public String updateHomingInfo(String homingInfo, String aicVersion) {
486 if(homingInfo == null || homingInfo.trim().length() == 0) {
487 newHomingInfo = "<l2-homing-information><aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
490 newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
495 * Builds a topology SDNC request and return String request.
496 * As V2 will use 1607-style request, region instead of aic clli code
497 * @param execution, the execution
498 * @param requestXML, the incoming request for the flow
499 * @param serviceInstanceId, the serviceIntance (if available)
500 * @param callbackUrl, the call back url
501 * @param action, the action element value
502 * @param requestAction the svcOperation element value
503 * @param cloudRegionId the aai's cloud-region-id
504 * @param networkId the aai's network-id
505 * @param additionalData additional XML content to be inserted into the
506 * RequestData element (may be null)
508 public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, L3Network queryAAIResponse, String additionalData) {
509 def utils=new MsoUtils()
511 // SNDC is expecting request Id for header as unique each call.
512 String hdrRequestId = ""
513 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
514 if (testHdrRequestId == null) {
515 hdrRequestId = UUID.randomUUID() // generate unique
517 hdrRequestId = testHdrRequestId
520 String requestId = ""
522 requestId = execution.getVariable("mso-request-id")
523 } catch (Exception ex) {
524 requestId = utils.getNodeText(requestXML, "request-id")
527 String aicCloudRegion = cloudRegionId
529 if (utils.nodeExists(requestXML, "tenant-id")) {
530 tenantId = utils.getNodeText(requestXML, "tenant-id")
532 String networkType = ""
533 if (utils.nodeExists(requestXML, "network-type")) {
534 networkType = utils.getNodeText(requestXML, "network-type")
537 // Replace/Use the value of network-type from aai query (vs input) during Delete Network flows.
538 if (queryAAIResponse != null) {
539 networkType = queryAAIResponse.getNetworkType()
542 String serviceId = ""
543 if (utils.nodeExists(requestXML, "service-id")) {
544 serviceId = utils.getNodeText(requestXML, "service-id")
546 String networkName = ""
547 // Replace/Use the value of network-name from aai query (vs input) if it was already set in AAI
548 if (queryAAIResponse != null) {
549 networkName = queryAAIResponse.getNetworkName()
551 if (networkName.isEmpty() && utils.nodeExists(requestXML, "network-name")) {
552 networkName = utils.getNodeText(requestXML, "network-name")
555 if (utils.nodeExists(requestXML, "source")) {
556 source = utils.getNodeText(requestXML, "source")
559 // get resourceLink from subflow execution variable
560 String serviceType = ""
561 String subscriberName = ""
562 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
563 if (siRelatedLink != null) {
565 int serviceStart = siRelatedLink.indexOf("service-subscription/")
566 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
567 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
568 serviceType = UriUtils.decode(serviceType,"UTF-8")
569 // get subscriber name
570 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
571 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
572 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
573 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
575 serviceType = execution.getVariable("serviceType")
576 subscriberName = execution.getVariable("subscriberName")
580 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
581 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
582 xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
583 xmlns:ns5="http://org.onap/so/request/types/v1">
584 <sdncadapter:RequestHeader>
585 <sdncadapter:RequestId>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
586 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
587 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
588 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
589 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
590 </sdncadapter:RequestHeader>
591 <sdncadapterworkflow:SDNCRequestData>
592 <request-information>
593 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
594 <request-action>${MsoUtils.xmlEscape(requestAction)}</request-action>
595 <source>${MsoUtils.xmlEscape(source)}</source>
596 <notification-url></notification-url>
597 <order-number></order-number>
598 <order-version></order-version>
599 </request-information>
600 <service-information>
601 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
602 <service-type>${MsoUtils.xmlEscape(serviceType)}</service-type>
603 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
604 <subscriber-name>${MsoUtils.xmlEscape(subscriberName)}</subscriber-name>
605 </service-information>
606 <network-request-information>
607 <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
608 <network-type>${MsoUtils.xmlEscape(networkType)}</network-type>
609 <network-name>${MsoUtils.xmlEscape(networkName)}</network-name>
610 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
611 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
612 </network-request-information>
613 </sdncadapterworkflow:SDNCRequestData>
614 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
620 * Builds a topology SDNC request and return String request.
621 * As V2 will use 1607-style request, region instead of aic clli code
622 * @param execution, the execution
623 * @param requestXML, the incoming request for the flow
624 * @param serviceInstanceId, the serviceIntance (if available)
625 * @param callbackUrl, the call back url
626 * @param action, the action element value
627 * @param requestAction the svcOperation element value
628 * @param cloudRegionId the aai's cloud-region-id
629 * @param networkId the aai's network-id
630 * @param additionalData additional XML content to be inserted into the
631 * RequestData element (may be null)
633 public String sdncTopologyRequestRsrc (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) {
634 def utils=new MsoUtils()
636 // SNDC is expecting request Id for header as unique each call.
637 String hdrRequestId = ""
638 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
639 if (testHdrRequestId == null) {
640 hdrRequestId = UUID.randomUUID() // generate unique
642 hdrRequestId = testHdrRequestId
645 String requestId = ""
646 String testRequestId = execution.getVariable("testMessageId") // for test purposes.
647 if (testRequestId == null) {
648 requestId = execution.getVariable("mso-request-id")
649 if (requestId == null) {
650 requestId = execution.getVariable("msoRequestId")
653 requestId = testRequestId
656 String aicCloudRegion = cloudRegionId
658 if (utils.nodeExists(requestXML, "tenant-id")) {
659 tenantId = utils.getNodeText(requestXML, "tenant-id")
661 String networkType = ""
662 if (utils.nodeExists(requestXML, "network-type")) {
663 networkType = utils.getNodeText(requestXML, "network-type")
666 String subscriptionServiceType = ""
667 if (utils.nodeExists(requestXML, "subscription-service-type")) {
668 subscriptionServiceType = utils.getNodeText(requestXML, "subscription-service-type")
671 String globalCustomerId = ""
672 if (utils.nodeExists(requestXML, "global-customer-id")) {
673 globalCustomerId = utils.getNodeText(requestXML, "global-customer-id")
676 String serviceId = ""
677 if (utils.nodeExists(requestXML, "service-id")) {
678 serviceId = utils.getNodeText(requestXML, "service-id")
680 String networkName = ""
681 if (utils.nodeExists(requestXML, "network-name")) {
682 networkName = utils.getNodeText(requestXML, "network-name")
685 if (utils.nodeExists(requestXML, "source")) {
686 source = utils.getNodeText(requestXML, "source")
689 // get resourceLink from subflow execution variable
690 String serviceType = ""
691 String subscriberName = ""
692 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
693 if (siRelatedLink != null) {
695 int serviceStart = siRelatedLink.indexOf("service-subscription/")
696 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
697 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
698 serviceType = UriUtils.decode(serviceType,"UTF-8")
699 // get subscriber name
700 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
701 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
702 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
703 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
706 // network-information from 'networkModelInfo' // verify the DB Catalog response
707 String networkModelInfo = utils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
708 String modelInvariantUuid = utils.getNodeText(networkModelInfo, "modelInvariantUuid") !=null ?
709 utils.getNodeText(networkModelInfo, "modelInvariantUuid") : ""
710 String modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") !=null ?
711 utils.getNodeText(networkModelInfo, "modelCustomizationUuid") : ""
712 String modelUuid = utils.getNodeText(networkModelInfo, "modelUuid") !=null ?
713 utils.getNodeText(networkModelInfo, "modelUuid") : ""
714 String modelVersion = utils.getNodeText(networkModelInfo, "modelVersion") !=null ?
715 utils.getNodeText(networkModelInfo, "modelVersion") : ""
716 String modelName = utils.getNodeText(networkModelInfo, "modelName") !=null ?
717 utils.getNodeText(networkModelInfo, "modelName") : ""
719 // service-information from 'networkModelInfo' // verify the DB Catalog response
720 String serviceModelInfo = utils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","")
721 String serviceModelInvariantUuid = utils.getNodeText(serviceModelInfo, "modelInvariantUuid") !=null ?
722 utils.getNodeText(serviceModelInfo, "modelInvariantUuid") : ""
723 String serviceModelUuid = utils.getNodeText(serviceModelInfo, "modelUuid") !=null ?
724 utils.getNodeText(serviceModelInfo, "modelUuid") : ""
725 String serviceModelVersion = utils.getNodeText(serviceModelInfo, "modelVersion") !=null ?
726 utils.getNodeText(serviceModelInfo, "modelVersion") : ""
727 String serviceModelName = utils.getNodeText(serviceModelInfo, "modelName") !=null ?
728 utils.getNodeText(serviceModelInfo, "modelName") : ""
732 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
733 xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
734 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
735 <sdncadapter:RequestHeader>
736 <sdncadapter:RequestId>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
737 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
738 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
739 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
740 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
741 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
742 </sdncadapter:RequestHeader>
743 <sdncadapterworkflow:SDNCRequestData>
744 <request-information>
745 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
746 <request-action>${MsoUtils.xmlEscape(requestAction)}</request-action>
747 <source>${MsoUtils.xmlEscape(source)}</source>
748 <notification-url></notification-url>
749 <order-number></order-number>
750 <order-version></order-version>
751 </request-information>
752 <service-information>
753 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
754 <subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type>
755 <onap-model-information>
756 <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
757 <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
758 <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
759 <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
760 </onap-model-information>
761 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
762 <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
763 <subscriber-name>${MsoUtils.xmlEscape(subscriberName)}</subscriber-name>
764 </service-information>
765 <network-information>
766 <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
767 <network-type>${MsoUtils.xmlEscape(networkType)}</network-type>
768 <onap-model-information>
769 <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
770 <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
771 <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
772 <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
773 <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
774 </onap-model-information>
775 </network-information>
776 <network-request-input>
777 <network-name>${MsoUtils.xmlEscape(networkName)}</network-name>
778 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
779 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
780 <aic-clli></aic-clli>
781 <network-input-parameters/>
782 </network-request-input>
783 </sdncadapterworkflow:SDNCRequestData>
784 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
790 * Validates a workflow response.
791 * @param execution the execution
792 * @param responseVar the execution variable in which the response is stored
793 * @param workflowException the WorkflowException Object returned from sdnc call
795 public void validateSDNCResponse(DelegateExecution execution, String response, WorkflowException workflowException, boolean successIndicator){
796 logger.debug("SDNC Response is: " + response)
797 logger.debug("SuccessIndicator is: " + successIndicator)
800 def prefix = execution.getVariable('prefix')
801 execution.setVariable(prefix+'sdncResponseSuccess', false)
802 logger.debug("Response" + ' = ' + (response == null ? "" : System.lineSeparator()) + response)
804 if (successIndicator){
805 if (response == null || response.trim().equals("")) {
806 logger.debug(response + ' is empty');
807 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty")
810 // we need to peer into the request data for error
811 def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false)
812 def String decodedXml = sdncAdapterWorkflowResponse.replace('<?xml version="1.0" encoding="UTF-8"?>', "")
813 decodedXml = taskProcessor.utils.getNodeXml(response, 'RequestData')
814 logger.debug("decodedXml:\n" + decodedXml)
816 int requestDataResponseCode = 200
817 def String requestDataResponseMessage = ''
820 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
821 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
822 } else if (taskProcessor.utils.nodeExists(sdncAdapterWorkflowResponse, "ResponseMessage")) {
823 requestDataResponseMessage = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseMessage")
826 logger.debug('Error caught while decoding resposne ' + e.getMessage())
829 if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
830 logger.debug("response-code node Exist ")
831 String code = taskProcessor.utils.getNodeText(decodedXml, "response-code")
832 if(code.isEmpty() || code.equals("")){
833 // if response-code is blank then Success
834 logger.debug("response-code node is empty")
835 requestDataResponseCode = 0
837 requestDataResponseCode = code.toInteger()
838 logger.debug("response-code is: " + requestDataResponseCode)
840 }else if(taskProcessor.utils.nodeExists(sdncAdapterWorkflowResponse, "ResponseCode")){
841 logger.debug("ResponseCode node Exist ")
842 String code = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseCode")
843 if(code.isEmpty() || code.equals("")){
844 // if ResponseCode blank then Success
845 logger.debug("ResponseCode node is empty")
846 requestDataResponseCode = 0
848 requestDataResponseCode = code.toInteger()
849 logger.debug("ResponseCode is: " + requestDataResponseCode)
852 logger.debug("A Response Code DOES NOT Exist.")
853 // if a response code does not exist then Success
854 requestDataResponseCode = 0
858 execution.setVariable(prefix+'sdncRequestDataResponseCode', requestDataResponseCode.toString())
859 // if a response code is 0 or 2XX then Success
860 if ((requestDataResponseCode >= 200 && requestDataResponseCode <= 299) || requestDataResponseCode == 0) {
861 execution.setVariable(prefix+'sdncResponseSuccess', true)
862 logger.debug("Setting sdncResponseSuccess to True ")
863 logger.debug("Exited ValidateSDNCResponse Method")
865 ExceptionUtil exceptionUtil = new ExceptionUtil()
866 String convertedCode = exceptionUtil.MapSDNCResponseCodeToErrorCode(requestDataResponseCode.toString())
867 int convertedCodeInt = Integer.parseInt(convertedCode)
868 exceptionUtil.buildAndThrowWorkflowException(execution, convertedCodeInt, "Received error from SDN-C: " + requestDataResponseMessage)
872 //TODO proper handling of new, non numerical response codes in 1607 and new error handling for common API
873 requestDataResponseCode = 500
876 logger.debug("SDNC callback response-code: " + requestDataResponseCode)
877 logger.debug("SDNC callback response-message: " + requestDataResponseMessage)
881 logger.debug('SDNCAdapter Subflow did NOT complete Successfully. SuccessIndicator is False. ')
882 if(workflowException != null){
883 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
885 //TODO : what error code and error message use here
886 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - SDNCAdapter Subflow did NOT complete successfully.")
890 } catch (BpmnError e) {
892 } catch (Exception e) {
893 logger.debug('END of Validate SDNC Response')
894 exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error- Unable to validate SDNC Response ');
899 * Validates a workflow response.
900 * @param execution the execution
901 * @param responseVar the execution variable in which the response is stored
902 * @param responseCodeVar the execution variable in which the response code is stored
903 * @param errorResponseVar the execution variable in which the error response is stored
905 public void validateL3BondingSDNCResp(DelegateExecution execution, String response, WorkflowException workflowException, boolean success) {
906 def method = getClass().getSimpleName() + '.validateL3BondingSDNCResp(' +
907 'execution=' + execution.getId() +
908 ', response=' + response +
910 logger.trace('Entered ' + method)
911 def prefix = execution.getVariable('prefix')
912 TrinityExceptionUtil trinityExceptionUtil = new TrinityExceptionUtil()
915 execution.setVariable(prefix+'sdncResponseSuccess', false)
917 logger.debug("sdncAdapter Success Indicator is: " + success)
920 // we need to look inside the request data for error
921 def String callbackRequestData = taskProcessor.utils.getNodeXml(response, 'RequestData', false)
922 def String decodedXml = callbackRequestData
923 logger.debug("decodedXml:\n" + decodedXml)
925 def requestDataResponseCode = '200'
926 def requestDataResponseMessage = ''
927 int intDataResponseCode = 200
929 if (taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
931 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "response-code"))
932 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
933 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
935 }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){
936 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "ResponseCode")).toInteger()
937 }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){
938 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(response, "ResponseCode")).toInteger()
939 requestDataResponseMessage = taskProcessor.utils.getNodeText(response, "ResponseMessage")
942 logger.debug("SDNC callback response-code: " + requestDataResponseCode)
943 logger.debug("SDNC callback response-message: " + requestDataResponseMessage)
945 // Get the AAI Status to determine if rollback is needed on ASSIGN
947 if (taskProcessor.utils.nodeExists(decodedXml, "aai-status")) {
948 aai_status = ((String) taskProcessor.utils.getNodeText(decodedXml, "aai-status"))
949 logger.debug("SDNC sent AAI STATUS code: " + aai_status)
951 if (aai_status != null && !aai_status.equals("")) {
952 execution.setVariable(prefix+"AaiStatus",aai_status)
953 logger.debug("Set variable " + prefix + "AaiStatus: " + execution.getVariable(prefix+"AaiStatus"))
956 // Get the result string to determine if rollback is needed on ASSIGN in Add Bonding flow only
958 if (taskProcessor.utils.nodeExists(decodedXml, "result")) {
959 sdncResult = ((String) taskProcessor.utils.getNodeText(decodedXml, "result"))
960 logger.debug("SDNC sent result: " + sdncResult)
962 if (sdncResult != null && !sdncResult.equals("")) {
963 execution.setVariable(prefix+"SdncResult",sdncResult)
964 logger.debug("Set variable " + prefix + "SdncResult: " + execution.getVariable(prefix+"SdncResult"))
968 intDataResponseCode = Integer.parseInt(String.valueOf(requestDataResponseCode))
970 intDataResponseCode = 400
973 logger.debug("intDataResponseCode " + intDataResponseCode )
975 // if response-code is not Success (200, 201, etc) we need to throw an exception
976 if ((intDataResponseCode < 200 || intDataResponseCode > 299) && intDataResponseCode != 0) {
977 execution.setVariable(prefix+'ResponseCode', intDataResponseCode)
978 execution.setVariable("L3HLAB_rollback", true)
979 def msg = trinityExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution)
980 exceptionUtil.buildAndThrowWorkflowException(execution, intDataResponseCode, "Received error from SDN-C: " + msg)
984 logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING,
985 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ',
986 "BPMN", ErrorCode.UnknownError,
987 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ')
988 execution.setVariable("L3HLAB_rollback", true)
989 def msg = trinityExceptionUtil.intDataResponseCode(response, execution)
990 exceptionUtil.buildAndThrowWorkflowException(execution, intDataResponseCode, msg)
993 if (response == null || response.trim().equals("")) {
994 logger.warn("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_WARNING,
995 'sdncAdapter workflow response is empty', "BPMN",
996 ErrorCode.UnknownError, 'sdncAdapter workflow response is empty')
997 execution.setVariable("L3HLAB_rollback", true)
998 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response " , execution)
999 exceptionUtil.buildAndThrowWorkflowException(execution, intResponseCode, msg)
1002 execution.setVariable(prefix+'sdncResponseSuccess', true)
1003 logger.trace('Exited ' + method)
1004 } catch (BpmnError e) {
1006 } catch (Exception e) {
1007 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), 'Caught ' +
1008 'exception in ' + method, "BPMN", ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
1009 execution.setVariable(prefix+"ResponseCode",400)
1010 execution.setVariable("L3HLAB_rollback", true)
1011 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response: " + e.getMessage(), execution)
1012 exceptionUtil.buildAndThrowWorkflowException(execution, 400, msg)
1016 public String modelInfoToEcompModelInformation(String jsonModelInfo) {
1017 String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid")
1018 String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid")
1019 if (modelUuid == null) {
1022 String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid")
1023 String modelCustomizationString = ""
1024 if (modelCustomizationUuid != null) {
1025 modelCustomizationString = "<model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>"
1027 String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion")
1028 if (modelVersion == null) {
1031 String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName")
1032 String ecompModelInformation =
1033 """<onap-model-information>
1034 <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
1035 <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
1036 ${modelCustomizationString}
1037 <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
1038 <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
1039 </onap-model-information>"""
1041 return ecompModelInformation