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