Springboot 2.0 upgrade
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / vcpe / scripts / DoCreateAllottedResourceTXC.groovy
1 /*
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.so.bpmn.vcpe.scripts
22
23 import org.camunda.bpm.engine.delegate.BpmnError
24 import org.camunda.bpm.engine.delegate.DelegateExecution
25 import org.onap.aai.domain.yang.AllottedResource
26 import org.onap.so.bpmn.common.scripts.*;
27 import org.onap.so.bpmn.core.RollbackData
28 import org.onap.so.bpmn.core.UrnPropertiesReader
29 import org.onap.so.bpmn.core.WorkflowException
30 import org.onap.so.bpmn.core.json.JsonUtils
31 import org.onap.so.client.aai.AAIObjectType
32 import org.onap.so.client.aai.entities.uri.AAIResourceUri
33 import org.onap.so.client.aai.entities.uri.AAIUriFactory
34 import org.onap.so.logger.MessageEnum
35 import org.onap.so.logger.MsoLogger
36
37 import javax.ws.rs.core.UriBuilder
38 import static org.apache.commons.lang3.StringUtils.isBlank
39
40 /**
41  * This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process.
42  *
43  * @author
44  * 
45  * Inputs:
46  * @param - msoRequestId
47  * @param - isDEbugLogEnabled
48  * @param - disableRollback
49  * @param - failExists  - O
50  * @param - serviceInstanceId
51  * @param - globalCustomerId - O
52  * @param - subscriptionServiceType - O
53  * @param - parentServiceInstanceId
54  * @param - allottedReourceId - O
55  * @param - allottedResourceModelInfo
56  * @param - allottedResourceRole
57  * @param - allottedResourceType
58  * @param - brgWanMacAddress
59  *
60  * Outputs:
61  * @param - rollbackData (localRB->null)
62  * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
63  * @param - WorkflowException - O
64  * @param - allottedResourceId
65  * @param - allottedResourceName 
66  * @param - vni 
67  * @param - vgmuxBearerIP 
68  * @param - vgmuxLanIP 
69  *
70  */
71 public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{
72         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateAllottedResourceTXC.class);
73
74         String Prefix="DCARTXC_"
75         ExceptionUtil exceptionUtil = new ExceptionUtil()
76         JsonUtils jsonUtil = new JsonUtils()
77
78         public void preProcessRequest (DelegateExecution execution) {
79
80
81                 String msg = ""
82                 msoLogger.trace("start preProcessRequest")
83
84                 try {
85                         String msoRequestId      = execution.getVariable("msoRequestId")
86                         msoLogger.debug(" msoRequestId  = " + msoRequestId)
87                         
88                         execution.setVariable("prefix", Prefix)
89
90                         //Config Inputs
91                         String sdncCallbackUrl = UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
92                         if (isBlank(sdncCallbackUrl)) {
93                                 msg = "mso.workflow.sdncadapter.callback is null"
94                                 msoLogger.debug(msg)
95                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
96                         }
97                         execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
98                         msoLogger.debug("SDNC Callback URL: " + sdncCallbackUrl)
99
100                         String sdncReplDelay = UrnPropertiesReader.getVariable("mso.workflow.sdnc.replication.delay",execution)
101                         if (isBlank(sdncReplDelay)) {
102                                 msg = "mso.workflow.sdnc.replication.delay is null"
103                                 msoLogger.debug(msg)
104                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
105                         }
106                         execution.setVariable("sdncReplDelay", sdncReplDelay)
107                         msoLogger.debug("SDNC replication delay: " + sdncReplDelay)
108
109                         //Request Inputs
110                         if (isBlank(execution.getVariable("serviceInstanceId"))){
111                                 msg = "Input serviceInstanceId is null"
112                                 msoLogger.debug(msg)
113                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
114                         }
115                         if (isBlank(execution.getVariable("parentServiceInstanceId"))) {
116                                 msg = "Input parentServiceInstanceId is null"
117                                 msoLogger.debug(msg)
118                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
119                         }
120                         if (isBlank(execution.getVariable("allottedResourceModelInfo"))) {
121                                 msg = "Input allottedResourceModelInfo is null"
122                                 msoLogger.debug(msg)
123                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
124                         }
125                         if (isBlank(execution.getVariable("brgWanMacAddress"))) {
126                                 msg = "Input brgWanMacAddress is null"
127                                 msoLogger.debug(msg)
128                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
129                         }
130                         if (isBlank(execution.getVariable("allottedResourceRole"))) {
131                                 msg = "Input allottedResourceRole is null"
132                                 msoLogger.debug(msg)
133                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
134                         }
135                         if (isBlank(execution.getVariable("allottedResourceType"))) {
136                                 msg = "Input allottedResourceType is null"
137                                 msoLogger.debug(msg)
138                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
139                         }
140                 }catch(BpmnError b){
141                         msoLogger.debug("Rethrowing MSOWorkflowException")
142                         throw b
143                 } catch (Exception ex){
144                         msg = "Exception in preProcessRequest " + ex.getMessage()
145                         msoLogger.debug(msg)
146                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
147                 }
148                 msoLogger.trace("end preProcessRequest")
149         }
150
151         public void getAaiAR (DelegateExecution execution) {
152
153
154                 msoLogger.trace("start getAaiAR")
155
156                 String arType = execution.getVariable("allottedResourceType")
157                 String arRole = execution.getVariable("allottedResourceRole")
158
159                 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
160                 String orchStatus = arUtils.getAROrchStatus(execution)
161
162                 String errorMsg = ""
163
164                 if (orchStatus != null) // AR was found
165                 {
166                         if ("true".equals(execution.getVariable("failExists")))
167                         {
168                                 errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists"
169                         }
170                         else
171                         {
172                                 if ("Active".equals(orchStatus))
173                                 {
174                                         execution.setVariable("foundActiveAR", true)
175                                 }
176                                 else // blanks included
177                                 {
178                                         errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -"  +  orchStatus
179                                 }
180                         }
181                 }
182                 if (!isBlank(errorMsg)) {
183                         msoLogger.debug(errorMsg)
184                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg)
185                 }
186                 msoLogger.trace("end getAaiAR")
187         }
188
189         public void createAaiAR(DelegateExecution execution) {
190
191
192                 msoLogger.trace("start createAaiAR")
193
194                 String allottedResourceId = execution.getVariable("allottedResourceId")
195                 if (isBlank(allottedResourceId))
196                 {
197                         allottedResourceId = UUID.randomUUID().toString()
198                         execution.setVariable("allottedResourceId", allottedResourceId)
199                 }
200                 try {
201
202                         AAIResourceUri siResourceLink= execution.getVariable("PSI_resourceLink")
203
204                         AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceFromParentURI(siResourceLink, AAIObjectType.ALLOTTED_RESOURCE, allottedResourceId)
205
206                         execution.setVariable("aaiARPath", allottedResourceUri.build().toString());
207                         String arType = execution.getVariable("allottedResourceType")
208                         String arRole = execution.getVariable("allottedResourceRole")
209                         String CSI_resourceLink = execution.getVariable("CSI_resourceLink")
210                         String arModelInfo = execution.getVariable("allottedResourceModelInfo")
211                         msoLogger.debug("arModelInfo is:\n" + arModelInfo)
212                         String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
213                         String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
214
215                         AllottedResource resource = new AllottedResource()
216                         resource.setId(allottedResourceId)
217                         resource.setType(arType)
218                         resource.setRole(arRole)
219                         resource.setModelInvariantId(modelInvariantId)
220                         resource.setModelVersionId(modelVersionId)
221                         getAAIClient().create(allottedResourceUri, resource)
222                         AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceFromExistingURI(AAIObjectType.SERVICE_INSTANCE, UriBuilder.fromPath(CSI_resourceLink).build())
223                         getAAIClient().connect(allottedResourceUri,serviceInstanceUri)
224
225                 }catch (Exception ex) {
226                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception in createAaiAR " + ex.getMessage())
227                 }
228
229                 //start rollback set up
230                 RollbackData rollbackData = new RollbackData()
231                 def disableRollback = execution.getVariable("disableRollback")
232                 rollbackData.put(Prefix, "disableRollback", disableRollback.toString())
233                 rollbackData.put(Prefix, "rollbackAAI", "true")
234                 rollbackData.put(Prefix, "allottedResourceId", allottedResourceId)
235                 rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId"))
236                 rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId"))
237                 execution.setVariable("rollbackData", rollbackData)
238                 msoLogger.trace("end createAaiAR")
239         }
240
241         public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) {
242
243
244                 String msg = ""
245                 msoLogger.trace("start buildSDNCRequest")
246                 String sdncReq = null
247
248                 try {
249
250                         String allottedResourceId = execution.getVariable("allottedResourceId")
251                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
252                         String globalCustomerId = execution.getVariable("globalCustomerId")
253                         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
254                         String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId")
255                         String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId")
256                         String callbackUrl = execution.getVariable("sdncCallbackUrl")
257                         String requestId = execution.getVariable("msoRequestId")
258
259                         String brgWanMacAddress = execution.getVariable("brgWanMacAddress")
260
261                         String arModelInfo = execution.getVariable("allottedResourceModelInfo")
262                         String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid")
263                         String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion")
264                         String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid")
265                         String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid")
266                         String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName")
267
268                         if (modelInvariantId == null) {
269                                 modelInvariantId = ""
270                         }
271                         if (modelVersion == null) {
272                                 modelVersion = ""
273                         }
274                         if (modelUUId == null) {
275                                 modelUUId = ""
276                         }
277                         if (modelName == null) {
278                                 modelName = ""
279                         }
280                         if (modelCustomizationId == null) {
281                                 modelCustomizationId = ""
282                         }
283
284                         sdncReq =
285                         """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
286                                                                                                         xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
287                                                                                                         xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
288                                    <sdncadapter:RequestHeader>
289                                                         <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>
290                                                         <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
291                                                         <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
292                                                         <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation>
293                                                         <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
294                                         </sdncadapter:RequestHeader>
295                                 <sdncadapterworkflow:SDNCRequestData>
296                                         <request-information>
297                                                 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
298                                                 <request-action>CreateTunnelXConnInstance</request-action>
299                                                 <source>MSO</source>
300                                                 <notification-url/>
301                                                 <order-number/>
302                                                 <order-version/>
303                                         </request-information>
304                                         <service-information>
305                                                 <service-id></service-id>
306                                                 <subscription-service-type>${MsoUtils.xmlEscape(subscriptionServiceType)}</subscription-service-type>
307                                                 <onap-model-information></onap-model-information>
308                                                 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
309                                                 <subscriber-name/>
310                                                 <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
311                                         </service-information>
312                                         <allotted-resource-information>
313                                                 <allotted-resource-id>${MsoUtils.xmlEscape(allottedResourceId)}</allotted-resource-id>    
314                                                 <allotted-resource-type>tunnelxconn</allotted-resource-type>
315                                                 <parent-service-instance-id>${MsoUtils.xmlEscape(parentServiceInstanceId)}</parent-service-instance-id>   
316                                                 <onap-model-information>
317                                                         <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantId)}</model-invariant-uuid>
318                                                         <model-uuid>${MsoUtils.xmlEscape(modelUUId)}</model-uuid>
319                                                         <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationId)}</model-customization-uuid>
320                                                         <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
321                                                         <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
322                                                 </onap-model-information>
323                                         </allotted-resource-information>
324                                         <tunnelxconn-request-input>
325                                                         <brg-wan-mac-address>${MsoUtils.xmlEscape(brgWanMacAddress)}</brg-wan-mac-address>
326                                         </tunnelxconn-request-input>
327                                 </sdncadapterworkflow:SDNCRequestData>
328                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
329
330                         msoLogger.debug("sdncRequest:\n" + sdncReq)
331                         sdncReq = utils.formatXml(sdncReq)
332
333                 } catch(Exception ex) {
334                         msg = "Exception in buildSDNCRequest. " + ex.getMessage()
335                         msoLogger.debug(msg)
336                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
337                 }
338                 msoLogger.trace("end buildSDNCRequest")
339                 return sdncReq
340         }
341
342         public void preProcessSDNCAssign(DelegateExecution execution) {
343
344
345                 String msg = ""
346                 msoLogger.trace("start preProcessSDNCAssign")
347
348                 try {
349                         String sdncRequestId = UUID.randomUUID().toString()
350                         String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId)
351                         execution.setVariable("sdncAssignRequest", sdncAssignReq)
352                         msoLogger.debug("sdncAssignRequest:  " + sdncAssignReq)
353                         def sdncRequestId2 = UUID.randomUUID().toString()
354                         String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
355                         def rollbackData = execution.getVariable("rollbackData")
356                         rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq)
357                         execution.setVariable("rollbackData", rollbackData)
358
359                         msoLogger.debug("sdncAssignRollbackReq:\n" + sdncAssignRollbackReq)
360                         msoLogger.debug("rollbackData:\n" + rollbackData.toString())
361
362                 } catch (BpmnError e) {
363                         throw e;
364                 } catch(Exception ex) {
365                         msg = "Exception in preProcessSDNCAssign. " + ex.getMessage()
366                         msoLogger.debug(msg)
367                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
368                 }
369                 msoLogger.debug("end preProcessSDNCAssign")
370         }
371
372         public void preProcessSDNCCreate(DelegateExecution execution) {
373
374
375                 String msg = ""
376                 msoLogger.trace("start preProcessSDNCCreate")
377
378                 try {
379                         String sdncRequestId = UUID.randomUUID().toString()
380                         String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId)
381                         execution.setVariable("sdncCreateRequest", sdncCreateReq)
382                         msoLogger.debug("sdncCreateReq:  " + sdncCreateReq)
383                         def sdncRequestId2 = UUID.randomUUID().toString()
384                         String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
385                         def rollbackData = execution.getVariable("rollbackData")
386                         rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq)
387                         execution.setVariable("rollbackData", rollbackData)
388
389                         msoLogger.debug("sdncCreateRollbackReq:\n" + sdncCreateRollbackReq)
390                         msoLogger.debug("rollbackData:\n" + rollbackData.toString())
391
392                 } catch (BpmnError e) {
393                         throw e;
394                 } catch(Exception ex) {
395                         msg = "Exception in preProcessSDNCCreate. " + ex.getMessage()
396                         msoLogger.debug(msg)
397                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
398                 }
399                 msoLogger.trace("end preProcessSDNCCreate")
400         }
401
402         public void preProcessSDNCActivate(DelegateExecution execution) {
403
404
405                 String msg = ""
406                 msoLogger.trace("start preProcessSDNCActivate")
407
408                 try {
409                         String sdncRequestId = UUID.randomUUID().toString()
410                         String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId)
411                         execution.setVariable("sdncActivateRequest", sdncActivateReq)
412                         msoLogger.debug("sdncActivateReq:  " + sdncActivateReq)
413                         def sdncRequestId2 = UUID.randomUUID().toString()
414                         String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
415                         def rollbackData = execution.getVariable("rollbackData")
416                         rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq)
417                         execution.setVariable("rollbackData", rollbackData)
418
419                         msoLogger.debug("sdncActivateRollbackReq:\n" + sdncActivateRollbackReq)
420                         msoLogger.debug("rollbackData:\n" + rollbackData.toString())
421
422                 } catch (BpmnError e) {
423                         throw e;
424                 } catch(Exception ex) {
425                         msg = "Exception in preProcessSDNCActivate. " + ex.getMessage()
426                         msoLogger.debug(msg)
427                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
428                 }
429                 msoLogger.trace("end preProcessSDNCActivate")
430         }
431
432         public void validateSDNCResp(DelegateExecution execution, String response, String method){
433
434
435                 msoLogger.trace("start ValidateSDNCResponse Process")
436                 String msg = ""
437
438                 try {
439                         WorkflowException workflowException = execution.getVariable("WorkflowException")
440                         msoLogger.debug("workflowException: " + workflowException)
441
442                         boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
443                         msoLogger.debug("SDNCResponse: " + response)
444
445                         SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
446                         sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
447
448                         if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
449                                 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + response)
450
451                                 if (!"get".equals(method))
452                                 {
453                                         def rollbackData = execution.getVariable("rollbackData")
454                                         rollbackData.put(Prefix, "rollback" +  "SDNC" + method, "true")
455                                         execution.setVariable("rollbackData", rollbackData)
456                                 }
457
458                         }else{
459                                 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
460                                 throw new BpmnError("MSOWorkflowException")
461                         }
462                 } catch (BpmnError e) {
463                         throw e;
464                 } catch(Exception ex) {
465                         msg = "Exception in validateSDNCResp. " + ex.getMessage()
466                         msoLogger.debug(msg)
467                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
468                 }
469                 msoLogger.trace("end ValidateSDNCResp Process")
470         }
471
472         public void preProcessSDNCGet(DelegateExecution execution){
473
474                 msoLogger.trace("start preProcessSDNCGet")
475                 try{
476
477                         def callbackUrl = execution.getVariable("sdncCallbackUrl")
478                         // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI
479                         // or from  "object-path" in SDNC response for assign when AR does not exist in AA
480
481                         String serviceOperation = ""
482
483                         if (execution.getVariable("foundActiveAR")) {
484                                 def aaiQueryResponse = execution.getVariable("aaiARGetResponse")
485                                 serviceOperation = utils.getNodeText(aaiQueryResponse, "selflink")
486                                 msoLogger.debug("AR service operation/aaiARSelfLink: " + serviceOperation)
487                         }
488                         else
489                         {
490                                 String response = execution.getVariable("sdncAssignResponse")
491                                 String data = utils.getNodeXml(response, "response-data")
492                                 msoLogger.debug("Assign responseData: " + data)
493                                 serviceOperation = utils.getNodeText(data, "object-path")
494                                 msoLogger.debug("AR service operation:" + serviceOperation)
495                         }
496
497                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
498                         String sdncRequestId = UUID.randomUUID().toString()
499                         
500                         //neeed the same url as used by vfmodules
501                         String SDNCGetRequest =
502                         """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
503                                                                                         xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
504                                                                                         xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
505                                         <sdncadapter:RequestHeader>
506                                         <sdncadapter:RequestId>${MsoUtils.xmlEscape(sdncRequestId)}</sdncadapter:RequestId>
507                                         <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
508                                         <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
509                                         <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
510                                         <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
511                                         <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
512                                 </sdncadapter:RequestHeader>
513                                         <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
514                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
515
516                         execution.setVariable("sdncGetRequest", SDNCGetRequest)
517
518                 }catch(Exception e){
519                         msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
520                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage())
521                 }
522                 msoLogger.trace("end preProcessSDNCGet")
523         }
524         
525         public void updateAaiAROrchStatus(DelegateExecution execution, String status){
526
527                 msoLogger.trace("start updateAaiAROrchStatus")
528                 String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create
529                 AllottedResourceUtils arUtils = new AllottedResourceUtils(this)
530                 String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath)
531                 msoLogger.trace("end updateAaiAROrchStatus")
532         }
533         
534         public void generateOutputs(DelegateExecution execution)
535         {
536
537                 msoLogger.trace("start generateOutputs")
538                 try {
539                         String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped
540                         msoLogger.debug("resp:" + sdncGetResponse)
541                         String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology")
542                         arData = utils.removeXmlNamespaces(arData)
543                 
544                         String txca = utils.getNodeXml(arData, "tunnelxconn-assignments")
545                         execution.setVariable("vni", utils.getNodeText(txca, "vni"))
546                         execution.setVariable("vgmuxBearerIP", utils.getNodeText(txca, "vgmux-bearer-ip"))
547                         execution.setVariable("vgmuxLanIP", utils.getNodeText(txca, "vgmux-lan-ip"))
548                         
549                         String ari = utils.getNodeXml(arData, "allotted-resource-identifiers")
550                         execution.setVariable("allotedResourceName", utils.getNodeText(ari, "allotted-resource-name"))
551                 } catch (BpmnError e) {
552                         msoLogger.debug("BPMN Error in generateOutputs ")
553                 } catch(Exception ex) {
554                         String msg = "Exception in generateOutputs " + ex.getMessage()
555                         msoLogger.debug(msg)
556                 }
557                 msoLogger.trace("end generateOutputs")
558                 
559         }
560
561         public void preProcessRollback (DelegateExecution execution) {
562
563                 msoLogger.trace("start preProcessRollback")
564                 try {
565
566                         Object workflowException = execution.getVariable("WorkflowException");
567
568                         if (workflowException instanceof WorkflowException) {
569                                 msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage())
570                                 execution.setVariable("prevWorkflowException", workflowException);
571                                 //execution.setVariable("WorkflowException", null);
572                         }
573                 } catch (BpmnError e) {
574                         msoLogger.debug("BPMN Error during preProcessRollback")
575                 } catch(Exception ex) {
576                         String msg = "Exception in preProcessRollback. " + ex.getMessage()
577                         msoLogger.debug(msg)
578                 }
579                 msoLogger.trace("end preProcessRollback")
580         }
581
582         public void postProcessRollback (DelegateExecution execution) {
583
584                 msoLogger.trace("start postProcessRollback")
585                 String msg = ""
586                 try {
587                         Object workflowException = execution.getVariable("prevWorkflowException");
588                         if (workflowException instanceof WorkflowException) {
589                                 msoLogger.debug("Setting prevException to WorkflowException: ")
590                                 execution.setVariable("WorkflowException", workflowException);
591                         }
592                         execution.setVariable("rollbackData", null)
593                 } catch (BpmnError b) {
594                         msoLogger.debug("BPMN Error during postProcessRollback")
595                         throw b;
596                 } catch(Exception ex) {
597                         msg = "Exception in postProcessRollback. " + ex.getMessage()
598                         msoLogger.debug(msg)
599                 }
600                 msoLogger.trace("end postProcessRollback")
601         }
602
603 }