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\r
26 import org.openecomp.mso.bpmn.core.WorkflowException
\r
27 import org.openecomp.mso.bpmn.core.json.JsonUtils;
\r
28 import org.springframework.web.util.UriUtils
\r
35 class SDNCAdapterUtils {
\r
37 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
38 JsonUtils jsonUtil = new JsonUtils()
\r
40 private AbstractServiceTaskProcessor taskProcessor
\r
42 public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
\r
43 this.taskProcessor = taskProcessor
\r
46 String SDNCAdapterFeatureRequest(DelegateExecution execution, String requestName, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
\r\r
47 def utils=new MsoUtils()
\r
49 def prefix = execution.getVariable('prefix')
\r
50 def request = taskProcessor.getVariable(execution, requestName)
\r
51 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
52 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
53 def featureInformation = utils.getNodeXml(request, 'feature-information', false)
\r
54 def featureParameters = utils.getNodeXml(request, 'feature-parameters', false)
\r
56 def requestId = execution.getVariable('testReqId') // for junits
\r
57 if(requestId==null){
\r
58 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
61 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
63 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
64 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
65 def nnsFeatureInformation = utils.removeXmlNamespaces(featureInformation)
\r
66 def nnsFeatureParameters = utils.removeXmlNamespaces(featureParameters)
\r
68 String sdncAdapterFeatureRequest = """
\r
69 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
70 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
71 <sdncadapter:RequestHeader>
\r
72 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
73 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
74 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
75 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
\r
76 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
77 </sdncadapter:RequestHeader>
\r
78 <sdncadapterworkflow:SDNCRequestData>
\r
79 ${nnsRequestInformation}
\r
80 ${nnsServiceInformation}
\r
81 ${nnsFeatureInformation}
\r
82 ${nnsFeatureParameters}
\r
83 </sdncadapterworkflow:SDNCRequestData>
\r
84 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
85 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
87 sdncAdapterFeatureRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterFeatureRequest))
\r
88 return sdncAdapterFeatureRequest
\r
91 String SDNCAdapterActivateVnfRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String msoAction, String timeoutValueInMinutes) {
\r\r
92 def utils=new MsoUtils()
\r
94 def prefix = execution.getVariable('prefix')
\r
95 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
96 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
97 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
98 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
\r
100 def requestId = execution.getVariable('testReqId') // for junits
\r
101 if(requestId==null){
\r
102 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
105 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
107 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
108 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
109 def nnsVnfInformationList = utils.removeXmlNamespaces(vnfInformationList)
\r
111 String sdncAdapterActivateVnfRequest = """
\r
112 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
113 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
114 <sdncadapter:RequestHeader>
\r
115 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
116 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
117 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
118 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
\r
119 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
120 <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
\r
121 </sdncadapter:RequestHeader>
\r
122 <sdncadapterworkflow:SDNCRequestData>
\r
123 ${nnsRequestInformation}
\r
124 ${nnsServiceInformation}
\r
125 ${nnsVnfInformationList}
\r
126 </sdncadapterworkflow:SDNCRequestData>
\r
127 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
128 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
130 sdncAdapterActivateVnfRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterActivateVnfRequest))
\r
131 return sdncAdapterActivateVnfRequest
\r
134 String SDNCAdapterL3ToHigherLayerRequest(DelegateExecution execution, String action, String callbackURL, String serviceOperation, String timeoutValueInMinutes) {
\r\r
135 def utils=new MsoUtils()
\r
137 def prefix = execution.getVariable('prefix')
\r
138 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
140 def requestInformation = """<request-information>
\r
141 <request-id>${execution.getVariable("mso-request-id")}</request-id>
\r
142 <request-action>torepl</request-action>
\r
143 <source>${execution.getVariable(prefix+"source")}</source>
\r
144 <notification-url>${execution.getVariable(prefix+"notificationUrl")}</notification-url>
\r
145 </request-information>"""
\r
147 // Change the value of the 'request-information'.'request-action' element
\r
148 def xml = new XmlSlurper().parseText(requestInformation)
\r
149 if("assign".equalsIgnoreCase(action)){
\r
150 xml.'request-action'.replaceBody('createTrinityBonding')
\r
151 }else if("activate".equalsIgnoreCase(action)){
\r
152 xml.'request-action'.replaceBody('activateTrinityBonding')
\r
153 }else if("delete".equalsIgnoreCase(action)){
\r
154 xml.'request-action'.replaceBody('deleteTrinityBonding')
\r
156 requestInformation = utils.removeXmlPreamble(groovy.xml.XmlUtil.serialize(xml))
\r
157 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
159 def requestId = execution.getVariable('testReqId') // for junits
\r
160 if(requestId==null){
\r
161 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
164 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
166 //Build Service Information
\r
167 // Send serviceName from CANOPI to sdnc for service-type
\r
168 def serviceInformation = """<service-information>
\r
169 <service-type>${execution.getVariable(prefix+"serviceName")}</service-type>
\r
170 <service-instance-id>${svcInstanceId}</service-instance-id>
\r
171 <subscriber-name>${execution.getVariable(prefix+"subscriberName")}</subscriber-name>
\r
172 <subscriber-global-id>${execution.getVariable(prefix+"subscriberGlobalId")}</subscriber-global-id>
\r
173 </service-information>"""
\r
175 //Build Additional Information - vpn or vni
\r
176 // Send serviceType from CANOPI to SDNC for nbnc-request-information service-type
\r
177 def service = execution.getVariable(prefix+"serviceType")
\r
178 def customerId = execution.getVariable(prefix+"customerId")
\r
179 def vpnId = execution.getVariable(prefix+"vpnId")
\r
180 def vpnRt = execution.getVariable(prefix+"vpnRt")
\r
181 def vpnService = execution.getVariable(prefix+"vpnService")
\r
182 def vpnRegion = execution.getVariable(prefix+"vpnRegion")
\r
183 def additionalInfo = ""
\r
184 if("assign".equalsIgnoreCase(action)){
\r
185 additionalInfo = """<vpn-data-list>
\r
186 <vpn-id>${vpnId}</vpn-id>
\r
187 <vpn-rt>${vpnRt}</vpn-rt>
\r
188 <vpn-service>${vpnService}</vpn-service>
\r
189 <vpn-region>${vpnRegion}</vpn-region>
\r
190 </vpn-data-list>"""
\r
191 }else if("activate".equalsIgnoreCase(action) || "delete".equalsIgnoreCase(action)){
\r
192 def vniId = execution.getVariable(prefix+'vniId')
\r
193 additionalInfo = "<vni-id>${vniId}</vni-id>"
\r
196 //Set Interface Status
\r
197 def interfaceStatus = "DISABLE"
\r
198 if("activate".equalsIgnoreCase(action)){
\r
199 interfaceStatus = "ENABLE"
\r
202 //Build SDNC Adapter Request
\r
203 String sdncAdapterL3ToHLRequest = """
\r
204 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
205 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
206 <sdncadapter:RequestHeader>
\r
207 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
208 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
209 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
210 <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
\r
211 <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
\r
212 </sdncadapter:RequestHeader>
\r
213 <sdncadapterworkflow:SDNCRequestData>
\r
214 ${nnsRequestInformation}
\r
215 ${serviceInformation}
\r
216 <nbnc-request-information>
\r
217 <service-type>${service}</service-type>
\r
218 <customer-id>${customerId}</customer-id>
\r
219 <interface-status>${interfaceStatus}</interface-status>
\r
221 </nbnc-request-information>
\r
222 </sdncadapterworkflow:SDNCRequestData>
\r
223 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutValueInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
224 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
226 sdncAdapterL3ToHLRequest = utils.removeXmlPreamble(utils.formatXML(sdncAdapterL3ToHLRequest))
\r
228 return sdncAdapterL3ToHLRequest
\r
233 private void SDNCAdapterActivateRequest(DelegateExecution execution, String resultVar, String svcAction,
\r\r
234 String svcOperation, String additionalData) {
\r
235 def utils=new MsoUtils()
\r
237 def prefix = execution.getVariable('prefix')
\r
238 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
239 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
240 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
241 def serviceParameters = utils.getNodeXml(request, 'service-parameters', false)
\r
243 def requestId = execution.getVariable('testReqId') // for junits
\r
244 if(requestId==null){
\r
245 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
248 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
249 def msoAction = 'gammainternet'
\r
251 def timeoutInMinutes = execution.getVariable('URN_mso_sdnc_timeout_firewall_minutes')
\r
253 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
\r
254 if (callbackUrl == null || callbackUrl.trim() == "") {
\r
255 logError('mso:workflow:sdncadapter:callback URN is not set')
\r
256 workflowException(execution, 'Internal Error', 9999) // TODO: what message and error code?
\r
259 def l2HomingInformation = utils.getNodeXml(serviceParameters, 'l2-homing-information', false)
\r
260 def internetEvcAccessInformation = utils.getNodeXml(serviceParameters, 'internet-evc-access-information', false)
\r
261 def vrLan = utils.getNodeXml(serviceParameters, 'vr-lan', false)
\r
262 def upceVmsServiceInformation = utils.getNodeXml(serviceParameters, 'ucpe-vms-service-information', false)
\r
265 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
266 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
267 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
\r
268 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
\r
269 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
\r
270 def nnsUpceVmsServiceInformation = utils.removeXmlNamespaces(upceVmsServiceInformation)
\r
272 if (additionalData == null) {
\r
273 additionalData = ""
\r
276 boolean isAic3 = execution.getVariable("isAic3")
\r
279 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
\r
282 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
\r
285 String content = """
\r
286 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
287 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
288 <sdncadapter:RequestHeader>
\r
289 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
290 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
291 <sdncadapter:SvcAction>${svcAction}</sdncadapter:SvcAction>
\r
292 <sdncadapter:SvcOperation>${svcOperation}</sdncadapter:SvcOperation>
\r
293 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
\r
294 <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
\r
295 </sdncadapter:RequestHeader>
\r
296 <sdncadapterworkflow:SDNCRequestData>
\r
298 ${nnsRequestInformation}
\r
299 ${nnsServiceInformation}
\r
300 ${nnsl2HomingInformation}
\r
301 ${nnsInternetEvcAccessInformation}
\r
303 ${nnsUpceVmsServiceInformation}
\r
304 </sdncadapterworkflow:SDNCRequestData>
\r
305 <sdncadapterworkflow:SDNCTimeOutValueInMinutes>${timeoutInMinutes}</sdncadapterworkflow:SDNCTimeOutValueInMinutes>
\r
306 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
309 content = utils.removeXmlPreamble(utils.formatXML(content))
\r
310 execution.setVariable(resultVar, content)
\r
314 * Builds an SDNC "reserve" request and stores it in the specified execution
\r
316 * @param execution the execution
\r
317 * @param action the type of action: reserve, turnup, etc
\r
318 * @param resultVar the execution variable in which the result will be stored
\r
320 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar) {
\r
321 sdncReservePrep(execution, action, resultVar, false)
\r
325 * Builds an SDNC "reserve" request and stores it in the specified execution
\r
327 * @param execution the execution
\r
328 * @param action the type of action: reserve, turnup, etc
\r
329 * @param resultVar the execution variable in which the result will be stored
\r
330 * @param isAic3 boolean to indicate whether request is for AIC3.0
\r
332 public void sdncReservePrep(DelegateExecution execution, String action, String resultVar, boolean isAic3) {
\r\r
333 sdncPrep(execution, resultVar, action , 'service-configuration-operation', null, isAic3, this.taskProcessor)
\r
337 * Builds a basic SDNC request and stores it in the specified execution variable.
\r
338 * @param execution the execution
\r
339 * @param resultVar the execution variable in which the result will be stored
\r
340 * @param svcAction the svcAction element value
\r
341 * @param svcOperation the svcOperation element value
\r
342 * @param additionalData additional XML content to be inserted into the
\r
343 * RequestData element (may be null)
\r
345 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
\r
346 String svcOperation, String additionalData, AbstractServiceTaskProcessor taskProcessor) {
\r
347 sdncPrep(execution, resultVar, svcAction, svcOperation, additionalData, false, taskProcessor)
\r
351 * Builds a basic SDNC request and stores it in the specified execution variable.
\r
352 * @param execution the execution
\r
353 * @param resultVar the execution variable in which the result will be stored
\r
354 * @param svcAction the svcAction element value
\r
355 * @param svcOperation the svcOperation element value
\r
356 * @param additionalData additional XML content to be inserted into the RequestData element (may be null)
\r
357 * @param isAic3 boolean to indicate whether request is for AIC3.0
\r
359 public void sdncPrep(DelegateExecution execution, String resultVar, String svcAction,
\r\r
360 String svcOperation, String additionalData, boolean isAic3, AbstractServiceTaskProcessor taskProcessor) {
\r
361 def method = getClass().getSimpleName() + '.sdncPrep(' +
\r
362 'execution=' + execution.getId() +
\r
363 ', resultVar=' + resultVar +
\r
364 ', svcAction=' + svcAction +
\r
365 ', svcOperation=' + svcOperation +
\r
366 ', additionalData=' + (additionalData == null ? "no" : "yes") +
\r
369 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
370 taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled)
\r
371 MsoUtils utils = taskProcessor.utils
\r
373 def prefix = execution.getVariable('prefix')
\r
374 def request = taskProcessor.getVariable(execution, prefix+'Request')
\r
375 def requestInformation = utils.getNodeXml(request, 'request-information', false)
\r
376 def serviceInformation = utils.getNodeXml(request, 'service-information', false)
\r
377 def serviceParameters = utils.getChildNodes(request, 'service-parameters')
\r
378 def requestAction = utils.getNodeText1(request, 'request-action')
\r
380 def timeoutInMinutes = execution.getVariable('URN_mso_sdnc_timeout_firewall_minutes')
\r
382 def requestId = execution.getVariable('testReqId') // for junits
\r
383 if(requestId==null){
\r
384 requestId = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
\r
387 def svcInstanceId = execution.getVariable("mso-service-instance-id")
\r
388 def msoAction = 'gammainternet'
\r
390 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
\r
391 if (callbackUrl == null || callbackUrl.trim() == "") {
\r
392 taskProcessor.logError('mso:workflow:sdncadapter:callback URN is not set')
\r
393 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request")
\r
396 def l2HomingInformation = utils.getNodeXml(request, 'l2-homing-information', false)
\r
397 def internetEvcAccessInformation = utils.getNodeXml(request, 'internet-evc-access-information', false)
\r
398 def vrLan = utils.getNodeXml(request, 'vr-lan', false)
\r
399 def upceVmsServiceInfo = utils.getNodeXml(request, 'ucpe-vms-service-information', false)
\r
400 def vnfInformationList = utils.getNodeXml(request, 'vnf-information-list', false)
\r
402 def nnsRequestInformation = utils.removeXmlNamespaces(requestInformation)
\r
403 def nnsServiceInformation = utils.removeXmlNamespaces(serviceInformation)
\r
404 def nnsl2HomingInformation = utils.removeXmlNamespaces(l2HomingInformation)
\r
405 def nnsInternetEvcAccessInformation = utils.removeXmlNamespaces(internetEvcAccessInformation)
\r
406 def nnsVrLan = utils.removeXmlNamespaces(vrLan)
\r
407 def nnsUpceVmsServiceInfo = utils.removeXmlNamespaces(upceVmsServiceInfo)
\r
408 def nnsVnfInformationList = utils.removeXmlNamespaces(vrLan)
\r
409 def nnsinternetSvcChangeDetails = ""
\r
411 if(requestAction!=null && requestAction.equals("ChangeLayer3ServiceProvRequest")){
\r
412 def internetSvcChangeDetails = utils.removeXmlNamespaces(serviceParameters)
\r
413 nnsinternetSvcChangeDetails = """<internet-service-change-details>
\r
414 ${internetSvcChangeDetails}
\r
415 </internet-service-change-details>"""
\r
418 if (additionalData == null) {
\r
419 additionalData = ""
\r
423 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC3.0")
\r
426 nnsl2HomingInformation = updateHomingInfo(nnsl2HomingInformation, "AIC2.X")
\r
430 String content = """
\r
431 <sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:sdncadapterworkflow="http://openecomp.com/mso/workflow/schema/v1"
\r
432 xmlns:sdncadapter="http://domain2.openecomp.com/workflow/sdnc/adapter/schema/v1">
\r
433 <sdncadapter:RequestHeader>
\r
434 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
\r
435 <sdncadapter:SvcInstanceId>${svcInstanceId}</sdncadapter:SvcInstanceId>
\r
436 <sdncadapter:SvcAction>${svcAction}</sdncadapter:SvcAction>
\r
437 <sdncadapter:SvcOperation>${svcOperation}</sdncadapter:SvcOperation>
\r
438 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
\r
439 <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
\r
440 </sdncadapter:RequestHeader>
\r
441 <sdncadapterworkflow:SDNCRequestData>
\r
443 ${nnsRequestInformation}
\r
444 ${nnsServiceInformation}
\r
445 ${nnsl2HomingInformation}
\r
446 ${nnsInternetEvcAccessInformation}
\r
448 ${nnsUpceVmsServiceInfo}
\r
449 ${nnsVnfInformationList}
\r
450 ${nnsinternetSvcChangeDetails}
\r
451 </sdncadapterworkflow:SDNCRequestData>
\r
452 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
\r
455 content = utils.removeXmlPreamble(utils.formatXML(content))
\r
456 execution.setVariable(resultVar, content)
\r
457 taskProcessor.logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
\r
459 taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled)
\r
460 } catch (BpmnError e) {
\r
462 } catch (Exception e) {
\r
463 taskProcessor.logError('Caught exception in ' + method, e)
\r
464 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error")
\r
468 public String updateHomingInfo(String homingInfo, String aicVersion) {
\r
469 String newHomingInfo
\r
470 if(homingInfo == null || homingInfo.trim().length() == 0) {
\r
471 newHomingInfo = "<l2-homing-information><aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
\r
474 newHomingInfo = homingInfo.substring(0, homingInfo.indexOf("</l2-homing-information>")) + "<aic-version>" + aicVersion + "</aic-version></l2-homing-information>"
\r
479 * Builds a topology SDNC request and return String request.
\r
480 * As V2 will use 1607-style request, region instead of aic clli code
\r
481 * @param execution, the execution
\r
482 * @param requestXML, the incoming request for the flow
\r
483 * @param serviceInstanceId, the serviceIntance (if available)
\r
484 * @param callbackUrl, the call back url
\r
485 * @param action, the action element value
\r
486 * @param requestAction the svcOperation element value
\r
487 * @param cloudRegionId the aai's cloud-region-id
\r
488 * @param networkId the aai's network-id
\r
489 * @param additionalData additional XML content to be inserted into the
\r
490 * RequestData element (may be null)
\r
492 public String sdncTopologyRequestV2 (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String queryAAIResponse, String additionalData) {
\r\r
493 def utils=new MsoUtils()
\r
495 // SNDC is expecting request Id for header as unique each call.
\r
496 String hdrRequestId = ""
\r
497 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
\r
498 if (testHdrRequestId == null) {
\r
499 hdrRequestId = UUID.randomUUID() // generate unique
\r
501 hdrRequestId = testHdrRequestId
\r
504 String requestId = ""
\r
506 requestId = execution.getVariable("mso-request-id")
\r
507 } catch (Exception ex) {
\r
508 requestId = utils.getNodeText1(requestXML, "request-id")
\r
511 String aicCloudRegion = cloudRegionId
\r
512 String tenantId = ""
\r
513 if (utils.nodeExists(requestXML, "tenant-id")) {
\r
514 tenantId = utils.getNodeText1(requestXML, "tenant-id")
\r
516 String networkType = ""
\r
517 if (utils.nodeExists(requestXML, "network-type")) {
\r
518 networkType = utils.getNodeText1(requestXML, "network-type")
\r
521 // Replace/Use the value of network-type from aai query (vs input) during Delete Network flows.
\r
522 if (queryAAIResponse != null) {
\r
523 networkType = utils.getNodeText1(queryAAIResponse, "network-type")
\r
526 String serviceId = ""
\r
527 if (utils.nodeExists(requestXML, "service-id")) {
\r
528 serviceId = utils.getNodeText1(requestXML, "service-id")
\r
530 String networkName = ""
\r
531 if (utils.nodeExists(requestXML, "network-name")) {
\r
532 networkName = utils.getNodeText1(requestXML, "network-name")
\r
535 if (utils.nodeExists(requestXML, "source")) {
\r
536 source = utils.getNodeText1(requestXML, "source")
\r
539 // get resourceLink from subflow execution variable
\r
540 String serviceType = ""
\r
541 String subscriberName = ""
\r
542 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
\r
543 if (siRelatedLink != null) {
\r
544 // get service type
\r
545 int serviceStart = siRelatedLink.indexOf("service-subscription/")
\r
546 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
\r
547 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
\r
548 serviceType = UriUtils.decode(serviceType,"UTF-8")
\r
549 // get subscriber name
\r
550 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
\r
551 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
\r
552 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
\r
553 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
\r
557 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
558 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
\r
559 xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"
\r
560 xmlns:ns5="http://org.openecomp/mso/request/types/v1">
\r
561 <sdncadapter:RequestHeader>
\r
562 <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
\r
563 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
\r
564 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
565 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
\r
566 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
\r
567 </sdncadapter:RequestHeader>
\r
568 <sdncadapterworkflow:SDNCRequestData>
\r
569 <request-information>
\r
570 <request-id>${requestId}</request-id>
\r
571 <request-action>${requestAction}</request-action>
\r
572 <source>${source}</source>
\r
573 <notification-url></notification-url>
\r
574 <order-number></order-number>
\r
575 <order-version></order-version>
\r
576 </request-information>
\r
577 <service-information>
\r
578 <service-id>${serviceId}</service-id>
\r
579 <service-type>${serviceType}</service-type>
\r
580 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
581 <subscriber-name>${subscriberName}</subscriber-name>
\r
582 </service-information>
\r
583 <network-request-information>
\r
584 <network-id>${networkId}</network-id>
\r
585 <network-type>${networkType}</network-type>
\r
586 <network-name>${networkName}</network-name>
\r
587 <tenant>${tenantId}</tenant>
\r
588 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
\r
589 </network-request-information>
\r
590 </sdncadapterworkflow:SDNCRequestData>
\r
591 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
\r
597 * Builds a topology SDNC request and return String request.
\r
598 * As V2 will use 1607-style request, region instead of aic clli code
\r
599 * @param execution, the execution
\r
600 * @param requestXML, the incoming request for the flow
\r
601 * @param serviceInstanceId, the serviceIntance (if available)
\r
602 * @param callbackUrl, the call back url
\r
603 * @param action, the action element value
\r
604 * @param requestAction the svcOperation element value
\r
605 * @param cloudRegionId the aai's cloud-region-id
\r
606 * @param networkId the aai's network-id
\r
607 * @param additionalData additional XML content to be inserted into the
\r
608 * RequestData element (may be null)
\r
610 public String sdncTopologyRequestRsrc (DelegateExecution execution, String requestXML, String serviceInstanceId, String callbackUrl, String action, String requestAction, String cloudRegionId, networkId, String additionalData) {
\r\r
611 def utils=new MsoUtils()
\r
613 // SNDC is expecting request Id for header as unique each call.
\r
614 String hdrRequestId = ""
\r
615 String testHdrRequestId = execution.getVariable("testMessageId") // for test purposes.
\r
616 if (testHdrRequestId == null) {
\r
617 hdrRequestId = UUID.randomUUID() // generate unique
\r
619 hdrRequestId = testHdrRequestId
\r
622 String requestId = ""
\r
623 String testRequestId = execution.getVariable("testMessageId") // for test purposes.
\r
624 if (testRequestId == null) {
\r
625 requestId = execution.getVariable("mso-request-id")
\r
626 if (requestId == null) {
\r
627 requestId = execution.getVariable("msoRequestId")
\r
630 requestId = testRequestId
\r
633 String aicCloudRegion = cloudRegionId
\r
634 String tenantId = ""
\r
635 if (utils.nodeExists(requestXML, "tenant-id")) {
\r
636 tenantId = utils.getNodeText1(requestXML, "tenant-id")
\r
638 String networkType = ""
\r
639 if (utils.nodeExists(requestXML, "network-type")) {
\r
640 networkType = utils.getNodeText1(requestXML, "network-type")
\r
643 String subscriptionServiceType = ""
\r
644 if (utils.nodeExists(requestXML, "subscription-service-type")) {
\r
645 subscriptionServiceType = utils.getNodeText1(requestXML, "subscription-service-type")
\r
648 String globalCustomerId = ""
\r
649 if (utils.nodeExists(requestXML, "global-customer-id")) {
\r
650 globalCustomerId = utils.getNodeText1(requestXML, "global-customer-id")
\r
653 String serviceId = ""
\r
654 if (utils.nodeExists(requestXML, "service-id")) {
\r
655 serviceId = utils.getNodeText1(requestXML, "service-id")
\r
657 String networkName = ""
\r
658 if (utils.nodeExists(requestXML, "network-name")) {
\r
659 networkName = utils.getNodeText1(requestXML, "network-name")
\r
662 if (utils.nodeExists(requestXML, "source")) {
\r
663 source = utils.getNodeText1(requestXML, "source")
\r
666 // get resourceLink from subflow execution variable
\r
667 String serviceType = ""
\r
668 String subscriberName = ""
\r
669 String siRelatedLink = execution.getVariable("GENGSI_siResourceLink")
\r
670 if (siRelatedLink != null) {
\r
671 // get service type
\r
672 int serviceStart = siRelatedLink.indexOf("service-subscription/")
\r
673 int serviceEnd = siRelatedLink.indexOf("/service-instances/")
\r
674 serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd)
\r
675 serviceType = UriUtils.decode(serviceType,"UTF-8")
\r
676 // get subscriber name
\r
677 int subscriberNameStart = siRelatedLink.indexOf("customers/customer/")
\r
678 int subscriberNameEnd = siRelatedLink.indexOf("/service-subscriptions/")
\r
679 subscriberName = siRelatedLink.substring(subscriberNameStart + 19, subscriberNameEnd)
\r
680 subscriberName = UriUtils.decode(subscriberName,"UTF-8")
\r
683 // network-information from 'networkModelInfo' // verify the DB Catalog response
\r
684 String networkModelInfo = utils.getNodeXml(requestXML, "networkModelInfo", false).replace("tag0:","").replace(":tag0","")
\r
685 String modelInvariantUuid = utils.getNodeText1(networkModelInfo, "modelInvariantUuid") !=null ?
\r
686 utils.getNodeText1(networkModelInfo, "modelInvariantUuid") : ""
\r
687 String modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") !=null ?
\r
688 utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") : ""
\r
689 String modelUuid = utils.getNodeText1(networkModelInfo, "modelUuid") !=null ?
\r
690 utils.getNodeText1(networkModelInfo, "modelUuid") : ""
\r
691 String modelVersion = utils.getNodeText1(networkModelInfo, "modelVersion") !=null ?
\r
692 utils.getNodeText1(networkModelInfo, "modelVersion") : ""
\r
693 String modelName = utils.getNodeText1(networkModelInfo, "modelName") !=null ?
\r
694 utils.getNodeText1(networkModelInfo, "modelName") : ""
\r
696 // service-information from 'networkModelInfo' // verify the DB Catalog response
\r
697 String serviceModelInfo = utils.getNodeXml(requestXML, "serviceModelInfo", false).replace("tag0:","").replace(":tag0","")
\r
698 String serviceModelInvariantUuid = utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") !=null ?
\r
699 utils.getNodeText1(serviceModelInfo, "modelInvariantUuid") : ""
\r
700 String serviceModelUuid = utils.getNodeText1(serviceModelInfo, "modelUuid") !=null ?
\r
701 utils.getNodeText1(serviceModelInfo, "modelUuid") : ""
\r
702 String serviceModelVersion = utils.getNodeText1(serviceModelInfo, "modelVersion") !=null ?
\r
703 utils.getNodeText1(serviceModelInfo, "modelVersion") : ""
\r
704 String serviceModelName = utils.getNodeText1(serviceModelInfo, "modelName") !=null ?
\r
705 utils.getNodeText1(serviceModelInfo, "modelName") : ""
\r
709 """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
710 xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"
\r
711 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
\r
712 <sdncadapter:RequestHeader>
\r
713 <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
\r
714 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
\r
715 <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
\r
716 <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
\r
717 <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
\r
718 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
\r
719 </sdncadapter:RequestHeader>
\r
720 <sdncadapterworkflow:SDNCRequestData>
\r
721 <request-information>
\r
722 <request-id>${requestId}</request-id>
\r
723 <request-action>${requestAction}</request-action>
\r
724 <source>${source}</source>
\r
725 <notification-url></notification-url>
\r
726 <order-number></order-number>
\r
727 <order-version></order-version>
\r
728 </request-information>
\r
729 <service-information>
\r
730 <service-id>${serviceId}</service-id>
\r
731 <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
\r
732 <ecomp-model-information>
\r
733 <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid>
\r
734 <model-uuid>${serviceModelUuid}</model-uuid>
\r
735 <model-version>${serviceModelVersion}</model-version>
\r
736 <model-name>${serviceModelName}</model-name>
\r
737 </ecomp-model-information>
\r
738 <service-instance-id>${serviceInstanceId}</service-instance-id>
\r
739 <global-customer-id>${globalCustomerId}</global-customer-id>
\r
740 <subscriber-name>${subscriberName}</subscriber-name>
\r
741 </service-information>
\r
742 <network-information>
\r
743 <network-id>${networkId}</network-id>
\r
744 <network-type>${networkType}</network-type>
\r
745 <ecomp-model-information>
\r
746 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
\r
747 <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>
\r
748 <model-uuid>${modelUuid}</model-uuid>
\r
749 <model-version>${modelVersion}</model-version>
\r
750 <model-name>${modelName}</model-name>
\r
751 </ecomp-model-information>
\r
752 </network-information>
\r
753 <network-request-input>
\r
754 <network-name>${networkName}</network-name>
\r
755 <tenant>${tenantId}</tenant>
\r
756 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
\r
757 <aic-clli></aic-clli>
\r
758 <network-input-parameters/>
\r
759 </network-request-input>
\r
760 </sdncadapterworkflow:SDNCRequestData>
\r
761 </aetgt:SDNCAdapterWorkflowRequest>""".trim()
\r
767 * Validates a workflow response.
\r
768 * @param execution the execution
\r
769 * @param responseVar the execution variable in which the response is stored
\r
770 * @param workflowException the WorkflowException Object returned from sdnc call
\r
772 public void validateSDNCResponse(DelegateExecution execution, String response, WorkflowException workflowException, boolean successIndicator){
\r\r
773 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
774 taskProcessor.utils.log("DEBUG", "SDNC Response is: " + response, isDebugLogEnabled)
\r
775 taskProcessor.utils.log("DEBUG", "SuccessIndicator is: " + successIndicator, isDebugLogEnabled)
\r
778 def prefix = execution.getVariable('prefix')
\r
779 execution.setVariable(prefix+'sdncResponseSuccess', false)
\r
780 taskProcessor.utils.log("DEBUG", "Response" + ' = ' + (response == null ? "" : System.lineSeparator()) + response, isDebugLogEnabled)
\r
782 if (successIndicator){
\r
783 if (response == null || response.trim().equals("")) {
\r
784 taskProcessor.utils.log("DEBUG", response + ' is empty');
\r
785 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "SDNCAdapter Workflow Response is Empty")
\r
788 // we need to peer into the request data for error
\r
789 def String sdncAdapterWorkflowResponse = taskProcessor.utils.getNodeXml(response, 'response-data', false)
\r
790 def String decodedXml = decodeXML(sdncAdapterWorkflowResponse).replace('<?xml version="1.0" encoding="UTF-8"?>', "")
\r
792 // change '&' to "& (if present as data, ex: subscriber-name = 'FOUR SEASONS HEATING & COOLING_8310006378683'
\r
793 decodedXml = decodedXml.replace("&", "&")
\r
795 taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled)
\r
797 int requestDataResponseCode = 200
\r
798 def String requestDataResponseMessage = ''
\r
801 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
\r
802 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
\r
803 } else if (taskProcessor.utils.nodeExists(decodedXml, "ResponseMessage")) {
\r
804 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "ResponseMessage")
\r
806 }catch(Exception e){
\r
807 taskProcessor.utils.log("DEBUG", 'Error caught while decoding resposne ' + e.getMessage(), isDebugLogEnabled)
\r
810 if(taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
\r
811 taskProcessor.utils.log("DEBUG","response-code node Exist ", isDebugLogEnabled)
\r
812 String code = taskProcessor.utils.getNodeText1(decodedXml, "response-code")
\r
813 if(code.isEmpty() || code.equals("")){
\r
814 // if response-code is blank then Success
\r
815 taskProcessor.utils.log("DEBUG","response-code node is empty", isDebugLogEnabled)
\r
816 requestDataResponseCode = 0
\r
818 requestDataResponseCode = code.toInteger()
\r
819 taskProcessor.utils.log("DEBUG","response-code is: " + requestDataResponseCode, isDebugLogEnabled)
\r
821 }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){
\r
822 taskProcessor.utils.log("DEBUG","ResponseCode node Exist ", isDebugLogEnabled)
\r
823 String code = taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode")
\r
824 if(code.isEmpty() || code.equals("")){
\r
825 // if ResponseCode blank then Success
\r
826 taskProcessor.utils.log("DEBUG","ResponseCode node is empty", isDebugLogEnabled)
\r
827 requestDataResponseCode = 0
\r
829 requestDataResponseCode = code.toInteger()
\r
830 taskProcessor.utils.log("DEBUG","ResponseCode is: " + requestDataResponseCode, isDebugLogEnabled)
\r
833 taskProcessor.utils.log("DEBUG","A Response Code DOES NOT Exist.", isDebugLogEnabled)
\r
834 // if a response code does not exist then Success
\r
835 requestDataResponseCode = 0
\r
839 execution.setVariable(prefix+'sdncRequestDataResponseCode', requestDataResponseCode.toString())
\r
840 // if a response code is 0 or 2XX then Success
\r
841 if ((requestDataResponseCode >= 200 && requestDataResponseCode <= 299) || requestDataResponseCode == 0) {
\r
842 execution.setVariable(prefix+'sdncResponseSuccess', true)
\r
843 taskProcessor.utils.log("DEBUG", "Setting sdncResponseSuccess to True ", isDebugLogEnabled)
\r
844 taskProcessor.utils.log("DEBUG", "Exited ValidateSDNCResponse Method", isDebugLogEnabled)
\r
846 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
847 String convertedCode = exceptionUtil.MapSDNCResponseCodeToErrorCode(requestDataResponseCode.toString())
\r
848 int convertedCodeInt = Integer.parseInt(convertedCode)
\r
849 exceptionUtil.buildAndThrowWorkflowException(execution, convertedCodeInt, "Received error from SDN-C: " + requestDataResponseMessage)
\r
852 }catch(Exception e){
\r
853 //TODO proper handling of new, non numerical response codes in 1607 and new error handling for common API
\r
854 requestDataResponseCode = 500
\r
857 taskProcessor.utils.log("DEBUG", "SDNC callback response-code: " + requestDataResponseCode, isDebugLogEnabled)
\r
858 taskProcessor.utils.log("DEBUG", "SDNC callback response-message: " + requestDataResponseMessage, isDebugLogEnabled)
\r
862 taskProcessor.utils.log("DEBUG", 'SDNCAdapter Subflow did NOT complete Successfully. SuccessIndicator is False. ')
\r
863 if(workflowException != null){
\r
864 exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
\r
866 //TODO : what error code and error message use here
\r
867 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - SDNCAdapter Subflow did NOT complete successfully.")
\r
871 } catch (BpmnError e) {
\r
873 } catch (Exception e) {
\r
874 taskProcessor.utils.log("DEBUG", 'END of Validate SDNC Response', isDebugLogEnabled)
\r
875 exceptionUtil.buildAndThrowWorkflowException(execution, 500, 'Internal Error- Unable to validate SDNC Response ');
\r
880 * Validates a workflow response.
\r
881 * @param execution the execution
\r
882 * @param responseVar the execution variable in which the response is stored
\r
883 * @param responseCodeVar the execution variable in which the response code is stored
\r
884 * @param errorResponseVar the execution variable in which the error response is stored
\r
886 public void validateL3BondingSDNCResp(DelegateExecution execution, String response, WorkflowException workflowException, boolean success) {
\r\r
887 def method = getClass().getSimpleName() + '.validateL3BondingSDNCResp(' +
\r
888 'execution=' + execution.getId() +
\r
889 ', response=' + response +
\r
891 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
892 taskProcessor.logDebug('Entered ' + method, isDebugLogEnabled)
\r
893 def prefix = execution.getVariable('prefix')
\r
894 TrinityExceptionUtil trinityExceptionUtil = new TrinityExceptionUtil()
\r
897 execution.setVariable(prefix+'sdncResponseSuccess', false)
\r
899 taskProcessor.utils.log("sdncAdapter Success Indicator is: " + success, isDebugLogEnabled)
\r
902 // we need to look inside the request data for error
\r
903 def String callbackRequestData = taskProcessor.utils.getNodeXml(response, 'RequestData', false)
\r
904 def String decodedXml = decodeXML(callbackRequestData)
\r
905 taskProcessor.utils.log("DEBUG","decodedXml:\n" + decodedXml, isDebugLogEnabled)
\r
907 def requestDataResponseCode = '200'
\r
908 def requestDataResponseMessage = ''
\r
909 int intDataResponseCode = 200
\r
911 if (taskProcessor.utils.nodeExists(decodedXml, "response-code")) {
\r
913 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText(decodedXml, "response-code"))
\r
914 if (taskProcessor.utils.nodeExists(decodedXml, "response-message")) {
\r
915 requestDataResponseMessage = taskProcessor.utils.getNodeText(decodedXml, "response-message")
\r
917 }else if(taskProcessor.utils.nodeExists(decodedXml, "ResponseCode")){
\r
918 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText1(decodedXml, "ResponseCode")).toInteger()
\r
919 }else if(taskProcessor.utils.nodeExists(response, "ResponseCode")){
\r
920 requestDataResponseCode = ((String) taskProcessor.utils.getNodeText1(response, "ResponseCode")).toInteger()
\r
921 requestDataResponseMessage = taskProcessor.utils.getNodeText(response, "ResponseMessage")
\r
924 taskProcessor.utils.log("DEBUG", "SDNC callback response-code: " + requestDataResponseCode, isDebugLogEnabled)
\r
925 taskProcessor.utils.log("DEBUG", "SDNC callback response-message: " + requestDataResponseMessage, isDebugLogEnabled)
\r
927 // Get the AAI Status to determine if rollback is needed on ASSIGN
\r
928 def aai_status = ''
\r
929 if (taskProcessor.utils.nodeExists(decodedXml, "aai-status")) {
\r
930 aai_status = ((String) taskProcessor.utils.getNodeText(decodedXml, "aai-status"))
\r
931 taskProcessor.utils.log("DEBUG", "SDNC sent AAI STATUS code: " + aai_status, isDebugLogEnabled)
\r
933 if (aai_status != null && !aai_status.equals("")) {
\r
934 execution.setVariable(prefix+"AaiStatus",aai_status)
\r
935 taskProcessor.utils.log("DEBUG", "Set variable " + prefix + "AaiStatus: " + execution.getVariable(prefix+"AaiStatus"), isDebugLogEnabled)
\r
938 // Get the result string to determine if rollback is needed on ASSIGN in Add Bonding flow only
\r
939 def sdncResult = ''
\r
940 if (taskProcessor.utils.nodeExists(decodedXml, "result")) {
\r
941 sdncResult = ((String) taskProcessor.utils.getNodeText(decodedXml, "result"))
\r
942 taskProcessor.utils.log("DEBUG", "SDNC sent result: " + sdncResult, isDebugLogEnabled)
\r
944 if (sdncResult != null && !sdncResult.equals("")) {
\r
945 execution.setVariable(prefix+"SdncResult",sdncResult)
\r
946 taskProcessor.utils.log("DEBUG", "Set variable " + prefix + "SdncResult: " + execution.getVariable(prefix+"SdncResult"), isDebugLogEnabled)
\r
950 intDataResponseCode = Integer.parseInt(String.valueOf(requestDataResponseCode))
\r
951 }catch(Exception e){
\r
952 intDataResponseCode = 400
\r
955 taskProcessor.utils.log("DEBUG", "intDataResponseCode " + intDataResponseCode , isDebugLogEnabled)
\r
957 // if response-code is not Success (200, 201, etc) we need to throw an exception
\r
958 if ((intDataResponseCode < 200 || intDataResponseCode > 299) && intDataResponseCode != 0) {
\r
959 execution.setVariable(prefix+'ResponseCode', intDataResponseCode)
\r
960 execution.setVariable("L3HLAB_rollback", true)
\r
961 def msg = trinityExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution)
\r
962 exceptionUtil.buildAndThrowWorkflowException(execution, intDataResponseCode, "Received error from SDN-C: " + msg)
\r
966 taskProcessor.logWarn('sdncAdapter did not complete successfully, sdncAdapter Success Indicator was false ')
\r
967 execution.setVariable("L3HLAB_rollback", true)
\r
968 def msg = trinityExceptionUtil.mapSDNCAdapterExceptionToErrorResponse(response, execution)
\r
969 exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, msg)
\r
972 if (response == null || response.trim().equals("")) {
\r
973 taskProcessor.logWarn('sdncAdapter workflow response is empty');
\r
974 execution.setVariable("L3HLAB_rollback", true)
\r
975 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response " , execution)
\r
976 exceptionUtil.buildAndThrowWorkflowException(execution, intResponseCode, msg)
\r
979 execution.setVariable(prefix+'sdncResponseSuccess', true)
\r
980 taskProcessor.logDebug('Exited ' + method, isDebugLogEnabled)
\r
981 } catch (BpmnError e) {
\r
983 } catch (Exception e) {
\r
984 taskProcessor.logError('Caught exception in ' + method, e)
\r
985 execution.setVariable(prefix+"ResponseCode",400)
\r
986 execution.setVariable("L3HLAB_rollback", true)
\r
987 def msg = trinityExceptionUtil.buildException("Exception occurred while validating SDNC response: " + e.getMessage(), execution)
\r
988 exceptionUtil.buildAndThrowWorkflowException(execution, 400, msg)
\r
992 public String modelInfoToEcompModelInformation(String jsonModelInfo) {
\r
993 String modelInvariantUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelInvariantUuid")
\r
994 String modelUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelUuid")
\r
995 if (modelUuid == null) {
\r
998 String modelCustomizationUuid = jsonUtil.getJsonValue(jsonModelInfo, "modelCustomizationUuid")
\r
999 String modelCustomizationString = ""
\r
1000 if (modelCustomizationUuid != null) {
\r
1001 modelCustomizationString = "<model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>"
\r
1003 String modelVersion = jsonUtil.getJsonValue(jsonModelInfo, "modelVersion")
\r
1004 if (modelVersion == null) {
\r
1007 String modelName = jsonUtil.getJsonValue(jsonModelInfo, "modelName")
\r
1008 String ecompModelInformation =
\r
1009 """<ecomp-model-information>
\r
1010 <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
\r
1011 <model-uuid>${modelUuid}</model-uuid>
\r
1012 ${modelCustomizationString}
\r
1013 <model-version>${modelVersion}</model-version>
\r
1014 <model-name>${modelName}</model-name>
\r
1015 </ecomp-model-information>"""
\r
1017 return ecompModelInformation
\r
1021 * Decode XML - replace & < and > with '&', '<' and '>'
\r
1022 * @param xml - the xml to be decoded
\r
1024 private String decodeXML(String xml) {
\r
1025 def String decodedXml = xml.replaceAll("&", "&")
\r
1026 decodedXml = decodedXml.replaceAll("<", "<")
\r
1027 decodedXml = decodedXml.replaceAll(">", ">")
\r