2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.common.scripts;
\r
23 import org.apache.commons.lang3.*
\r
24 import org.camunda.bpm.engine.delegate.BpmnError
\r
25 import org.camunda.bpm.engine.delegate.DelegateExecution
\r
27 import org.openecomp.mso.bpmn.core.WorkflowException
\r
28 import org.openecomp.mso.bpmn.core.json.JsonUtils;
\r
29 import org.springframework.web.util.UriUtils
\r
36 class SDNCAdapterUtils {
\r
38 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
39 JsonUtils jsonUtil = new JsonUtils()
\r
41 private AbstractServiceTaskProcessor taskProcessor
\r
43 public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
\r
44 this.taskProcessor = taskProcessor
\r
47 String SDNCAdapterFeatureRequest(DelegateExecution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
\r
49 def utils=new MsoUtils()
\r
51 def prefix = execution.getVariable('prefix')
\r
52 def request = taskProcessor.getVariable(execution, requestName)
\r
53 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
54 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
55 def featureInformation = utils.getNodeXml(request, 'feature-information', false)
\r
56 def featureParameters = utils.getNodeXml(request, 'feature-parameters', false)
\r
58 def requestId = execution.getVariable('testReqId') // for junits
\r
59 if(requestId==null){
\r
60 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
63 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
65 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
66 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
67 def nnsFeatureInformation = utils.removeXmlNamespaces(featureInformation)
\r
68 def nnsFeatureParameters = utils.removeXmlNamespaces(featureParameters)
\r
70 String sdncAdapterFeatureRequest = """
\r
71 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
72 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
73 <sdncadapter:RequestHeader>
\r
74 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
75 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
76 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
77 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
\r
78 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
79 </sdncadapter:RequestHeader>
\r
80 <sdncadapterworkflow:SDNCRequestData>
\r
81 ${nnsRequestInformation}
\r
82 ${nnsServiceInformation}
\r
83 ${nnsFeatureInformation}
\r
84 ${nnsFeatureParameters}
\r
85 </sdncadapterworkflow:SDNCRequestData>
\r
86 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
87 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
89 sdncAdapterFeatureRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterFeatureRequest))
\r
90 return sdncAdapterFeatureRequest
\r
93 String SDNCAdapterActivateVnfRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) {
\r
95 def utils=new MsoUtils()
\r
97 def prefix = execution.getVariable('prefix')
\r
98 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
99 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
100 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
101 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
\r
103 def requestId = execution.getVariable('testReqId') // for junits
\r
104 if(requestId==null){
\r
105 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
108 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
110 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
111 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
112 def nnsVnfInformationList = utils.removeXmlNamespaces(vnfInformationList)
\r
114 String sdncAdapterActivateVnfRequest = """
\r
115 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
116 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
117 <sdncadapter:RequestHeader>
\r
118 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
119 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
120 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
121 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
\r
122 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
123 <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
\r
124 </sdncadapter:RequestHeader>
\r
125 <sdncadapterworkflow:SDNCRequestData>
\r
126 ${nnsRequestInformation}
\r
127 ${nnsServiceInformation}
\r
128 ${nnsVnfInformationList}
\r
129 </sdncadapterworkflow:SDNCRequestData>
\r
130 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
131 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
133 sdncAdapterActivateVnfRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterActivateVnfRequest))
\r
134 return sdncAdapterActivateVnfRequest
\r
137 String SDNCAdapterL3ToHigherLayerRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
\r
139 def utils=new MsoUtils()
\r
141 def prefix = execution.getVariable('prefix')
\r
142 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
144 def requestInformation = """<request-information>
\r
145 <request-id>${execution.getVariable("mso-request-id")}</request-id>
\r
146 <request-action>torepl</request-action>
\r
147 <source>${execution.getVariable(prefix+"source")}</source>
\r
148 <notification-url>${execution.getVariable(prefix+"notificationUrl")}</notification-url>
\r
149 </request-information>"""
\r
151 // Change the value of the 'request-information'.'request-action' element
\r
152 def xml = new XmlSlurper().parseText(requestInformation)
\r
153 if("assign".equalsIgnoreCase(action)){
\r
154 xml.'request-action'.replaceBody('createTrinityBonding')
\r
155 }else if("activate".equalsIgnoreCase(action)){
\r
156 xml.'request-action'.replaceBody('activateTrinityBonding')
\r
157 }else if("delete".equalsIgnoreCase(action)){
\r
158 xml.'request-action'.replaceBody('deleteTrinityBonding')
\r
160 requestInformation = utils.removeXmlPreamble(groovy.xml.XmlUtil.serialize(xml))
\r
161 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
163 def requestId = execution.getVariable('testReqId') // for junits
\r
164 if(requestId==null){
\r
165 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
168 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
170 //Build Service Information
\r
171 // Send serviceName from CANOPI to sdnc for service-type
\r
172 def serviceInformation = """<service-information>
\r
173 <service-type>${execution.getVariable(prefix+"serviceName")}</service-type>
\r
174 <service-instance-id>${svcInstanceId}</service-instance-id>
\r
175 <subscriber-name>${execution.getVariable(prefix+"subscriberName")}</subscriber-name>
\r
176 <subscriber-global-id>${execution.getVariable(prefix+"subscriberGlobalId")}</subscriber-global-id>
\r
177 </service-information>"""
\r
179 //Build Additional Information - vpn or vni
\r
180 // Send serviceType from CANOPI to SDNC for nbnc-request-information service-type
\r
181 def service = execution.getVariable(prefix+"serviceType")
\r
182 def customerId = execution.getVariable(prefix+"customerId")
\r
183 def vpnId = execution.getVariable(prefix+"vpnId")
\r
184 def vpnRt = execution.getVariable(prefix+"vpnRt")
\r
185 def vpnService = execution.getVariable(prefix+"vpnService")
\r
186 def vpnRegion = execution.getVariable(prefix+"vpnRegion")
\r
187 def additionalInfo = ""
\r
188 if("assign".equalsIgnoreCase(action)){
\r
189 additionalInfo = """<vpn-data-list>
\r
190 <vpn-id>${vpnId}</vpn-id>
\r
191 <vpn-rt>${vpnRt}</vpn-rt>
\r
192 <vpn-service>${vpnService}</vpn-service>
\r
193 <vpn-region>${vpnRegion}</vpn-region>
\r
194 </vpn-data-list>"""
\r
195 }else if("activate".equalsIgnoreCase(action) || "delete".equalsIgnoreCase(action)){
\r
196 def vniId = execution.getVariable(prefix+'vniId')
\r
197 additionalInfo = "<vni-id>${vniId}</vni-id>"
\r
200 //Set Interface Status
\r
201 def interfaceStatus = "DISABLE"
\r
202 if("activate".equalsIgnoreCase(action)){
\r
203 interfaceStatus = "ENABLE"
\r
206 //Build SDNC Adapter Request
\r
207 String sdncAdapterL3ToHLRequest = """
\r
208 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
209 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
210 <sdncadapter:RequestHeader>
\r
211 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
212 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
213 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
214 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
\r
215 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
216 </sdncadapter:RequestHeader>
\r
217 <sdncadapterworkflow:SDNCRequestData>
\r
218 ${nnsRequestInformation}
\r
219 ${serviceInformation}
\r
220 <nbnc-request-information>
\r
221 <service-type>${service}</service-type>
\r
222 <customer-id>${customerId}</customer-id>
\r
223 <interface-status>${interfaceStatus}</interface-status>
\r
225 </nbnc-request-information>
\r
226 </sdncadapterworkflow:SDNCRequestData>
\r
227 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
228 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
230 sdncAdapterL3ToHLRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterL3ToHLRequest))
\r
232 return sdncAdapterL3ToHLRequest
\r
237 private void SDNCAdapterActivateRequest(DelegateExecution execution, String resultVar, String svcAction,
\r
239 String svcOperation, String additionalData) {
\r
240 def utils=new MsoUtils()
\r
242 def prefix = execution.getVariable('prefix')
\r
243 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
244 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
245 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
246 def serviceParameters = utils.getNodeXml(request, 'service-parameters', false)
\r
248 def requestId = execution.getVariable('testReqId') // for junits
\r
249 if(requestId==null){
\r
250 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
253 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
254 def msoAction = 'gammainternet'
\r
256 def timeoutInMinutes = execution.getVariable('URN_mso_sdnc_timeout_firewall_minutes')
\r
258 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
\r
259 if (callbackUrl == null || callbackUrl.trim() == "") {
\r
260 logError('mso:workflow:sdncadapter:callback URN is not set')
\r
261 workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code?
\r
264 def l2HomingInformation = utils.getNodeXml(serviceParameters, 'l2-homing-information', false)
\r
265 def internetEvcAccessInformation = utils.getNodeXml(serviceParameters, 'internet-evc-access-information', false)
\r
266 def vrLan = utils.getNodeXml(serviceParameters, 'vr-lan', false)
\r
267 def upceVmsServiceInformation = utils.getNodeXml(serviceParameters, 'ucpe-vms-service-information', false)
\r
270 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
271 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
272 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
\r
273 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
\r
274 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
\r
275 def nnsUpceVmsServiceInformation = utils.removeXmlNamespaces(upceVmsServiceInformation)
\r
277 if (additionalData == null) {
\r
278 additionalData = ""
\r
281 boolean isAic3 = execution.getVariable("isAic3")
\r
284 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
\r
287 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
\r
290 String content = """
\r
291 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
292 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
293 <sdncadapter:RequestHeader>
\r
294 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
295 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
296 <sdncadapter:SvcAction>${svcAction}</sdncadapter:SvcAction>
\r
297 <sdncadapter:SvcOperation>${svcOperation}</sdncadapter:SvcOperation>
\r
298 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
\r
299 <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
\r
300 </sdncadapter:RequestHeader>
\r
301 <sdncadapterworkflow:SDNCRequestData>
\r
303 ${nnsRequestInformation}
\r
304 ${nnsServiceInformation}
\r
305 ${nnsl2HomingInformation}
\r
306 ${nnsInternetEvcAccessInformation}
\r
308 ${nnsUpceVmsServiceInformation}
\r
309 </sdncadapterworkflow:SDNCRequestData>
\r
310 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
311 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
314 content = utils.removeXmlPreamble(utils.formatXML(content))
\r
315 execution.setVariable(resultVar, content)
\r
319 * Builds an SDNC "reserve" request and stores it in the specified execution
\r
321 * @param execution the execution
\r
322 * @param action the type of action: reserve, turnup, etc
\r
323 * @param resultVar the execution variable in which the result will be stored
\r
325 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar) {
\r
326 sdncReservePrep(execution, action, resultVar, false)
\r
330 * Builds an SDNC "reserve" request and stores it in the specified execution
\r
332 * @param execution the execution
\r
333 * @param action the type of action: reserve, turnup, etc
\r
334 * @param resultVar the execution variable in which the result will be stored
\r
335 * @param isAic3 boolean to indicate whether request is for AIC3.0
\r
337 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar, boolean isAic3) {
\r
339 sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3, this.taskProcessor)
\r
343 * Builds a basic SDNC request and stores it in the specified execution variable.
\r
344 * @param execution the execution
\r
345 * @param resultVar the execution variable in which the result will be stored
\r
346 * @param svcAction the svcAction element value
\r
347 * @param svcOperation the svcOperation element value
\r
348 * @param additionalData additional XML content to be inserted into the
\r
349 * RequestData element (may be null)
\r
351 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
\r
352 String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) {
\r
353 sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false, taskProcessor)
\r
357 * Builds a basic SDNC request and stores it in the specified execution variable.
\r
358 * @param execution the execution
\r
359 * @param resultVar the execution variable in which the result will be stored
\r
360 * @param svcAction the svcAction element value
\r
361 * @param svcOperation the svcOperation element value
\r
362 * @param additionalData additional XML content to be inserted into the RequestData element (may be null)
\r
363 * @param isAic3 boolean to indicate whether request is for AIC3.0
\r
365 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
\r
367 String svcOperation, String additionalData, boolean isAic3, AbstractServiceTaskProcessor taskProcessor) {
\r
368 def method = getClass().getSimpleName() + '.sdncPrep(' +
\r
369 'execution=' + execution.getId() +
\r
370 ', resultVar=' + resultVar +
\r
371 ', svcAction=' + svcAction +
\r
372 ', svcOperation=' + svcOperation +
\r
373 ', additionalData=' + (additionalData == null ? "no" : "yes") +
\r
376 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
377 taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled)
\r
378 MsoUtils utils = taskProcessor.utils
\r
380 def prefix = execution.getVariable('prefix')
\r
381 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
382 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
383 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
384 def serviceParameters = utils.getChildNodes(request, 'service-parameters')
\r
385 def requestAction = utils.getNodeText1(request, 'request-action')
\r
387 def timeoutInMinutes = execution.getVariable('URN_mso_sdnc_timeout_firewall_minutes')
\r
389 def requestId = execution.getVariable('testReqId') // for junits
\r
390 if(requestId==null){
\r
391 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
394 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
395 def msoAction = 'gammainternet'
\r
397 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
\r
398 if (callbackUrl == null || callbackUrl.trim() == "") {
\r
399 taskProcessor.logError('mso:workflow:sdncadapter:callback URN is not set')
\r
400 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request")
\r
403 def l2HomingInformation = utils.getNodeXml(request, 'l2-homing-information', false)
\r
404 def internetEvcAccessInformation = utils.getNodeXml(request, 'internet-evc-access-information', false)
\r
405 def vrLan = utils.getNodeXml(request, 'vr-lan', false)
\r
406 def upceVmsServiceInfo = utils.getNodeXml(request, 'ucpe-vms-service-information', false)
\r
407 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
\r
409 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
410 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
411 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
\r
412 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
\r
413 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
\r
414 def nnsUpceVmsServiceInfo = utils.removeXmlNamespaces(upceVmsServiceInfo)
\r
415 def nnsVnfInformationList = utils.removeXmlNamespaces(vrLan)
\r
416 def nnsinternetSvcChangeDetails = ""
\r
418 if(requestAction!=null && requestAction.equals("ChangeLayer3ServiceProvRequest")){
\r
419 def internetSvcChangeDetails = utils.removeXmlNamespaces(serviceParameters)
\r
420 nnsinternetSvcChangeDetails = """<internet-service-change-details>
\r
421 ${internetSvcChangeDetails}
\r
422 </internet-service-change-details>"""
\r
425 if (additionalData == null) {
\r
426 additionalData = ""
\r
430 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
\r
433 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
\r
437 String content = """
\r
438 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
439 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
440 <sdncadapter:RequestHeader>
\r
441 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
442 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
443 <sdncadapter:SvcAction>${svcAction}</sdncadapter:SvcAction>
\r
444 <sdncadapter:SvcOperation>${svcOperation}</sdncadapter:SvcOperation>
\r
445 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
\r
446 <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
\r
447 </sdncadapter:RequestHeader>
\r
448 <sdncadapterworkflow:SDNCRequestData>
\r
450 ${nnsRequestInformation}
\r
451 ${nnsServiceInformation}
\r
452 ${nnsl2HomingInformation}
\r
453 ${nnsInternetEvcAccessInformation}
\r
455 ${nnsUpceVmsServiceInfo}
\r
456 ${nnsVnfInformationList}
\r
457 ${nnsinternetSvcChangeDetails}
\r
458 </sdncadapterworkflow:SDNCRequestData>
\r
459 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
462 content = utils.removeXmlPreamble(utils.formatXML(content))
\r
463 execution.setVariable(resultVar, content)
\r
464 taskProcessor.logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
\r
466 taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled)
\r
467 } catch (BpmnError e) {
\r
469 } catch (Exception e) {
\r
470 taskProcessor.logError('Caught exception in ' + method, e)
\r
471 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error")
\r
475 public String updateHomingInfo(String homingInfo, String aicVersion) {
\r
476 String newHomingInfo
\r
477 if(homingInfo == null || homingInfo.trim().length() == 0) {
\r
478 newHomingInfo = "<l2-homing-information><aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
\r
481 newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
\r
486 * Builds a topology SDNC request and return String request.
\r
487 * As V2 will use 1607-style request, region instead of aic clli code
\r
488 * @param execution, the execution
\r
489 * @param requestXML, the incoming request for the flow
\r
490 * @param serviceInstanceId, the serviceIntance (if available)
\r
491 * @param callbackUrl, the call back url
\r
492 * @param action, the action element value
\r
493 * @param requestAction the svcOperation element value
\r
494 * @param cloudRegionId the aai's cloud-region-id
\r
495 * @param networkId the aai's network-id
\r
496 * @param additionalData additional XML content to be inserted into the
\r
497 * RequestData element (may be null)
\r
499 public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) {
\r
501 def utils=new MsoUtils()
\r
503 // SNDC is expecting request Id for header as unique each call.
\r
504 String hdrRequestId = ""
\r
505 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
\r
506 if (testHdrRequestId == null) {
\r
507 hdrRequestId = UUID.randomUUID() // generate unique
\r
509 hdrRequestId = testHdrRequestId
\r
512 String requestId = ""
\r
514 requestId = execution.getVariable("mso-request-id")
\r
515 } catch (Exception ex) {
\r
516 requestId = utils.getNodeText1(requestXML, "request-id")
\r
519 String aicCloudRegion = cloudRegionId
\r
520 String tenantId = ""
\r
521 if (utils.nodeExists(requestXML, "tenant-id")) {
\r
522 tenantId = utils.getNodeText1(requestXML, "tenant-id")
\r
524 String networkType = ""
\r
525 if (utils.nodeExists(requestXML, "network-type")) {
\r
526 networkType = utils.getNodeText1(requestXML, "network-type")
\r
529 // Replace/Use the value of network-type from aai query (vs input) during Delete Network flows.
\r
530 if (queryAAIResponse != null) {
\r
531 networkType = utils.getNodeText1(queryAAIResponse, "network-type")
\r
534 String serviceId = ""
\r
535 if (utils.nodeExists(requestXML, "service-id")) {
\r
536 serviceId = utils.getNodeText1(requestXML, "service-id")
\r
538 String networkName = ""
\r
539 if (utils.nodeExists(requestXML, "network-name")) {
\r
540 networkName = utils.getNodeText1(requestXML, "network-name")
\r
543 if (utils.nodeExists(requestXML, "source")) {
\r
544 source = utils.getNodeText1(requestXML, "source")
\r
547 // get resourceLink from subflow execution variable
\r
548 String serviceType = ""
\r
549 String subscriberName = ""
\r
550 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
\r
551 if (siRelatedLink != null) {
\r
552 // get service type
\r
553 int serviceStart = siRelatedLink.indexOf("service-subscription/")
\r
554 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
\r
555 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
\r
556 serviceType = UriUtils.decode(serviceType,"UTF-8")
\r
557 // get subscriber name
\r
558 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
\r
559 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
\r
560 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
\r
561 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
\r
565 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
566 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
\r
567 xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"
\r
568 xmlns:ns5="http://org.openecomp/mso/request/types/v1">
\r
569 <sdncadapter:RequestHeader>
\r
570 <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
\r
571 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
\r
572 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
573 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
\r
574 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
\r
575 </sdncadapter:RequestHeader>
\r
576 <sdncadapterworkflow:SDNCRequestData>
\r
577 <request-information>
\r
578 <request-id>${requestId}</request-id>
\r
579 <request-action>${requestAction}</request-action>
\r
580 <source>${source}</source>
\r
581 <notification-url></notification-url>
\r
582 <order-number></order-number>
\r
583 <order-version></order-version>
\r
584 </request-information>
\r
585 <service-information>
\r
586 <service-id>${serviceId}</service-id>
\r
587 <service-type>${serviceType}</service-type>
\r
588 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
589 <subscriber-name>${subscriberName}</subscriber-name>
\r
590 </service-information>
\r
591 <network-request-information>
\r
592 <network-id>${networkId}</network-id>
\r
593 <network-type>${networkType}</network-type>
\r
594 <network-name>${networkName}</network-name>
\r
595 <tenant>${tenantId}</tenant>
\r
596 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
\r
597 </network-request-information>
\r
598 </sdncadapterworkflow:SDNCRequestData>
\r
599 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
\r
605 * Builds a topology SDNC request and return String request.
\r
606 * As V2 will use 1607-style request, region instead of aic clli code
\r
607 * @param execution, the execution
\r
608 * @param requestXML, the incoming request for the flow
\r
609 * @param serviceInstanceId, the serviceIntance (if available)
\r
610 * @param callbackUrl, the call back url
\r
611 * @param action, the action element value
\r
612 * @param requestAction the svcOperation element value
\r
613 * @param cloudRegionId the aai's cloud-region-id
\r
614 * @param networkId the aai's network-id
\r
615 * @param additionalData additional XML content to be inserted into the
\r
616 * RequestData element (may be null)
\r
618 public String sdncTopologyRequestRsrc (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) {
\r
620 def utils=new MsoUtils()
\r
622 // SNDC is expecting request Id for header as unique each call.
\r
623 String hdrRequestId = ""
\r
624 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
\r
625 if (testHdrRequestId == null) {
\r
626 hdrRequestId = UUID.randomUUID() // generate unique
\r
628 hdrRequestId = testHdrRequestId
\r
631 String requestId = ""
\r
632 String testRequestId = execution.getVariable("testMessageId") // for test purposes.
\r
633 if (testRequestId == null) {
\r
634 requestId = execution.getVariable("mso-request-id")
\r
635 if (requestId == null) {
\r
636 requestId = execution.getVariable("msoRequestId")
\r
639 requestId = testRequestId
\r
642 String aicCloudRegion = cloudRegionId
\r
643 String tenantId = ""
\r
644 if (utils.nodeExists(requestXML, "tenant-id")) {
\r
645 tenantId = utils.getNodeText1(requestXML, "tenant-id")
\r
647 String networkType = ""
\r
648 if (utils.nodeExists(requestXML, "network-type")) {
\r
649 networkType = utils.getNodeText1(requestXML, "network-type")
\r
652 String subscriptionServiceType = ""
\r
653 if (utils.nodeExists(requestXML, "subscription-service-type")) {
\r
654 subscriptionServiceType = utils.getNodeText1(requestXML, "subscription-service-type")
\r
657 String globalCustomerId = ""
\r
658 if (utils.nodeExists(requestXML, "global-customer-id")) {
\r
659 globalCustomerId = utils.getNodeText1(requestXML, "global-customer-id")
\r
662 String serviceId = ""
\r
663 if (utils.nodeExists(requestXML, "service-id")) {
\r
664 serviceId = utils.getNodeText1(requestXML, "service-id")
\r
666 String networkName = ""
\r
667 if (utils.nodeExists(requestXML, "network-name")) {
\r
668 networkName = utils.getNodeText1(requestXML, "network-name")
\r
671 if (utils.nodeExists(requestXML, "source")) {
\r
672 source = utils.getNodeText1(requestXML, "source")
\r
675 // get resourceLink from subflow execution variable
\r
676 String serviceType = ""
\r
677 String subscriberName = ""
\r
678 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
\r
679 if (siRelatedLink != null) {
\r
680 // get service type
\r
681 int serviceStart = siRelatedLink.indexOf("service-subscription/")
\r
682 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
\r
683 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
\r
684 serviceType = UriUtils.decode(serviceType,"UTF-8")
\r
685 // get subscriber name
\r
686 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
\r
687 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
\r
688 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
\r
689 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
\r
692 // network-information from 'networkModelInfo' // verify the DB Catalog response
\r
693 String networkModelInfo = utils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
\r
694 String modelInvariantUuid = utils.getNodeText1(networkModelInfo, "modelInvariantUuid") !=null ?
\r
695 utils.getNodeText1(networkModelInfo, "modelInvariantUuid") : ""
\r
696 String modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") !=null ?
\r
697 utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") : ""
\r
698 String modelUuid = utils.getNodeText1(networkModelInfo, "modelUuid") !=null ?
\r
699 utils.getNodeText1(networkModelInfo, "modelUuid") : ""
\r
700 String modelVersion = utils.getNodeText1(networkModelInfo, "modelVersion") !=null ?
\r
701 utils.getNodeText1(networkModelInfo, "modelVersion") : ""
\r
702 String modelName = utils.getNodeText1(networkModelInfo, "modelName") !=null ?
\r
703 utils.getNodeText1(networkModelInfo, "modelName") : ""
\r
705 // service-information from 'networkModelInfo' // verify the DB Catalog response
\r
706 String serviceModelInfo = utils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","")
\r
707 String serviceModelInvariantUuid = utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") !=null ?
\r
708 utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") : ""
\r
709 String serviceModelUuid = utils.getNodeText1(serviceModelInfo, "modelUuid") !=null ?
\r
710 utils.getNodeText1(serviceModelInfo, "modelUuid") : ""
\r
711 String serviceModelVersion = utils.getNodeText1(serviceModelInfo, "modelVersion") !=null ?
\r
712 utils.getNodeText1(serviceModelInfo, "modelVersion") : ""
\r
713 String serviceModelName = utils.getNodeText1(serviceModelInfo, "modelName") !=null ?
\r
714 utils.getNodeText1(serviceModelInfo, "modelName") : ""
\r
718 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
719 xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"
\r
720 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
\r
721 <sdncadapter:RequestHeader>
\r
722 <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
\r
723 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
\r
724 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
725 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
\r
726 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
\r
727 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
\r
728 </sdncadapter:RequestHeader>
\r
729 <sdncadapterworkflow:SDNCRequestData>
\r
730 <request-information>
\r
731 <request-id>${requestId}</request-id>
\r
732 <request-action>${requestAction}</request-action>
\r
733 <source>${source}</source>
\r
734 <notification-url></notification-url>
\r
735 <order-number></order-number>
\r
736 <order-version></order-version>
\r
737 </request-information>
\r
738 <service-information>
\r
739 <service-id>${serviceId}</service-id>
\r
740 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
\r
741 <onap-model-information>
\r
742 <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid>
\r
743 <model-uuid>${serviceModelUuid}</model-uuid>
\r
744 <model-version>${serviceModelVersion}</model-version>
\r
745 <model-name>${serviceModelName}</model-name>
\r
746 </onap-model-information>
\r
747 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
748 <global-customer-id>${globalCustomerId}</global-customer-id>
\r
749 <subscriber-name>${subscriberName}</subscriber-name>
\r
750 </service-information>
\r
751 <network-information>
\r
752 <network-id>${networkId}</network-id>
\r
753 <network-type>${networkType}</network-type>
\r
754 <onap-model-information>
\r
755 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
\r
756 <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>
\r
757 <model-uuid>${modelUuid}</model-uuid>
\r
758 <model-version>${modelVersion}</model-version>
\r
759 <model-name>${modelName}</model-name>
\r
760 </onap-model-information>
\r
761 </network-information>
\r
762 <network-request-input>
\r
763 <network-name>${networkName}</network-name>
\r
764 <tenant>${tenantId}</tenant>
\r
765 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
\r
766 <aic-clli></aic-clli>
\r
767 <network-input-parameters/>
\r
768 </network-request-input>
\r
769 </sdncadapterworkflow:SDNCRequestData>
\r
770 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
\r
776 * Validates a workflow response.
\r
777 * @param execution the execution
\r
778 * @param responseVar the execution variable in which the response is stored
\r
779 * @param workflowException the WorkflowException Object returned from sdnc call
\r
781 public void validateSDNCResponse(DelegateExecution execution, String response, WorkflowException workflowException, boolean successIndicator){
\r
783 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
784 taskProcessor.utils.log("DEBUG", "SDNC Response is: " + response, isDebugLogEnabled)
\r
785 taskProcessor.utils.log("DEBUG", "SuccessIndicator is: " + successIndicator, isDebugLogEnabled)
\r
788 def prefix = execution.getVariable('prefix')
\r
789 execution.setVariable(prefix+'sdncResponseSuccess', false)
\r
790 taskProcessor.utils.log("DEBUG", "Response" + ' = ' + (response == null ? "" : System.lineSeparator()) + response, isDebugLogEnabled)
\r
792 if (successIndicator){
\r
793 if (response == null || response.trim().equals("")) {
\r
794 taskProcessor.utils.log("DEBUG", response + ' is empty');
\r
795 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty")
\r
798 // we need to peer into the request data for error
\r
799 def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false)
\r
800 def String decodedXml = decodeXML(sdncAdapterWorkflowResponse).replace('<?xml version="1.0" encoding="UTF-8"?>', "")
\r
802 // change '&' to "& (if present as data, ex: subscriber-name = 'FOUR SEASONS HEATING & COOLING_8310006378683'
\r
803 decodedXml = decodedXml.replace("&", "&")
\r
805 taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled)
\r
807 int requestDataResponseCode = 200
\r
808 def String requestDataResponseMessage = ''
\r
811 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
\r
812 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
\r
813 } else if (taskProcessor.utils.nodeExists(decodedXml, "ResponseMessage")) {
\r
814 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "ResponseMessage")
\r
816 }catch(Exception e){
\r
817 taskProcessor.utils.log("DEBUG", 'Error caught while decoding resposne ' + e.getMessage(), isDebugLogEnabled)
\r
820 if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
\r
821 taskProcessor.utils.log("DEBUG","response-code node Exist ", isDebugLogEnabled)
\r
822 String code = taskProcessor.utils.getNodeText1(decodedXml, "response-code")
\r
823 if(code.isEmpty() || code.equals("")){
\r
824 // if response-code is blank then Success
\r
825 taskProcessor.utils.log("DEBUG","response-code node is empty", isDebugLogEnabled)
\r
826 requestDataResponseCode = 0
\r
828 requestDataResponseCode = code.toInteger()
\r
829 taskProcessor.utils.log("DEBUG","response-code is: " + requestDataResponseCode, isDebugLogEnabled)
\r
831 }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){
\r
832 taskProcessor.utils.log("DEBUG","ResponseCode node Exist ", isDebugLogEnabled)
\r
833 String code = taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode")
\r
834 if(code.isEmpty() || code.equals("")){
\r
835 // if ResponseCode blank then Success
\r
836 taskProcessor.utils.log("DEBUG","ResponseCode node is empty", isDebugLogEnabled)
\r
837 requestDataResponseCode = 0
\r
839 requestDataResponseCode = code.toInteger()
\r
840 taskProcessor.utils.log("DEBUG","ResponseCode is: " + requestDataResponseCode, isDebugLogEnabled)
\r
843 taskProcessor.utils.log("DEBUG","A Response Code DOES NOT Exist.", isDebugLogEnabled)
\r
844 // if a response code does not exist then Success
\r
845 requestDataResponseCode = 0
\r
849 execution.setVariable(prefix+'sdncRequestDataResponseCode', requestDataResponseCode.toString())
\r
850 // if a response code is 0 or 2XX then Success
\r
851 if ((requestDataResponseCode >= 200 && requestDataResponseCode <= 299) || requestDataResponseCode == 0) {
\r
852 execution.setVariable(prefix+'sdncResponseSuccess', true)
\r
853 taskProcessor.utils.log("DEBUG", "Setting sdncResponseSuccess to True ", isDebugLogEnabled)
\r
854 taskProcessor.utils.log("DEBUG", "Exited ValidateSDNCResponse Method", isDebugLogEnabled)
\r
856 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
857 String convertedCode = exceptionUtil.MapSDNCResponseCodeToErrorCode(requestDataResponseCode.toString())
\r
858 int convertedCodeInt = Integer.parseInt(convertedCode)
\r
859 exceptionUtil.buildAndThrowWorkflowException(execution, convertedCodeInt, "Received error from SDN-C: " + requestDataResponseMessage)
\r
862 }catch(Exception e){
\r
863 //TODO proper handling of new, non numerical response codes in 1607 and new error handling for common API
\r
864 requestDataResponseCode = 500
\r
867 taskProcessor.utils.log("DEBUG", "SDNC callback response-code: " + requestDataResponseCode, isDebugLogEnabled)
\r
868 taskProcessor.utils.log("DEBUG", "SDNC callback response-message: " + requestDataResponseMessage, isDebugLogEnabled)
\r
872 taskProcessor.utils.log("DEBUG", 'SDNCAdapter Subflow did NOT complete Successfully. SuccessIndicator is False. ')
\r
873 if(workflowException != null){
\r
874 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
876 //TODO : what error code and error message use here
\r
877 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - SDNCAdapter Subflow did NOT complete successfully.")
\r
881 } catch (BpmnError e) {
\r
883 } catch (Exception e) {
\r
884 taskProcessor.utils.log("DEBUG", 'END of Validate SDNC Response', isDebugLogEnabled)
\r
885 exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error- Unable to validate SDNC Response ');
\r
890 * Validates a workflow response.
\r
891 * @param execution the execution
\r
892 * @param responseVar the execution variable in which the response is stored
\r
893 * @param responseCodeVar the execution variable in which the response code is stored
\r
894 * @param errorResponseVar the execution variable in which the error response is stored
\r
896 public void validateL3BondingSDNCResp(DelegateExecution execution, String response, WorkflowException workflowException, boolean success) {
\r
898 def method = getClass().getSimpleName() + '.validateL3BondingSDNCResp(' +
\r
899 'execution=' + execution.getId() +
\r
900 ', response=' + response +
\r
902 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
903 taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled)
\r
904 def prefix = execution.getVariable('prefix')
\r
905 TrinityExceptionUtil trinityExceptionUtil = new TrinityExceptionUtil()
\r
908 execution.setVariable(prefix+'sdncResponseSuccess', false)
\r
910 taskProcessor.utils.log("sdncAdapter Success Indicator is: " + success, isDebugLogEnabled)
\r
913 // we need to look inside the request data for error
\r
914 def String callbackRequestData = taskProcessor.utils.getNodeXml(response, 'RequestData', false)
\r
915 def String decodedXml = decodeXML(callbackRequestData)
\r
916 taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled)
\r
918 def requestDataResponseCode = '200'
\r
919 def requestDataResponseMessage = ''
\r
920 int intDataResponseCode = 200
\r
922 if (taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
\r
924 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "response-code"))
\r
925 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
\r
926 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
\r
928 }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){
\r
929 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode")).toInteger()
\r
930 }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){
\r
931 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText1(response, "ResponseCode")).toInteger()
\r
932 requestDataResponseMessage = taskProcessor.utils.getNodeText(response, "ResponseMessage")
\r
935 taskProcessor.utils.log("DEBUG", "SDNC callback response-code: " + requestDataResponseCode, isDebugLogEnabled)
\r
936 taskProcessor.utils.log("DEBUG", "SDNC callback response-message: " + requestDataResponseMessage, isDebugLogEnabled)
\r
938 // Get the AAI Status to determine if rollback is needed on ASSIGN
\r
939 def aai_status = ''
\r
940 if (taskProcessor.utils.nodeExists(decodedXml, "aai-status")) {
\r
941 aai_status = ((String) taskProcessor.utils.getNodeText(decodedXml, "aai-status"))
\r
942 taskProcessor.utils.log("DEBUG", "SDNC sent AAI STATUS code: " + aai_status, isDebugLogEnabled)
\r
944 if (aai_status != null && !aai_status.equals("")) {
\r
945 execution.setVariable(prefix+"AaiStatus",aai_status)
\r
946 taskProcessor.utils.log("DEBUG", "Set variable " + prefix + "AaiStatus: " + execution.getVariable(prefix+"AaiStatus"), isDebugLogEnabled)
\r
949 // Get the result string to determine if rollback is needed on ASSIGN in Add Bonding flow only
\r
950 def sdncResult = ''
\r
951 if (taskProcessor.utils.nodeExists(decodedXml, "result")) {
\r
952 sdncResult = ((String) taskProcessor.utils.getNodeText(decodedXml, "result"))
\r
953 taskProcessor.utils.log("DEBUG", "SDNC sent result: " + sdncResult, isDebugLogEnabled)
\r
955 if (sdncResult != null && !sdncResult.equals("")) {
\r
956 execution.setVariable(prefix+"SdncResult",sdncResult)
\r
957 taskProcessor.utils.log("DEBUG", "Set variable " + prefix + "SdncResult: " + execution.getVariable(prefix+"SdncResult"), isDebugLogEnabled)
\r
961 intDataResponseCode = Integer.parseInt(String.valueOf(requestDataResponseCode))
\r
962 }catch(Exception e){
\r
963 intDataResponseCode = 400
\r
966 taskProcessor.utils.log("DEBUG", "intDataResponseCode " + intDataResponseCode , isDebugLogEnabled)
\r
968 // if response-code is not Success (200, 201, etc) we need to throw an exception
\r
969 if ((intDataResponseCode < 200 || intDataResponseCode > 299) && intDataResponseCode != 0) {
\r
970 execution.setVariable(prefix+'ResponseCode', intDataResponseCode)
\r
971 execution.setVariable("L3HLAB_rollback", true)
\r
972 def msg = trinityExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution)
\r
973 exceptionUtil.buildAndThrowWorkflowException(execution, intDataResponseCode, "Received error from SDN-C: " + msg)
\r
977 taskProcessor.logWarn('sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ')
\r
978 execution.setVariable("L3HLAB_rollback", true)
\r
979 def msg = trinityExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution)
\r
980 exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, msg)
\r
983 if (response == null || response.trim().equals("")) {
\r
984 taskProcessor.logWarn('sdncAdapter workflow response is empty');
\r
985 execution.setVariable("L3HLAB_rollback", true)
\r
986 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response " , execution)
\r
987 exceptionUtil.buildAndThrowWorkflowException(execution, intResponseCode, msg)
\r
990 execution.setVariable(prefix+'sdncResponseSuccess', true)
\r
991 taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled)
\r
992 } catch (BpmnError e) {
\r
994 } catch (Exception e) {
\r
995 taskProcessor.logError('Caught exception in ' + method, e)
\r
996 execution.setVariable(prefix+"ResponseCode",400)
\r
997 execution.setVariable("L3HLAB_rollback", true)
\r
998 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response: " + e.getMessage(), execution)
\r
999 exceptionUtil.buildAndThrowWorkflowException(execution, 400, msg)
\r
1003 public String modelInfoToEcompModelInformation(String jsonModelInfo) {
\r
1004 String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid")
\r
1005 String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid")
\r
1006 if (modelUuid == null) {
\r
1009 String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid")
\r
1010 String modelCustomizationString = ""
\r
1011 if (modelCustomizationUuid != null) {
\r
1012 modelCustomizationString = "<model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>"
\r
1014 String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion")
\r
1015 if (modelVersion == null) {
\r
1018 String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName")
\r
1019 String ecompModelInformation =
\r
1020 """<onap-model-information>
\r
1021 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
\r
1022 <model-uuid>${modelUuid}</model-uuid>
\r
1023 ${modelCustomizationString}
\r
1024 <model-version>${modelVersion}</model-version>
\r
1025 <model-name>${modelName}</model-name>
\r
1026 </onap-model-information>"""
\r
1028 return ecompModelInformation
\r
1032 * Decode XML - replace & < and > with '&', '<' and '>'
\r
1033 * @param xml - the xml to be decoded
\r
1035 private String decodeXML(String xml) {
\r
1036 def String decodedXml = xml.replaceAll("&", "&")
\r
1037 decodedXml = decodedXml.replaceAll("<", "<")
\r
1038 decodedXml = decodedXml.replaceAll(">", ">")
\r