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.common.scripts;
23 import org.camunda.bpm.engine.delegate.BpmnError
24 import org.camunda.bpm.engine.delegate.DelegateExecution
25 import org.onap.aai.domain.yang.L3Network
26 import org.onap.so.bpmn.core.WorkflowException
27 import org.onap.so.bpmn.core.json.JsonUtils;
28 import org.springframework.web.util.UriUtils
29 import org.onap.so.bpmn.core.UrnPropertiesReader
30 import org.onap.so.logger.MessageEnum
31 import org.onap.so.logger.MsoLogger
40 class SDNCAdapterUtils {
41 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, SDNCAdapterUtils.class);
44 ExceptionUtil exceptionUtil = new ExceptionUtil()
45 JsonUtils jsonUtil = new JsonUtils()
47 private AbstractServiceTaskProcessor taskProcessor
49 public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
50 this.taskProcessor = taskProcessor
53 String SDNCAdapterFeatureRequest(DelegateExecution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
54 def utils=new MsoUtils()
56 def prefix = execution.getVariable('prefix')
57 def request = taskProcessor.getVariable(execution, requestName)
58 def requestInformation = utils.getNodeXml(request, 'request-information', false)
59 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
60 def featureInformation = utils.getNodeXml(request, 'feature-information', false)
61 def featureParameters = utils.getNodeXml(request, 'feature-parameters', false)
63 def requestId = execution.getVariable('testReqId') // for junits
65 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
68 def svcInstanceId = execution.getVariable("mso-service-instance-id")
70 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
71 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
72 def nnsFeatureInformation = utils.removeXmlNamespaces(featureInformation)
73 def nnsFeatureParameters = utils.removeXmlNamespaces(featureParameters)
75 String sdncAdapterFeatureRequest = """
76 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
77 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
78 <sdncadapter:RequestHeader>
79 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
80 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
81 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
82 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
83 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
84 </sdncadapter:RequestHeader>
85 <sdncadapterworkflow:SDNCRequestData>
86 ${nnsRequestInformation}
87 ${nnsServiceInformation}
88 ${nnsFeatureInformation}
89 ${nnsFeatureParameters}
90 </sdncadapterworkflow:SDNCRequestData>
91 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
92 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
94 sdncAdapterFeatureRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterFeatureRequest))
95 return sdncAdapterFeatureRequest
98 String SDNCAdapterActivateVnfRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) {
99 def utils=new MsoUtils()
101 def prefix = execution.getVariable('prefix')
102 def request = taskProcessor.getVariable(execution, prefix+'Request')
103 def requestInformation = utils.getNodeXml(request, 'request-information', false)
104 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
105 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
107 def requestId = execution.getVariable('testReqId') // for junits
109 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
112 def svcInstanceId = execution.getVariable("mso-service-instance-id")
114 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
115 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
116 def nnsVnfInformationList = utils.removeXmlNamespaces(vnfInformationList)
118 String sdncAdapterActivateVnfRequest = """
119 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
120 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
121 <sdncadapter:RequestHeader>
122 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
123 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
124 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
125 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
126 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
127 <sdncadapter:MsoAction>${MsoUtils.xmlEscape(msoAction)}</sdncadapter:MsoAction>
128 </sdncadapter:RequestHeader>
129 <sdncadapterworkflow:SDNCRequestData>
130 ${nnsRequestInformation}
131 ${nnsServiceInformation}
132 ${nnsVnfInformationList}
133 </sdncadapterworkflow:SDNCRequestData>
134 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
135 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
137 sdncAdapterActivateVnfRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterActivateVnfRequest))
138 return sdncAdapterActivateVnfRequest
141 String SDNCAdapterL3ToHigherLayerRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
142 def utils=new MsoUtils()
144 def prefix = execution.getVariable('prefix')
145 def request = taskProcessor.getVariable(execution, prefix+'Request')
147 def requestInformation = """<request-information>
148 <request-id>${MsoUtils.xmlEscape(execution.getVariable("mso-request-id"))}</request-id>
149 <request-action>torepl</request-action>
150 <source>${MsoUtils.xmlEscape(execution.getVariable(prefix+"source"))}</source>
151 <notification-url>${MsoUtils.xmlEscape(execution.getVariable(prefix+"notificationUrl"))}</notification-url>
152 </request-information>"""
154 // Change the value of the 'request-information'.'request-action' element
155 def xml = new XmlSlurper().parseText(requestInformation)
156 if("assign".equalsIgnoreCase(action)){
157 xml.'request-action'.replaceBody('createTrinityBonding')
158 }else if("activate".equalsIgnoreCase(action)){
159 xml.'request-action'.replaceBody('activateTrinityBonding')
160 }else if("delete".equalsIgnoreCase(action)){
161 xml.'request-action'.replaceBody('deleteTrinityBonding')
163 requestInformation = utils.removeXmlPreamble(groovy.xml.XmlUtil.serialize(xml))
164 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
166 def requestId = execution.getVariable('testReqId') // for junits
168 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
171 def svcInstanceId = execution.getVariable("mso-service-instance-id")
173 //Build Service Information
174 // Send serviceName from CANOPI to sdnc for service-type
175 def serviceInformation = """<service-information>
176 <service-type>${MsoUtils.xmlEscape(execution.getVariable(prefix+"serviceName"))}</service-type>
177 <service-instance-id>${MsoUtils.xmlEscape(svcInstanceId)}</service-instance-id>
178 <subscriber-name>${MsoUtils.xmlEscape(execution.getVariable(prefix+"subscriberName"))}</subscriber-name>
179 <subscriber-global-id>${MsoUtils.xmlEscape(execution.getVariable(prefix+"subscriberGlobalId"))}</subscriber-global-id>
180 </service-information>"""
182 //Build Additional Information - vpn or vni
183 // Send serviceType from CANOPI to SDNC for nbnc-request-information service-type
184 def service = execution.getVariable(prefix+"serviceType")
185 def customerId = execution.getVariable(prefix+"customerId")
186 def vpnId = execution.getVariable(prefix+"vpnId")
187 def vpnRt = execution.getVariable(prefix+"vpnRt")
188 def vpnService = execution.getVariable(prefix+"vpnService")
189 def vpnRegion = execution.getVariable(prefix+"vpnRegion")
190 def additionalInfo = ""
191 if("assign".equalsIgnoreCase(action)){
192 additionalInfo = """<vpn-data-list>
193 <vpn-id>${MsoUtils.xmlEscape(vpnId)}</vpn-id>
194 <vpn-rt>${MsoUtils.xmlEscape(vpnRt)}</vpn-rt>
195 <vpn-service>${MsoUtils.xmlEscape(vpnService)}</vpn-service>
196 <vpn-region>${MsoUtils.xmlEscape(vpnRegion)}</vpn-region>
198 }else if("activate".equalsIgnoreCase(action) || "delete".equalsIgnoreCase(action)){
199 def vniId = execution.getVariable(prefix+'vniId')
200 additionalInfo = "<vni-id>${MsoUtils.xmlEscape(vniId)}</vni-id>"
203 //Set Interface Status
204 def interfaceStatus = "DISABLE"
205 if("activate".equalsIgnoreCase(action)){
206 interfaceStatus = "ENABLE"
209 //Build SDNC Adapter Request
210 String sdncAdapterL3ToHLRequest = """
211 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
212 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
213 <sdncadapter:RequestHeader>
214 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
215 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
216 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
217 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
218 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
219 </sdncadapter:RequestHeader>
220 <sdncadapterworkflow:SDNCRequestData>
221 ${nnsRequestInformation}
222 ${serviceInformation}
223 <nbnc-request-information>
224 <service-type>${MsoUtils.xmlEscape(service)}</service-type>
225 <customer-id>${MsoUtils.xmlEscape(customerId)}</customer-id>
226 <interface-status>${MsoUtils.xmlEscape(interfaceStatus)}</interface-status>
228 </nbnc-request-information>
229 </sdncadapterworkflow:SDNCRequestData>
230 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutValueInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
231 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
233 sdncAdapterL3ToHLRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterL3ToHLRequest))
235 return sdncAdapterL3ToHLRequest
240 private void SDNCAdapterActivateRequest(DelegateExecution execution, String resultVar, String svcAction,
241 String svcOperation, String additionalData) {
242 def utils=new MsoUtils()
244 def prefix = execution.getVariable('prefix')
245 def request = taskProcessor.getVariable(execution, prefix+'Request')
246 def requestInformation = utils.getNodeXml(request, 'request-information', false)
247 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
248 def serviceParameters = utils.getNodeXml(request, 'service-parameters', false)
250 def requestId = execution.getVariable('testReqId') // for junits
252 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
255 def svcInstanceId = execution.getVariable("mso-service-instance-id")
256 def msoAction = 'gammainternet'
258 def timeoutInMinutes = UrnPropertiesReader.getVariable('mso.sdnc.timeout.firewall.minutes',execution)
260 def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution)
261 if (callbackUrl == null || callbackUrl.trim() == "") {
262 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
263 workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code?
266 def l2HomingInformation = utils.getNodeXml(serviceParameters, 'l2-homing-information', false)
267 def internetEvcAccessInformation = utils.getNodeXml(serviceParameters, 'internet-evc-access-information', false)
268 def vrLan = utils.getNodeXml(serviceParameters, 'vr-lan', false)
269 def upceVmsServiceInformation = utils.getNodeXml(serviceParameters, 'ucpe-vms-service-information', false)
272 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
273 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
274 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
275 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
276 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
277 def nnsUpceVmsServiceInformation = utils.removeXmlNamespaces(upceVmsServiceInformation)
279 if (additionalData == null) {
283 boolean isAic3 = execution.getVariable("isAic3")
286 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
289 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
293 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
294 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
295 <sdncadapter:RequestHeader>
296 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
297 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
298 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction>
299 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(svcOperation)}</sdncadapter:SvcOperation>
300 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
301 <sdncadapter:MsoAction>${MsoUtils.xmlEscape(msoAction)}</sdncadapter:MsoAction>
302 </sdncadapter:RequestHeader>
303 <sdncadapterworkflow:SDNCRequestData>
305 ${nnsRequestInformation}
306 ${nnsServiceInformation}
307 ${nnsl2HomingInformation}
308 ${nnsInternetEvcAccessInformation}
310 ${nnsUpceVmsServiceInformation}
311 </sdncadapterworkflow:SDNCRequestData>
312 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${MsoUtils.xmlEscape(timeoutInMinutes)}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
313 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
316 content = utils.removeXmlPreamble(utils.formatXML(content))
317 execution.setVariable(resultVar, content)
321 * Builds an SDNC "reserve" request and stores it in the specified execution
323 * @param execution the execution
324 * @param action the type of action: reserve, turnup, etc
325 * @param resultVar the execution variable in which the result will be stored
327 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar) {
328 sdncReservePrep(execution, action, resultVar, false)
332 * Builds an SDNC "reserve" request and stores it in the specified execution
334 * @param execution the execution
335 * @param action the type of action: reserve, turnup, etc
336 * @param resultVar the execution variable in which the result will be stored
337 * @param isAic3 boolean to indicate whether request is for AIC3.0
339 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar, boolean isAic3) {
340 sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3, this.taskProcessor)
344 * Builds a basic SDNC request and stores it in the specified execution variable.
345 * @param execution the execution
346 * @param resultVar the execution variable in which the result will be stored
347 * @param svcAction the svcAction element value
348 * @param svcOperation the svcOperation element value
349 * @param additionalData additional XML content to be inserted into the
350 * RequestData element (may be null)
352 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
353 String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) {
354 sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false, taskProcessor)
358 * Builds a basic SDNC request and stores it in the specified execution variable.
359 * @param execution the execution
360 * @param resultVar the execution variable in which the result will be stored
361 * @param svcAction the svcAction element value
362 * @param svcOperation the svcOperation element value
363 * @param additionalData additional XML content to be inserted into the RequestData element (may be null)
364 * @param isAic3 boolean to indicate whether request is for AIC3.0
366 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
367 String svcOperation, String additionalData, boolean isAic3, AbstractServiceTaskProcessor taskProcessor) {
368 def method = getClass().getSimpleName() + '.sdncPrep(' +
369 'execution=' + execution.getId() +
370 ', resultVar=' + resultVar +
371 ', svcAction=' + svcAction +
372 ', svcOperation=' + svcOperation +
373 ', additionalData=' + (additionalData == null ? "no" : "yes") +
376 msoLogger.trace('Entered ' + method)
377 MsoUtils utils = taskProcessor.utils
379 def prefix = execution.getVariable('prefix')
380 def request = taskProcessor.getVariable(execution, prefix+'Request')
381 def requestInformation = utils.getNodeXml(request, 'request-information', false)
382 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
383 def serviceParameters = utils.getChildNodes(request, 'service-parameters')
384 def requestAction = utils.getNodeText(request, 'request-action')
386 def timeoutInMinutes = UrnPropertiesReader.getVariable('mso.sdnc.timeout.firewall.minutes',execution)
388 def requestId = execution.getVariable('testReqId') // for junits
390 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
393 def svcInstanceId = execution.getVariable("mso-service-instance-id")
394 def msoAction = 'gammainternet'
396 def callbackUrl = (String)UrnPropertiesReader.getVariable('mso.workflow.sdncadapter.callback',execution)
397 if (callbackUrl == null || callbackUrl.trim() == "") {
398 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'mso:workflow:sdncadapter:callback URN is not set', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
399 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request")
402 def l2HomingInformation = utils.getNodeXml(request, 'l2-homing-information', false)
403 def internetEvcAccessInformation = utils.getNodeXml(request, 'internet-evc-access-information', false)
404 def vrLan = utils.getNodeXml(request, 'vr-lan', false)
405 def upceVmsServiceInfo = utils.getNodeXml(request, 'ucpe-vms-service-information', false)
406 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
408 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
409 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
410 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
411 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
412 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
413 def nnsUpceVmsServiceInfo = utils.removeXmlNamespaces(upceVmsServiceInfo)
414 def nnsVnfInformationList = utils.removeXmlNamespaces(vrLan)
415 def nnsinternetSvcChangeDetails = ""
417 if(requestAction!=null && requestAction.equals("ChangeLayer3ServiceProvRequest")){
418 def internetSvcChangeDetails = utils.removeXmlNamespaces(serviceParameters)
419 nnsinternetSvcChangeDetails = """<internet-service-change-details>
420 ${internetSvcChangeDetails}
421 </internet-service-change-details>"""
424 if (additionalData == null) {
429 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
432 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
437 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
438 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
439 <sdncadapter:RequestHeader>
440 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
441 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstanceId)}</sdncadapter:SvcInstanceId>
442 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(svcAction)}</sdncadapter:SvcAction>
443 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(svcOperation)}</sdncadapter:SvcOperation>
444 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
445 <sdncadapter:MsoAction>${MsoUtils.xmlEscape(msoAction)}</sdncadapter:MsoAction>
446 </sdncadapter:RequestHeader>
447 <sdncadapterworkflow:SDNCRequestData>
449 ${nnsRequestInformation}
450 ${nnsServiceInformation}
451 ${nnsl2HomingInformation}
452 ${nnsInternetEvcAccessInformation}
454 ${nnsUpceVmsServiceInfo}
455 ${nnsVnfInformationList}
456 ${nnsinternetSvcChangeDetails}
457 </sdncadapterworkflow:SDNCRequestData>
458 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
461 content = utils.removeXmlPreamble(utils.formatXML(content))
462 execution.setVariable(resultVar, content)
463 msoLogger.debug(resultVar + ' = ' + System.lineSeparator() + content)
465 msoLogger.trace('Exited ' + method)
466 } catch (BpmnError e) {
468 } catch (Exception e) {
469 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
470 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error")
474 public String updateHomingInfo(String homingInfo, String aicVersion) {
476 if(homingInfo == null || homingInfo.trim().length() == 0) {
477 newHomingInfo = "<l2-homing-information><aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
480 newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
485 * Builds a topology SDNC request and return String request.
486 * As V2 will use 1607-style request, region instead of aic clli code
487 * @param execution, the execution
488 * @param requestXML, the incoming request for the flow
489 * @param serviceInstanceId, the serviceIntance (if available)
490 * @param callbackUrl, the call back url
491 * @param action, the action element value
492 * @param requestAction the svcOperation element value
493 * @param cloudRegionId the aai's cloud-region-id
494 * @param networkId the aai's network-id
495 * @param additionalData additional XML content to be inserted into the
496 * RequestData element (may be null)
498 public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, L3Network queryAAIResponse, String additionalData) {
499 def utils=new MsoUtils()
501 // SNDC is expecting request Id for header as unique each call.
502 String hdrRequestId = ""
503 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
504 if (testHdrRequestId == null) {
505 hdrRequestId = UUID.randomUUID() // generate unique
507 hdrRequestId = testHdrRequestId
510 String requestId = ""
512 requestId = execution.getVariable("mso-request-id")
513 } catch (Exception ex) {
514 requestId = utils.getNodeText(requestXML, "request-id")
517 String aicCloudRegion = cloudRegionId
519 if (utils.nodeExists(requestXML, "tenant-id")) {
520 tenantId = utils.getNodeText(requestXML, "tenant-id")
522 String networkType = ""
523 if (utils.nodeExists(requestXML, "network-type")) {
524 networkType = utils.getNodeText(requestXML, "network-type")
527 // Replace/Use the value of network-type from aai query (vs input) during Delete Network flows.
528 if (queryAAIResponse != null) {
529 networkType = queryAAIResponse.getNetworkType()
532 String serviceId = ""
533 if (utils.nodeExists(requestXML, "service-id")) {
534 serviceId = utils.getNodeText(requestXML, "service-id")
536 String networkName = ""
537 // Replace/Use the value of network-name from aai query (vs input) if it was already set in AAI
538 if (queryAAIResponse != null) {
539 networkName = queryAAIResponse.getNetworkName()
541 if (networkName.isEmpty() && utils.nodeExists(requestXML, "network-name")) {
542 networkName = utils.getNodeText(requestXML, "network-name")
545 if (utils.nodeExists(requestXML, "source")) {
546 source = utils.getNodeText(requestXML, "source")
549 // get resourceLink from subflow execution variable
550 String serviceType = ""
551 String subscriberName = ""
552 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
553 if (siRelatedLink != null) {
555 int serviceStart = siRelatedLink.indexOf("service-subscription/")
556 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
557 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
558 serviceType = UriUtils.decode(serviceType,"UTF-8")
559 // get subscriber name
560 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
561 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
562 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
563 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
565 serviceType = execution.getVariable("serviceType")
566 subscriberName = execution.getVariable("subscriberName")
570 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
571 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
572 xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
573 xmlns:ns5="http://org.onap/so/request/types/v1">
574 <sdncadapter:RequestHeader>
575 <sdncadapter:RequestId>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
576 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
577 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
578 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
579 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
580 </sdncadapter:RequestHeader>
581 <sdncadapterworkflow:SDNCRequestData>
582 <request-information>
583 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
584 <request-action>${MsoUtils.xmlEscape(requestAction)}</request-action>
585 <source>${MsoUtils.xmlEscape(source)}</source>
586 <notification-url></notification-url>
587 <order-number></order-number>
588 <order-version></order-version>
589 </request-information>
590 <service-information>
591 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
592 <service-type>${MsoUtils.xmlEscape(serviceType)}</service-type>
593 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
594 <subscriber-name>${MsoUtils.xmlEscape(subscriberName)}</subscriber-name>
595 </service-information>
596 <network-request-information>
597 <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
598 <network-type>${MsoUtils.xmlEscape(networkType)}</network-type>
599 <network-name>${MsoUtils.xmlEscape(networkName)}</network-name>
600 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
601 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
602 </network-request-information>
603 </sdncadapterworkflow:SDNCRequestData>
604 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
610 * Builds a topology SDNC request and return String request.
611 * As V2 will use 1607-style request, region instead of aic clli code
612 * @param execution, the execution
613 * @param requestXML, the incoming request for the flow
614 * @param serviceInstanceId, the serviceIntance (if available)
615 * @param callbackUrl, the call back url
616 * @param action, the action element value
617 * @param requestAction the svcOperation element value
618 * @param cloudRegionId the aai's cloud-region-id
619 * @param networkId the aai's network-id
620 * @param additionalData additional XML content to be inserted into the
621 * RequestData element (may be null)
623 public String sdncTopologyRequestRsrc (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) {
624 def utils=new MsoUtils()
626 // SNDC is expecting request Id for header as unique each call.
627 String hdrRequestId = ""
628 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
629 if (testHdrRequestId == null) {
630 hdrRequestId = UUID.randomUUID() // generate unique
632 hdrRequestId = testHdrRequestId
635 String requestId = ""
636 String testRequestId = execution.getVariable("testMessageId") // for test purposes.
637 if (testRequestId == null) {
638 requestId = execution.getVariable("mso-request-id")
639 if (requestId == null) {
640 requestId = execution.getVariable("msoRequestId")
643 requestId = testRequestId
646 String aicCloudRegion = cloudRegionId
648 if (utils.nodeExists(requestXML, "tenant-id")) {
649 tenantId = utils.getNodeText(requestXML, "tenant-id")
651 String networkType = ""
652 if (utils.nodeExists(requestXML, "network-type")) {
653 networkType = utils.getNodeText(requestXML, "network-type")
656 String subscriptionServiceType = ""
657 if (utils.nodeExists(requestXML, "subscription-service-type")) {
658 subscriptionServiceType = utils.getNodeText(requestXML, "subscription-service-type")
661 String globalCustomerId = ""
662 if (utils.nodeExists(requestXML, "global-customer-id")) {
663 globalCustomerId = utils.getNodeText(requestXML, "global-customer-id")
666 String serviceId = ""
667 if (utils.nodeExists(requestXML, "service-id")) {
668 serviceId = utils.getNodeText(requestXML, "service-id")
670 String networkName = ""
671 if (utils.nodeExists(requestXML, "network-name")) {
672 networkName = utils.getNodeText(requestXML, "network-name")
675 if (utils.nodeExists(requestXML, "source")) {
676 source = utils.getNodeText(requestXML, "source")
679 // get resourceLink from subflow execution variable
680 String serviceType = ""
681 String subscriberName = ""
682 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
683 if (siRelatedLink != null) {
685 int serviceStart = siRelatedLink.indexOf("service-subscription/")
686 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
687 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
688 serviceType = UriUtils.decode(serviceType,"UTF-8")
689 // get subscriber name
690 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
691 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
692 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
693 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
696 // network-information from 'networkModelInfo' // verify the DB Catalog response
697 String networkModelInfo = utils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
698 String modelInvariantUuid = utils.getNodeText(networkModelInfo, "modelInvariantUuid") !=null ?
699 utils.getNodeText(networkModelInfo, "modelInvariantUuid") : ""
700 String modelCustomizationUuid = utils.getNodeText(networkModelInfo, "modelCustomizationUuid") !=null ?
701 utils.getNodeText(networkModelInfo, "modelCustomizationUuid") : ""
702 String modelUuid = utils.getNodeText(networkModelInfo, "modelUuid") !=null ?
703 utils.getNodeText(networkModelInfo, "modelUuid") : ""
704 String modelVersion = utils.getNodeText(networkModelInfo, "modelVersion") !=null ?
705 utils.getNodeText(networkModelInfo, "modelVersion") : ""
706 String modelName = utils.getNodeText(networkModelInfo, "modelName") !=null ?
707 utils.getNodeText(networkModelInfo, "modelName") : ""
709 // service-information from 'networkModelInfo' // verify the DB Catalog response
710 String serviceModelInfo = utils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","")
711 String serviceModelInvariantUuid = utils.getNodeText(serviceModelInfo, "modelInvariantUuid") !=null ?
712 utils.getNodeText(serviceModelInfo, "modelInvariantUuid") : ""
713 String serviceModelUuid = utils.getNodeText(serviceModelInfo, "modelUuid") !=null ?
714 utils.getNodeText(serviceModelInfo, "modelUuid") : ""
715 String serviceModelVersion = utils.getNodeText(serviceModelInfo, "modelVersion") !=null ?
716 utils.getNodeText(serviceModelInfo, "modelVersion") : ""
717 String serviceModelName = utils.getNodeText(serviceModelInfo, "modelName") !=null ?
718 utils.getNodeText(serviceModelInfo, "modelName") : ""
722 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
723 xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
724 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
725 <sdncadapter:RequestHeader>
726 <sdncadapter:RequestId>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
727 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
728 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
729 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
730 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
731 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
732 </sdncadapter:RequestHeader>
733 <sdncadapterworkflow:SDNCRequestData>
734 <request-information>
735 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
736 <request-action>${MsoUtils.xmlEscape(requestAction)}</request-action>
737 <source>${MsoUtils.xmlEscape(source)}</source>
738 <notification-url></notification-url>
739 <order-number></order-number>
740 <order-version></order-version>
741 </request-information>
742 <service-information>
743 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
744 <subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type>
745 <onap-model-information>
746 <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
747 <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
748 <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
749 <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
750 </onap-model-information>
751 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
752 <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
753 <subscriber-name>${MsoUtils.xmlEscape(subscriberName)}</subscriber-name>
754 </service-information>
755 <network-information>
756 <network-id>${MsoUtils.xmlEscape(networkId)}</network-id>
757 <network-type>${MsoUtils.xmlEscape(networkType)}</network-type>
758 <onap-model-information>
759 <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
760 <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
761 <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
762 <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
763 <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
764 </onap-model-information>
765 </network-information>
766 <network-request-input>
767 <network-name>${MsoUtils.xmlEscape(networkName)}</network-name>
768 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
769 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
770 <aic-clli></aic-clli>
771 <network-input-parameters/>
772 </network-request-input>
773 </sdncadapterworkflow:SDNCRequestData>
774 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
780 * Validates a workflow response.
781 * @param execution the execution
782 * @param responseVar the execution variable in which the response is stored
783 * @param workflowException the WorkflowException Object returned from sdnc call
785 public void validateSDNCResponse(DelegateExecution execution, String response, WorkflowException workflowException, boolean successIndicator){
786 msoLogger.debug("SDNC Response is: " + response)
787 msoLogger.debug("SuccessIndicator is: " + successIndicator)
790 def prefix = execution.getVariable('prefix')
791 execution.setVariable(prefix+'sdncResponseSuccess', false)
792 msoLogger.debug("Response" + ' = ' + (response == null ? "" : System.lineSeparator()) + response)
794 if (successIndicator){
795 if (response == null || response.trim().equals("")) {
796 msoLogger.debug(response + ' is empty');
797 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty")
800 // we need to peer into the request data for error
801 def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false)
802 def String decodedXml = sdncAdapterWorkflowResponse.replace('<?xml version="1.0" encoding="UTF-8"?>', "")
803 decodedXml = taskProcessor.utils.getNodeXml(response, 'RequestData')
804 msoLogger.debug("decodedXml:\n" + decodedXml)
806 int requestDataResponseCode = 200
807 def String requestDataResponseMessage = ''
810 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
811 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
812 } else if (taskProcessor.utils.nodeExists(sdncAdapterWorkflowResponse, "ResponseMessage")) {
813 requestDataResponseMessage = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseMessage")
816 msoLogger.debug('Error caught while decoding resposne ' + e.getMessage())
819 if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
820 msoLogger.debug("response-code node Exist ")
821 String code = taskProcessor.utils.getNodeText(decodedXml, "response-code")
822 if(code.isEmpty() || code.equals("")){
823 // if response-code is blank then Success
824 msoLogger.debug("response-code node is empty")
825 requestDataResponseCode = 0
827 requestDataResponseCode = code.toInteger()
828 msoLogger.debug("response-code is: " + requestDataResponseCode)
830 }else if(taskProcessor.utils.nodeExists(sdncAdapterWorkflowResponse, "ResponseCode")){
831 msoLogger.debug("ResponseCode node Exist ")
832 String code = taskProcessor.utils.getNodeText(sdncAdapterWorkflowResponse, "ResponseCode")
833 if(code.isEmpty() || code.equals("")){
834 // if ResponseCode blank then Success
835 msoLogger.debug("ResponseCode node is empty")
836 requestDataResponseCode = 0
838 requestDataResponseCode = code.toInteger()
839 msoLogger.debug("ResponseCode is: " + requestDataResponseCode)
842 msoLogger.debug("A Response Code DOES NOT Exist.")
843 // if a response code does not exist then Success
844 requestDataResponseCode = 0
848 execution.setVariable(prefix+'sdncRequestDataResponseCode', requestDataResponseCode.toString())
849 // if a response code is 0 or 2XX then Success
850 if ((requestDataResponseCode >= 200 && requestDataResponseCode <= 299) || requestDataResponseCode == 0) {
851 execution.setVariable(prefix+'sdncResponseSuccess', true)
852 msoLogger.debug("Setting sdncResponseSuccess to True ")
853 msoLogger.debug("Exited ValidateSDNCResponse Method")
855 ExceptionUtil exceptionUtil = new ExceptionUtil()
856 String convertedCode = exceptionUtil.MapSDNCResponseCodeToErrorCode(requestDataResponseCode.toString())
857 int convertedCodeInt = Integer.parseInt(convertedCode)
858 exceptionUtil.buildAndThrowWorkflowException(execution, convertedCodeInt, "Received error from SDN-C: " + requestDataResponseMessage)
862 //TODO proper handling of new, non numerical response codes in 1607 and new error handling for common API
863 requestDataResponseCode = 500
866 msoLogger.debug("SDNC callback response-code: " + requestDataResponseCode)
867 msoLogger.debug("SDNC callback response-message: " + requestDataResponseMessage)
871 msoLogger.debug('SDNCAdapter Subflow did NOT complete Successfully. SuccessIndicator is False. ')
872 if(workflowException != null){
873 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
875 //TODO : what error code and error message use here
876 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - SDNCAdapter Subflow did NOT complete successfully.")
880 } catch (BpmnError e) {
882 } catch (Exception e) {
883 msoLogger.debug('END of Validate SDNC Response')
884 exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error- Unable to validate SDNC Response ');
889 * Validates a workflow response.
890 * @param execution the execution
891 * @param responseVar the execution variable in which the response is stored
892 * @param responseCodeVar the execution variable in which the response code is stored
893 * @param errorResponseVar the execution variable in which the error response is stored
895 public void validateL3BondingSDNCResp(DelegateExecution execution, String response, WorkflowException workflowException, boolean success) {
896 def method = getClass().getSimpleName() + '.validateL3BondingSDNCResp(' +
897 'execution=' + execution.getId() +
898 ', response=' + response +
900 msoLogger.trace('Entered ' + method)
901 def prefix = execution.getVariable('prefix')
902 TrinityExceptionUtil trinityExceptionUtil = new TrinityExceptionUtil()
905 execution.setVariable(prefix+'sdncResponseSuccess', false)
907 msoLogger.debug("sdncAdapter Success Indicator is: " + success)
910 // we need to look inside the request data for error
911 def String callbackRequestData = taskProcessor.utils.getNodeXml(response, 'RequestData', false)
912 def String decodedXml = callbackRequestData
913 msoLogger.debug("decodedXml:\n" + decodedXml)
915 def requestDataResponseCode = '200'
916 def requestDataResponseMessage = ''
917 int intDataResponseCode = 200
919 if (taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
921 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "response-code"))
922 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
923 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
925 }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){
926 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "ResponseCode")).toInteger()
927 }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){
928 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(response, "ResponseCode")).toInteger()
929 requestDataResponseMessage = taskProcessor.utils.getNodeText(response, "ResponseMessage")
932 msoLogger.debug("SDNC callback response-code: " + requestDataResponseCode)
933 msoLogger.debug("SDNC callback response-message: " + requestDataResponseMessage)
935 // Get the AAI Status to determine if rollback is needed on ASSIGN
937 if (taskProcessor.utils.nodeExists(decodedXml, "aai-status")) {
938 aai_status = ((String) taskProcessor.utils.getNodeText(decodedXml, "aai-status"))
939 msoLogger.debug("SDNC sent AAI STATUS code: " + aai_status)
941 if (aai_status != null && !aai_status.equals("")) {
942 execution.setVariable(prefix+"AaiStatus",aai_status)
943 msoLogger.debug("Set variable " + prefix + "AaiStatus: " + execution.getVariable(prefix+"AaiStatus"))
946 // Get the result string to determine if rollback is needed on ASSIGN in Add Bonding flow only
948 if (taskProcessor.utils.nodeExists(decodedXml, "result")) {
949 sdncResult = ((String) taskProcessor.utils.getNodeText(decodedXml, "result"))
950 msoLogger.debug("SDNC sent result: " + sdncResult)
952 if (sdncResult != null && !sdncResult.equals("")) {
953 execution.setVariable(prefix+"SdncResult",sdncResult)
954 msoLogger.debug("Set variable " + prefix + "SdncResult: " + execution.getVariable(prefix+"SdncResult"))
958 intDataResponseCode = Integer.parseInt(String.valueOf(requestDataResponseCode))
960 intDataResponseCode = 400
963 msoLogger.debug("intDataResponseCode " + intDataResponseCode )
965 // if response-code is not Success (200, 201, etc) we need to throw an exception
966 if ((intDataResponseCode < 200 || intDataResponseCode > 299) && intDataResponseCode != 0) {
967 execution.setVariable(prefix+'ResponseCode', intDataResponseCode)
968 execution.setVariable("L3HLAB_rollback", true)
969 def msg = trinityExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution)
970 exceptionUtil.buildAndThrowWorkflowException(execution, intDataResponseCode, "Received error from SDN-C: " + msg)
974 msoLogger.warn(MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, 'sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ');
975 execution.setVariable("L3HLAB_rollback", true)
976 def msg = trinityExceptionUtil.intDataResponseCode(response, execution)
977 exceptionUtil.buildAndThrowWorkflowException(execution, intDataResponseCode, msg)
980 if (response == null || response.trim().equals("")) {
981 msoLogger.warn(MessageEnum.BPMN_GENERAL_WARNING, 'sdncAdapter workflow response is empty', "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, 'sdncAdapter workflow response is empty');;
982 execution.setVariable("L3HLAB_rollback", true)
983 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response " , execution)
984 exceptionUtil.buildAndThrowWorkflowException(execution, intResponseCode, msg)
987 execution.setVariable(prefix+'sdncResponseSuccess', true)
988 msoLogger.trace('Exited ' + method)
989 } catch (BpmnError e) {
991 } catch (Exception e) {
992 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
993 execution.setVariable(prefix+"ResponseCode",400)
994 execution.setVariable("L3HLAB_rollback", true)
995 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response: " + e.getMessage(), execution)
996 exceptionUtil.buildAndThrowWorkflowException(execution, 400, msg)
1000 public String modelInfoToEcompModelInformation(String jsonModelInfo) {
1001 String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid")
1002 String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid")
1003 if (modelUuid == null) {
1006 String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid")
1007 String modelCustomizationString = ""
1008 if (modelCustomizationUuid != null) {
1009 modelCustomizationString = "<model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>"
1011 String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion")
1012 if (modelVersion == null) {
1015 String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName")
1016 String ecompModelInformation =
1017 """<onap-model-information>
1018 <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
1019 <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
1020 ${modelCustomizationString}
1021 <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
1022 <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
1023 </onap-model-information>"""
1025 return ecompModelInformation