Merge "conflict process"
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoCreateE2EServiceInstance.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21 package org.onap.so.bpmn.infrastructure.scripts;
22
23 import static org.apache.commons.lang3.StringUtils.*;
24
25 import javax.ws.rs.NotFoundException
26
27 import org.apache.commons.lang3.*
28 import org.camunda.bpm.engine.delegate.BpmnError
29 import org.camunda.bpm.engine.delegate.DelegateExecution
30 import org.onap.aai.domain.yang.ServiceInstance
31 import org.onap.so.bpmn.common.scripts.AaiUtil
32 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
33 import org.onap.so.bpmn.common.scripts.CatalogDbUtils;
34 import org.onap.so.bpmn.common.scripts.ExceptionUtil
35 import org.onap.so.bpmn.common.scripts.MsoUtils
36 import org.onap.so.bpmn.core.RollbackData
37 import org.onap.so.bpmn.core.WorkflowException
38 import org.onap.so.bpmn.core.domain.Resource
39 import org.onap.so.bpmn.core.domain.ServiceDecomposition
40 import org.onap.so.bpmn.core.json.JsonUtils
41 import org.onap.so.client.aai.AAIObjectType
42 import org.onap.so.client.aai.AAIResourcesClient
43 import org.onap.so.client.aai.entities.AAIResultWrapper
44 import org.onap.so.client.aai.entities.uri.AAIResourceUri
45 import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
46 import org.onap.so.client.aai.entities.uri.AAIUriFactory
47 import org.onap.so.logger.MessageEnum
48 import org.onap.so.logger.MsoLogger
49 import org.onap.so.rest.APIResponse
50 import org.springframework.web.util.UriUtils;
51
52 import groovy.json.*
53
54
55
56 /**
57  * This groovy class supports the <class>DoCreateServiceInstance.bpmn</class> process.
58  *
59  * Inputs:
60  * @param - msoRequestId
61  * @param - globalSubscriberId
62  * @param - subscriptionServiceType
63  * @param - serviceInstanceId
64  * @param - serviceInstanceName - O
65  * @param - serviceModelInfo
66  * @param - productFamilyId
67  * @param - disableRollback
68  * @param - failExists - TODO
69  * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
70  * @param - sdncVersion ("1610")
71  * @param - serviceDecomposition - Decomposition for R1710
72  * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored)
73  *
74  * Outputs:
75  * @param - rollbackData (localRB->null)
76  * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
77  * @param - WorkflowException
78  * @param - serviceInstanceName - (GET from AAI if null in input)
79  *
80  */
81 public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor {
82         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateE2EServiceInstance.class);
83
84
85         String Prefix="DCRESI_"
86         ExceptionUtil exceptionUtil = new ExceptionUtil()
87         JsonUtils jsonUtil = new JsonUtils()
88         CatalogDbUtils cutils = new CatalogDbUtils()
89
90         public void preProcessRequest (DelegateExecution execution) {
91                 String msg = ""
92                 msoLogger.trace("preProcessRequest ")
93
94                 try {
95                         execution.setVariable("prefix", Prefix)
96                         //Inputs
97                         //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
98                         String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
99                         msoLogger.info(" ***** globalSubscriberId *****" + globalSubscriberId)
100                         //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
101                         String serviceType = execution.getVariable("serviceType")
102                         msoLogger.info(" ***** serviceType *****" + serviceType)
103                         //requestDetails.requestParameters. for SDNC assignTopology
104                         String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId
105
106                         if (isBlank(globalSubscriberId)) {
107                                 msg = "Input globalSubscriberId is null"
108                                 msoLogger.info(msg)
109                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
110                         }
111
112                         if (isBlank(serviceType)) {
113                                 msg = "Input serviceType is null"
114                                 msoLogger.info(msg)
115                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
116                         }
117
118                         if (productFamilyId == null) {
119                                 execution.setVariable("productFamilyId", "")
120                         }
121
122                         String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
123                         if (isBlank(sdncCallbackUrl)) {
124                                 msg = "URN_mso_workflow_sdncadapter_callback is null"
125                                 msoLogger.info(msg)
126                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
127                         }
128                         execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
129                         msoLogger.info("SDNC Callback URL: " + sdncCallbackUrl)
130
131                         //requestDetails.modelInfo.for AAI PUT servieInstanceData
132                         //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData
133                         String serviceInstanceName = execution.getVariable("serviceInstanceName")
134                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
135                         String uuiRequest = execution.getVariable("uuiRequest")
136                         String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid")
137                         String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid")
138                         String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName")
139                         execution.setVariable("serviceModelName", serviceModelName)
140                         //aai serviceType and Role can be setted as fixed value now.
141                         String aaiServiceType = "E2E Service"
142                         String aaiServiceRole = "E2E Service"
143
144                         execution.setVariable("modelInvariantUuid", modelInvariantUuid)
145                         execution.setVariable("modelUuid", modelUuid)
146
147                         //AAI PUT
148                         String oStatus = execution.getVariable("initialStatus") ?: ""
149                         if ("TRANSPORT".equalsIgnoreCase(serviceType))
150                         {
151                                 oStatus = "Created"
152                         }
153
154                         String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${MsoUtils.xmlEscape(oStatus)}</orchestration-status>"
155
156                         AaiUtil aaiUriUtil = new AaiUtil(this)
157                         String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
158                         String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
159                         String serviceInstanceData =
160                                         """<service-instance xmlns=\"${namespace}\">
161                                 <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
162                                 <service-instance-name>${MsoUtils.xmlEscape(serviceInstanceName)}</service-instance-name>
163                                         <service-type>${MsoUtils.xmlEscape(aaiServiceType)}</service-type>
164                                         <service-role>${MsoUtils.xmlEscape(aaiServiceRole)}</service-role>
165                                         ${statusLine}
166                                     <model-invariant-id>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-id>
167                                     <model-version-id>${MsoUtils.xmlEscape(modelUuid)}</model-version-id>
168                                         </service-instance>""".trim()
169                         execution.setVariable("serviceInstanceData", serviceInstanceData)
170                         msoLogger.debug(serviceInstanceData)
171                         msoLogger.info(" aai_uri " + aai_uri + " namespace:" + namespace)
172                         msoLogger.info(" 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData)
173
174                 } catch (BpmnError e) {
175                         throw e;
176                 } catch (Exception ex){
177                         msg = "Exception in preProcessRequest " + ex.getMessage()
178                         msoLogger.info(msg)
179                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
180                 }
181                 msoLogger.trace("Exit preProcessRequest ")
182         }
183
184    public void prepareDecomposeService(DelegateExecution execution) {
185         try {
186             msoLogger.trace("Inside prepareDecomposeService of create generic e2e service ")
187             String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
188             String modelUuid = execution.getVariable("modelUuid")
189             //here modelVersion is not set, we use modelUuid to decompose the service.
190             String serviceModelInfo = """{
191             "modelInvariantUuid":"${modelInvariantUuid}",
192             "modelUuid":"${modelUuid}",
193             "modelVersion":""
194              }"""
195             execution.setVariable("serviceModelInfo", serviceModelInfo)
196
197             msoLogger.trace("Completed prepareDecomposeService of  create generic e2e service ")
198         } catch (Exception ex) {
199             // try error in method block
200             String exceptionMessage = "Bpmn error encountered in  create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage()
201             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
202         }
203      }
204
205     public void processDecomposition(DelegateExecution execution) {
206         msoLogger.trace("Inside processDecomposition() of  create generic e2e service flow ")
207         try {
208             ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
209         } catch (Exception ex) {
210             String exceptionMessage = "Bpmn error encountered in  create generic e2e service flow. processDecomposition() - " + ex.getMessage()
211             msoLogger.debug(exceptionMessage)
212             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
213         }
214     }
215
216     public void doServicePreOperation(DelegateExecution execution){
217        //we need a service plugin platform here.
218         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
219         String uuiRequest = execution.getVariable("uuiRequest")
220         String newUuiRequest = ServicePluginFactory.getInstance().preProcessService(serviceDecomposition, uuiRequest);
221         execution.setVariable("uuiRequest", newUuiRequest)
222     }
223
224     public void doServiceHoming(DelegateExecution execution) {
225         //we need a service plugin platform here.
226         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
227         String uuiRequest = execution.getVariable("uuiRequest")
228         String newUuiRequest = ServicePluginFactory.getInstance().doServiceHoming(serviceDecomposition, uuiRequest);
229         execution.setVariable("uuiRequest", newUuiRequest)
230     }
231
232         public void postProcessAAIGET(DelegateExecution execution) {
233                 msoLogger.trace("postProcessAAIGET ")
234                 String msg = ""
235
236                 try {
237                         String serviceInstanceName = execution.getVariable("serviceInstanceName")
238                         boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
239                         if(!succInAAI){
240                                 msoLogger.info("Error getting Service-instance from AAI", + serviceInstanceName)
241                                 WorkflowException workflowException = execution.getVariable("WorkflowException")
242                                 msoLogger.debug("workflowException: " + workflowException)
243                                 if(workflowException != null){
244                                         exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
245                                 }
246                                 else
247                                 {
248                                         msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
249                                         msoLogger.info(msg)
250                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
251                                 }
252                         }
253                         else
254                         {
255                                 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
256                                 if(foundInAAI){
257                                         msoLogger.info("Found Service-instance in AAI")
258                                         msg = "ServiceInstance already exists in AAI:" + serviceInstanceName
259                                         msoLogger.info(msg)
260                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
261                                 }
262                         }
263                 } catch (BpmnError e) {
264                         throw e;
265                 } catch (Exception ex) {
266                         msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage()
267                         msoLogger.info(msg)
268                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
269                 }
270                 msoLogger.trace("Exit postProcessAAIGET ")
271         }
272
273         //TODO use create if not exist
274         public void postProcessAAIPUT(DelegateExecution execution) {
275                 msoLogger.trace("postProcessAAIPUT ")
276                 String msg = ""
277                 try {
278                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
279                         boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator")
280                         if(!succInAAI){
281                                 msoLogger.info("Error putting Service-instance in AAI", + serviceInstanceId)
282                                 WorkflowException workflowException = execution.getVariable("WorkflowException")
283                                 msoLogger.debug("workflowException: " + workflowException)
284                                 if(workflowException != null){
285                                         exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
286                                 }
287                         }
288                         else
289                         {
290                                 //start rollback set up
291                                 RollbackData rollbackData = new RollbackData()
292                                 def disableRollback = execution.getVariable("disableRollback")
293                                 rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
294                                 rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
295                                 rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
296                                 rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
297                                 rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
298                                 execution.setVariable("rollbackData", rollbackData)
299                         }
300
301                 } catch (BpmnError e) {
302                         throw e;
303                 } catch (Exception ex) {
304                         msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
305                         msoLogger.info(msg)
306                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
307                 }
308                 msoLogger.trace("Exit postProcessAAIPUT ")
309         }
310
311         /**
312          * Gets the service instance and its relationships from aai
313          */
314         public void getServiceInstance(DelegateExecution execution) {
315                 try {
316                         String serviceInstanceId = execution.getVariable('serviceInstanceId')
317                         String globalSubscriberId = execution.getVariable('globalSubscriberId')
318                         String serviceType = execution.getVariable('subscriptionServiceType')
319
320                         AAIResourcesClient resourceClient = new AAIResourcesClient()
321                         AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, serviceInstanceId)
322                         AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
323
324                         Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
325                         execution.setVariable("serviceInstanceName", si.get().getServiceInstanceName())
326
327                 }catch(BpmnError e) {
328                         throw e;
329                 }catch(Exception ex) {
330                         String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
331                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
332                 }
333         }
334
335
336         public void saveServiceInputToAAI(DelegateExecution execution) {
337                 AaiUtil aaiUriUtil = new AaiUtil(this)
338
339                 // create url for AAI requestInput
340                 String aai_uri = aaiUriUtil.getAAIServiceInstanceUri(execution)
341                 String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
342
343                 String serviceInstanceId = execution.getVariable("serviceInstanceId")
344                 String serviceInstanceName = execution.getVariable("serviceInstanceName")
345                 String serviceType = execution.getVariable("serviceType")
346                 String uuiRequest = execution.getVariable("uuiRequest")
347
348                 String payload =
349                                 """< xmlns=\"${namespace}\">
350                                         <service-instance>
351                                                 <service-instance-id>${serviceInstanceId}</service-instance-id>
352                                                 <service-instance-name>${serviceInstanceName}</service-instance-name>
353                                                 <service-type>${serviceType}</service-type>
354                                         <customer-request>${uuiRequest}</customer-request>
355                                         </service-instance>""".trim()
356                 utils.logAudit(payload)
357
358                 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
359                 String serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(serviceInstanceId,"UTF-8")
360
361                 APIResponse response = aaiUriUtil.executeAAIPutCall(execution, serviceAaiPath, payload)
362                 int responseCode = response.getStatusCode()
363                 execution.setVariable(Prefix + "PutSppartnerResponseCode", responseCode)
364         }
365
366
367         public void postProcessAAIGET2(DelegateExecution execution) {
368                 msoLogger.trace("postProcessAAIGET2 ")
369                 String msg = ""
370
371                 try {
372                         String serviceInstanceName = execution.getVariable("serviceInstanceName")
373                         boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
374                         if(!succInAAI){
375                                 msoLogger.info("Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName)
376                                 WorkflowException workflowException = execution.getVariable("WorkflowException")
377                                 msoLogger.debug("workflowException: " + workflowException)
378                                 if(workflowException != null){
379                                         exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
380                                 }
381                                 else
382                                 {
383                                         msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI
384                                         msoLogger.info(msg)
385                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
386                                 }
387                         }
388                         else
389                         {
390                                 boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
391                                 if(foundInAAI){
392                                         String aaiService = execution.getVariable("GENGS_service")
393                                         if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) {
394                                                 execution.setVariable("serviceInstanceName",  utils.getNodeText(aaiService, "service-instance-name"))
395                                                 msoLogger.info("Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"))
396                                         }
397                                 }
398                         }
399                 } catch (BpmnError e) {
400                         throw e;
401                 } catch (Exception ex) {
402                         msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage()
403                         msoLogger.info(msg)
404                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
405                 }
406                 msoLogger.trace("Exit postProcessAAIGET2 ")
407         }
408
409         public void preProcessRollback (DelegateExecution execution) {
410                 msoLogger.trace("preProcessRollback ")
411                 try {
412
413                         Object workflowException = execution.getVariable("WorkflowException");
414
415                         if (workflowException instanceof WorkflowException) {
416                                 msoLogger.info("Prev workflowException: " + workflowException.getErrorMessage())
417                                 execution.setVariable("prevWorkflowException", workflowException);
418                                 //execution.setVariable("WorkflowException", null);
419                         }
420                 } catch (BpmnError e) {
421                         msoLogger.info("BPMN Error during preProcessRollback")
422                 } catch(Exception ex) {
423                         String msg = "Exception in preProcessRollback. " + ex.getMessage()
424                         msoLogger.info(msg)
425                 }
426                 msoLogger.trace("Exit preProcessRollback ")
427         }
428
429         public void postProcessRollback (DelegateExecution execution) {
430                 msoLogger.trace("postProcessRollback ")
431                 String msg = ""
432                 try {
433                         Object workflowException = execution.getVariable("prevWorkflowException");
434                         if (workflowException instanceof WorkflowException) {
435                                 msoLogger.info("Setting prevException to WorkflowException: ")
436                                 execution.setVariable("WorkflowException", workflowException);
437                         }
438                         execution.setVariable("rollbackData", null)
439                 } catch (BpmnError b) {
440                         msoLogger.info("BPMN Error during postProcessRollback")
441                         throw b;
442                 } catch(Exception ex) {
443                         msg = "Exception in postProcessRollback. " + ex.getMessage()
444                         msoLogger.info(msg)
445                 }
446                 msoLogger.trace("Exit postProcessRollback ")
447         }
448
449         public void preInitResourcesOperStatus(DelegateExecution execution){
450         msoLogger.trace("STARTED preInitResourcesOperStatus Process ")
451         try{
452             String serviceId = execution.getVariable("serviceInstanceId")
453             String operationId = execution.getVariable("operationId")
454             String operationType = execution.getVariable("operationType")
455             String resourceTemplateUUIDs = ""
456             String result = "processing"
457             String progress = "0"
458             String reason = ""
459             String operationContent = "Prepare service creation"
460             msoLogger.info("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType)
461             serviceId = UriUtils.encode(serviceId,"UTF-8")
462             execution.setVariable("serviceInstanceId", serviceId)
463             execution.setVariable("operationId", operationId)
464             execution.setVariable("operationType", operationType)
465             ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
466             List<Resource>  resourceList = serviceDecomposition.getServiceResources()
467
468             for(Resource resource : resourceList){
469                     resourceTemplateUUIDs  = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
470             }
471
472             def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
473             execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
474             msoLogger.info("DB Adapter Endpoint is: " + dbAdapterEndpoint)
475
476             String payload =
477                 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
478                         xmlns:ns="http://org.onap.so/requestsdb">
479                         <soapenv:Header/>
480                         <soapenv:Body>
481                             <ns:initResourceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
482                                                                 <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
483                                                                 <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
484                                                                 <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
485                                                                 <resourceTemplateUUIDs>${MsoUtils.xmlEscape(resourceTemplateUUIDs)}</resourceTemplateUUIDs>
486                             </ns:initResourceOperationStatus>
487                         </soapenv:Body>
488                         </soapenv:Envelope>"""
489
490             payload = utils.formatXml(payload)
491             execution.setVariable("CVFMI_initResOperStatusRequest", payload)
492             msoLogger.info("Outgoing initResourceOperationStatus: \n" + payload)
493             msoLogger.debug("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
494
495         }catch(Exception e){
496             msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preInitResourcesOperStatus.", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, e);
497             execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
498         }
499         msoLogger.trace("COMPLETED preInitResourcesOperStatus Process ")
500         }
501
502         // if site location is in local Operator, create all resources in local ONAP; 
503         // if site location is in 3rd Operator, only process sp-partner to create all resources in 3rd ONAP
504         public void doProcessSiteLocation(DelegateExecution execution){
505                 msoLogger.trace("======== Start doProcessSiteLocation Process ======== ")
506                 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
507                 String uuiRequest = execution.getVariable("uuiRequest")
508                 uuiRequest = ServicePluginFactory.getInstance().doProcessSiteLocation(serviceDecomposition, uuiRequest);
509                 execution.setVariable("uuiRequest", uuiRequest)
510                 execution.setVariable("serviceDecomposition", serviceDecomposition)
511                 
512                 msoLogger.trace("======== COMPLETED doProcessSiteLocation Process ======== ")
513         }
514         
515         // Allocate cross link TPs(terminal points) for sotn network only
516         public void doTPResourcesAllocation(DelegateExecution execution){
517                 msoLogger.trace("======== Start doTPResourcesAllocation Process ======== ")
518                 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
519                 String uuiRequest = execution.getVariable("uuiRequest")
520                 uuiRequest = ServicePluginFactory.getInstance().doTPResourcesAllocation(execution, uuiRequest);
521                 execution.setVariable("uuiRequest", uuiRequest)
522                 msoLogger.trace("======== COMPLETED doTPResourcesAllocation Process ======== ")
523         }
524
525         // prepare input param for using DoCreateResources.bpmn
526         public void preProcessForAddResource(DelegateExecution execution) {
527                 msoLogger.trace("STARTED preProcessForAddResource Process ")
528
529                 ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
530                 List<Resource> addResourceList = serviceDecomposition.getServiceResources()
531                 execution.setVariable("addResourceList", addResourceList)
532
533                 msoLogger.trace("COMPLETED preProcessForAddResource Process ")
534         }
535
536         public void postProcessForAddResource(DelegateExecution execution) {
537                 // do nothing now
538
539         }
540
541 }