078d68bd75ae34843349c7d42384aa086b7bc6f5
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / Delete3rdONAPE2EServiceInstance.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - SO
4  * ================================================================================
5  * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.infrastructure.scripts
22
23 import javax.ws.rs.NotFoundException
24 import javax.ws.rs.core.Response
25
26 import org.apache.commons.lang3.StringUtils
27 import static org.apache.commons.lang3.StringUtils.*
28 import org.camunda.bpm.engine.delegate.BpmnError
29 import org.camunda.bpm.engine.delegate.DelegateExecution
30 import org.json.JSONArray
31 import org.json.JSONObject
32 import org.onap.aai.domain.yang.SpPartner
33 import org.onap.so.bpmn.common.recipe.ResourceInput
34 import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
35 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
36 import org.onap.so.bpmn.common.scripts.ExceptionUtil
37 import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
38 import org.onap.so.bpmn.core.json.JsonUtils
39 import org.onap.so.bpmn.core.UrnPropertiesReader
40 import org.onap.so.client.aai.AAIObjectType
41 import org.onap.so.client.aai.AAIResourcesClient
42 import org.onap.so.client.aai.entities.uri.AAIResourceUri
43 import org.onap.so.client.aai.entities.uri.AAIUriFactory
44 import org.onap.so.logger.MsoLogger
45
46 /**
47  * This groovy class supports the <class>Delete3rdONAPE2EServiceInstance.bpmn</class> process.
48  * flow for Delete 3rdONAPE2EServiceInstance in 3rdONAP
49  */
50 public class Delete3rdONAPE2EServiceInstance extends AbstractServiceTaskProcessor {
51
52         String Prefix = "CRE3rdONAPESI_"
53
54         ExceptionUtil exceptionUtil = new ExceptionUtil()
55
56         JsonUtils jsonUtil = new JsonUtils()
57
58         private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, Delete3rdONAPE2EServiceInstance.class)
59
60         public void checkSPPartnerInfoFromAAI (DelegateExecution execution) {
61                 msoLogger.info(" ***** Started checkSPPartnerInfo *****")
62                 try {
63                         //get bpmn inputs from resource request.
64                         String requestId = execution.getVariable("mso-request-id")
65                         String requestAction = execution.getVariable("requestAction")
66                         msoLogger.info("The requestAction is: " + requestAction)
67                         String recipeParamsFromRequest = execution.getVariable("recipeParams")
68                         msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
69                         String resourceInput = execution.getVariable("resourceInput")
70                         msoLogger.info("The resourceInput is: " + resourceInput)
71                         //Get ResourceInput Object
72                         ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
73                         // set local resourceInput
74                         execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
75
76                         String resourceInstanceId = resourceInputObj.getResourceInstancenUuid()
77                         String sppartnerId = resourceInstanceId
78                         execution.setVariable(Prefix + "SppartnerId", sppartnerId)
79
80                         // Get Sppartner from AAI
81                         getSPPartnerInAAI(execution)
82
83                         String callSource = "UUI"
84                         String sppartnerUrl = ""
85                         if(execution.hasVariable(Prefix + "CallSource")) {
86                                 callSource = execution.getVariable(Prefix + "CallSource")
87                                 sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
88                         }
89
90                         boolean is3rdONAPExist = false
91                         if(!isBlank(sppartnerUrl)) {
92                                 is3rdONAPExist = true
93                         }
94
95                         execution.setVariable("Is3rdONAPExist", is3rdONAPExist)
96                         execution.setVariable(Prefix + "ServiceInstanceId", resourceInputObj.getServiceInstanceId())
97                         execution.setVariable("mso-request-id", requestId)
98                         execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
99
100                 } catch (Exception ex){
101                         String msg = "Exception in checkSPPartnerInfoFromAAI " + ex.getMessage()
102                         msoLogger.debug(msg)
103 //                      exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
104                 }
105         }
106
107         public void checkLocallCall (DelegateExecution execution) {
108                 msoLogger.info(" ***** Started checkLocallCall *****")
109
110                 boolean isLocalCall = true
111                 String callSource = execution.getVariable(Prefix + "CallSource")
112                 if("ExternalAPI".equalsIgnoreCase(callSource)) {
113                         isLocalCall = false
114                 }
115                 execution.setVariable("IsLocalCall", isLocalCall)
116         }
117
118         public void preProcessRequest(DelegateExecution execution){
119                 msoLogger.info(" ***** Started preProcessRequest *****")
120                 String msg = ""
121
122                 try {
123                         ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
124
125                         String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
126                         if (isBlank(globalSubscriberId)) {
127                                 msg = "Input globalSubscriberId is null"
128                                 msoLogger.error( msg)
129                         }
130                         //set local variable
131                         execution.setVariable("globalSubscriberId", globalSubscriberId)
132                         msoLogger.info( "globalSubscriberId:" + globalSubscriberId)
133
134                         String serviceType = resourceInputObj.getServiceType()
135                         if (isBlank(serviceType)) {
136                                 msg = "Input serviceType is null"
137                                 msoLogger.error( msg)
138                         }
139                         execution.setVariable("serviceType", serviceType)
140                         msoLogger.info( "serviceType:" + serviceType)
141
142                         String operationId = resourceInputObj.getOperationId()
143                         if (isBlank(operationId)) {
144                                 msg = "Input operationId is null"
145                                 msoLogger.error( msg)
146                         }
147                         execution.setVariable("operationId", operationId)
148                         msoLogger.info( "operationId:" + operationId)
149
150                         String resourceName = resourceInputObj.getResourceInstanceName()
151                         if (isBlank(resourceName)) {
152                                 msg = "Input resourceName is null"
153                                 msoLogger.error( msg)
154                         }
155                         execution.setVariable("resourceName", resourceName)
156                         msoLogger.info("resourceName:" + resourceName)
157
158                         String resourceTemplateId = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
159                         if (isBlank(resourceTemplateId)) {
160                                 msg = "Input resourceTemplateId is null"
161                                 msoLogger.error( msg)
162                         }
163                         execution.setVariable("resourceTemplateId", resourceTemplateId)
164                         msoLogger.info( "resourceTemplateId:" + resourceTemplateId)
165
166                 } catch (Exception ex){
167                         msg = "Exception in preProcessRequest " + ex.getMessage()
168                         msoLogger.debug(msg)
169 //                      exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
170                 }
171         }
172
173         public void prepareUpdateProgress(DelegateExecution execution) {
174                 msoLogger.info(" ***** Started prepareUpdateProgress *****")
175                 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
176                 String operType = resourceInputObj.getOperationType()
177                 String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
178                 String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
179                 String modelName = resourceInputObj.getResourceModelInfo().getModelName()
180                 String operationId = resourceInputObj.getOperationId()
181                 String progress = execution.getVariable("progress")
182                 String status = execution.getVariable("status")
183                 String statusDescription = execution.getVariable("statusDescription")
184
185                 String body = """
186                 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
187                         xmlns:ns="http://org.onap.so/requestsdb">
188                         <soapenv:Header/>
189                 <soapenv:Body>
190                     <ns:updateResourceOperationStatus>
191                                <operType>${operType}</operType>
192                                <operationId>${operationId}</operationId>
193                                <progress>${progress}</progress>
194                                <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
195                                <serviceId>${ServiceInstanceId}</serviceId>
196                                <status>${status}</status>
197                                <statusDescription>${statusDescription}</statusDescription>
198                     </ns:updateResourceOperationStatus>
199                 </soapenv:Body>
200                 </soapenv:Envelope>"""
201
202                 setProgressUpdateVariables(execution, body)
203                 msoLogger.info(" ***** End prepareUpdateProgress *****")
204         }
205
206         public void prepare3rdONAPRequest(DelegateExecution execution) {
207                 msoLogger.info(" ***** Started prepare3rdONAPRequest *****")
208
209                 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
210                 String extAPIPath = sppartnerUrl + '/serviceOrder'
211                 execution.setVariable("ExternalAPIURL", extAPIPath)
212
213                 // ExternalAPI message format
214                 String externalId = execution.getVariable("resourceName")
215                 String category = "E2E Service"
216                 String description = "Service Order from SPPartner"
217                 String requestedStartDate = utils.generateCurrentTimeInUtc()
218                 String requestedCompletionDate = utils.generateCurrentTimeInUtc()
219                 String priority = "1" // 0-4 0:highest
220                 String subscriberId = execution.getVariable("globalSubscriberId")
221                 String customerRole = "ONAPcustomer"
222                 String subscriberName = subscriberId
223                 String referredType = "Consumer"
224                 String orderItemId = "1"
225                 String action = "delete" //for delete
226                 String serviceState = "active"
227                 String serviceName = ""
228                 String serviceType = execution.getVariable("serviceType")
229                 String serviceId = execution.getVariable(Prefix + "SppartnerId")
230
231                 queryServicefrom3rdONAP(execution)
232                 String serviceSpecificationId = execution.getVariable(Prefix + "ServiceSpecificationId")
233
234                 Map<String, String> valueMap = new HashMap<>()
235                 valueMap.put("externalId", '"' + externalId + '"')
236                 valueMap.put("category", '"' + category + '"')
237                 valueMap.put("description", '"' + description + '"')
238                 valueMap.put("requestedStartDate", '"' + requestedStartDate + '"')
239                 valueMap.put("requestedCompletionDate", '"' + requestedCompletionDate + '"')
240                 valueMap.put("priority", '"'+ priority + '"')
241                 valueMap.put("subscriberId", '"' + subscriberId + '"')
242                 valueMap.put("customerRole", '"' + customerRole + '"')
243                 valueMap.put("subscriberName", '"' + subscriberName + '"')
244                 valueMap.put("referredType", '"' + referredType + '"')
245                 valueMap.put("orderItemId", '"' + orderItemId + '"')
246                 valueMap.put("action", '"' + action + '"')
247                 valueMap.put("serviceState", '"' + serviceState + '"')
248                 valueMap.put("serviceId", '"' + serviceId + '"')
249                 valueMap.put("serviceName", "null")
250                 valueMap.put("serviceUuId", '"' + serviceSpecificationId + '"')
251
252                 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
253
254                 valueMap.put("_requestInputs_",  "")
255
256                 String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
257                 execution.setVariable(Prefix + "Payload", payload)
258                 msoLogger.info( "Exit " + prepare3rdONAPRequest)
259         }
260
261         private void queryServicefrom3rdONAP(DelegateExecution execution)
262         {
263                 msoLogger.info(" ***** Started queryServicefrom3rdONAP *****")
264         try {
265
266                 String globalSubscriberId = execution.getVariable("globalSubscriberId")
267                 String SppartnerServiceId = execution.getVariable(Prefix + "SppartnerId")
268
269                 //https://{api_url}/nbi/api/v1/service?relatedParty.id=${globalSubscriberId}
270                 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
271                 String extAPIPath = sppartnerUrl + "/service?relatedParty.id=" + globalSubscriberId
272                 msoLogger.debug("queryServicefrom3rdONAP externalAPIURL is: " + extAPIPath)
273
274                 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
275
276                 Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
277
278                 int responseCode = response.getStatus()
279                 execution.setVariable(Prefix + "GetServiceResponseCode", responseCode)
280                 msoLogger.debug("Get Service response code is: " + responseCode)
281
282                 String extApiResponse = response.readEntity(String.class)
283
284                 execution.setVariable(Prefix + "GetServiceResponse", extApiResponse)
285                 msoLogger.debug("queryServicefrom3rdONAP response body is: " + extApiResponse)
286
287                 //Process Response //200 OK 201 CREATED 202 ACCEPTED
288                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
289                 {
290                         msoLogger.debug("Get Service Received a Good Response")
291                         JSONArray responseList = new JSONArray(extApiResponse)
292                         for(JSONObject obj : responseList) {
293                                 String svcId  = obj.get("id")
294                                 if(StringUtils.equalsIgnoreCase(SppartnerServiceId, svcId)) {
295                                         JSONObject serviceSpecification = obj.get("serviceSpecification")
296                                         String serviceUuid = serviceSpecification.get("id")
297                                         execution.setVariable(Prefix + "ServiceSpecificationId", serviceUuid)
298                                         break
299                                 }
300                         }
301                 }
302                 else{
303                         msoLogger.error("Get Service Received a Bad Response Code. Response Code is: " + responseCode)
304 //                      exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Service Received a bad response from 3rdONAP External API")
305                 }
306         }catch(Exception e) {
307             msoLogger.error("queryServicefrom3rdONAP exception:" + e.getMessage())
308         }
309                 msoLogger.info( "Exit " + queryServicefrom3rdONAP)
310         }
311
312         public void doDeleteE2ESIin3rdONAP(DelegateExecution execution) {
313                 msoLogger.info(" ***** Started doDeleteE2ESIin3rdONAP *****")
314                 try {
315                 String extAPIPath = execution.getVariable("ExternalAPIURL")
316                 String payload = execution.getVariable(Prefix + "Payload")
317                 msoLogger.debug("doDeleteE2ESIin3rdONAP externalAPIURL is: " + extAPIPath)
318                 msoLogger.debug("doDeleteE2ESIin3rdONAP payload is: " + payload)
319
320                 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
321                 execution.setVariable("ServiceOrderId", "")
322
323                 Response response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
324
325                 int responseCode = response.getStatus()
326                 execution.setVariable(Prefix + "PostServiceOrderResponseCode", responseCode)
327                 msoLogger.debug("Post ServiceOrder response code is: " + responseCode)
328
329                 String extApiResponse = response.readEntity(String.class)
330                 JSONObject responseObj = new JSONObject(extApiResponse)
331                 execution.setVariable(Prefix + "PostServiceOrderResponse", extApiResponse)
332
333                 msoLogger.debug("doDeleteE2ESIin3rdONAP response body is: " + extApiResponse)
334
335                 //Process Response
336                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
337                         //200 OK 201 CREATED 202 ACCEPTED
338                 {
339                         msoLogger.debug("Post ServiceOrder Received a Good Response")
340                         String serviceOrderId = responseObj.get("id")
341                         execution.setVariable(Prefix + "SuccessIndicator", true)
342                         execution.setVariable("ServiceOrderId", serviceOrderId)
343                         msoLogger.info("Post ServiceOrderid is: " + serviceOrderId)
344                 }
345                 else{
346                         msoLogger.error("Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
347 //                      exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
348                 }
349                 }catch(Exception e) {
350                         msoLogger.error("doDeleteE2ESIin3rdONAP exception:" + e.getMessage())
351                 }
352                 msoLogger.info( "Exit " + doDeleteE2ESIin3rdONAP)
353         }
354
355
356         public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
357                 msoLogger.info(" ***** Started getE2ESIProgressin3rdONAP *****")
358         try {
359
360                 String extAPIPath = execution.getVariable("ExternalAPIURL")
361                 extAPIPath += "/" + execution.getVariable("ServiceOrderId")
362                 msoLogger.debug("getE2ESIProgressin3rdONAP delete externalAPIURL is: " + extAPIPath)
363
364                 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil()
365
366                 Response response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
367
368                 int responseCode = response.getStatus()
369                 execution.setVariable(Prefix + "GetServiceOrderResponseCode", responseCode)
370                 msoLogger.debug("Get ServiceOrder response code is: " + responseCode)
371
372                 String extApiResponse = response.readEntity(String.class)
373                 JSONObject responseObj = new JSONObject(extApiResponse)
374                 execution.setVariable(Prefix + "GetServiceOrderResponse", extApiResponse)
375
376                 utils.log("DEBUG", "getE2ESIProgressin3rdONAP delete response body is: " + extApiResponse)
377
378                 //Process Response //200 OK 201 CREATED 202 ACCEPTED
379                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
380                 {
381                         msoLogger.debug("Get ServiceOrder Received a Good Response")
382
383                         String orderState = responseObj.get("state")
384                         if("REJECTED".equalsIgnoreCase(orderState)) {
385                                 execution.setVariable("progress", 100)
386                                 execution.setVariable("status", "error")
387                                 execution.setVariable("statusDescription", "Delete Service Order Status is REJECTED")
388                                 return
389                         }
390
391                         JSONArray items = responseObj.getJSONArray("orderItem")
392                         JSONObject item = items[0]
393                         JSONObject service = item.get("service")
394                         String sppartnerServiceId = service.get("id")
395                         if(sppartnerServiceId == null || sppartnerServiceId.equals("null")) {
396                                 execution.setVariable("progress", 100)
397                                 execution.setVariable("status", "error")
398                                 execution.setVariable("statusDescription", "Delete Service Order Status get null sppartnerServiceId")
399                                 msoLogger.error("null sppartnerServiceId while getting progress from externalAPI")
400                                 return
401                         }
402                         execution.setVariable(Prefix + "SppartnerServiceId", sppartnerServiceId)
403
404                         String serviceOrderState = item.get("state")
405                         execution.setVariable(Prefix + "SuccessIndicator", true)
406                         execution.setVariable("ServiceOrderState", serviceOrderState)
407
408                         // Get serviceOrder State and process progress
409                         if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
410                                 execution.setVariable("progress", 15)
411                                 execution.setVariable("status", "processing")
412                                 execution.setVariable("statusDescription", "Delete Service Order Status is " + serviceOrderState)
413                         }
414                         else if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
415                                 execution.setVariable("progress", 40)
416                                 execution.setVariable("status", "processing")
417                                 execution.setVariable("statusDescription", "Delete Service Order Status is " + serviceOrderState)
418                         }
419                         else if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
420                                 execution.setVariable("progress", 100)
421                                 execution.setVariable("status", "finished")
422                                 execution.setVariable("statusDescription", "Delete Service Order Status is " + serviceOrderState)
423                         }
424                         else if("FAILED".equalsIgnoreCase(serviceOrderState)) {
425                                 execution.setVariable("progress", 100)
426                                 execution.setVariable("status", "error")
427                                 execution.setVariable("statusDescription", "Delete Service Order Status is " + serviceOrderState)
428                         }
429                         else {
430                                 execution.setVariable("progress", 100)
431                                 execution.setVariable("status", "error")
432                                 execution.setVariable("statusDescription", "Delete Service Order Status is unknown")
433                         }
434                 }
435                 else{
436                         msoLogger.debug("Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode)
437                         execution.setVariable("progress", 100)
438                         execution.setVariable("status", "error")
439                         execution.setVariable("statusDescription", "Get Delete ServiceOrder Received a bad response")
440 //                      exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get Delete ServiceOrder Received a bad response from 3rdONAP External API")
441                 }
442         }catch(Exception e) {
443             execution.setVariable("progress", 100)
444             execution.setVariable("status", "error")
445             execution.setVariable("statusDescription", "Get Delete ServiceOrder Exception")
446             msoLogger.error("getE2ESIProgressin3rdONAP exception:" + e.getMessage())
447         }
448                 msoLogger.info( "Exit " + getE2ESIProgressin3rdONAP)
449         }
450
451         /**
452          * delay 5 sec
453          */
454         public void timeDelay(DelegateExecution execution) {
455                 try {
456                         Thread.sleep(5000)
457                 } catch(InterruptedException e) {
458                         msoLogger.error("Time Delay exception" + e )
459                 }
460         }
461
462         private void getSPPartnerInAAI(DelegateExecution execution) {
463                 msoLogger.info(" ***** Started getSPPartnerInAAI *****")
464         try {
465                 String id = execution.getVariable(Prefix + "SppartnerId")
466
467                 AAIResourcesClient client = new AAIResourcesClient()
468                 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, id)
469                 SpPartner sp = client.get(uri).asBean(SpPartner.class).get()
470
471                 msoLogger.debug("GET sppartner Received a Good Response")
472                 execution.setVariable(Prefix + "SuccessIndicator", true)
473                 execution.setVariable(Prefix + "FoundIndicator", true)
474
475 //              String sppartnerId = sp.getSpPartnerId()
476 //              execution.setVariable(Prefix + "SppartnerId", sppartnerId)
477 //              msoLogger.debug(" SppartnerId is: " + sppartnerId)
478                 String sppartnerUrl = sp.getUrl()
479                 execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
480                 msoLogger.debug(" SppartnerUrl is: " + sppartnerUrl)
481                 String callSource = sp.getCallsource()
482                 execution.setVariable(Prefix + "CallSource", callSource)
483                 msoLogger.debug(" CallSource is: " + callSource)
484                 String sppartnerVersion = sp.getResourceVersion()
485                 execution.setVariable(Prefix + "SppartnerVersion", sppartnerVersion)
486                 msoLogger.debug(" Resource Version is: " + sppartnerVersion)
487         } catch (Exception ex) {
488             String msg = "Exception in Delete3rdONAPE2EServiceInstance.saveSPPartnerInAAI. " + ex.getMessage()
489             msoLogger.debug(msg)
490 //            throw new BpmnError("MSOWorkflowException")
491         }
492
493                 msoLogger.info( "Exit " + getSPPartnerInAAI)
494         }
495
496         public void deleteSPPartnerInAAI(DelegateExecution execution) {
497                 msoLogger.info(" ***** Started deleteSPPartnerInAAI *****")
498         try {
499
500                 String sppartnerId = execution.getVariable(Prefix + "SppartnerId")
501
502                 AAIResourcesClient client = new AAIResourcesClient()
503                 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SP_PARTNER, sppartnerId)
504                 client.delete(uri)
505                 msoLogger.debug("Delete sppartner Received a Good Response")
506                 execution.setVariable(Prefix + "SuccessIndicator", true)
507         } catch (Exception ex) {
508             String msg = "Exception in Delete3rdONAPE2EServiceInstance.deleteSPPartnerInAAI. " + ex.getMessage()
509             msoLogger.debug(msg)
510 //            throw new BpmnError("MSOWorkflowException")
511         }
512                 
513
514                 msoLogger.info( "Exit " + deleteSPPartnerInAAI)
515         }
516
517         private void setProgressUpdateVariables(DelegateExecution execution, String body) {
518                 def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint", execution)
519                 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
520                 execution.setVariable("CVFMI_updateResOperStatusRequest", body)
521         }
522
523         public void postProcess(DelegateExecution execution){
524                 msoLogger.info(" ***** Started postProcess *****")
525                 String responseCode = execution.getVariable(Prefix + "PutSppartnerResponseCode")
526                 String responseObj = execution.getVariable(Prefix + "PutSppartnerResponse")
527
528                 msoLogger.info("response from AAI for put sppartner, response code :" + responseCode + "  response object :" + responseObj)
529                 msoLogger.info(" ***** Exit postProcess *****")
530         }
531
532         public void sendSyncResponse (DelegateExecution execution) {
533                 msoLogger.debug(" *** sendSyncResponse *** ")
534
535                 try {
536                         String operationStatus = "finished"
537                         // RESTResponse for main flow
538                         String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
539                         msoLogger.debug(" sendSyncResponse to APIH:" + "\n" + resourceOperationResp)
540                         sendWorkflowResponse(execution, 202, resourceOperationResp)
541                         execution.setVariable("sentSyncResponse", true)
542
543                 } catch (Exception ex) {
544                         String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
545                         msoLogger.debug(msg)
546 //                      exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
547                 }
548                 msoLogger.debug(" ***** Exit sendSyncResopnse *****")
549         }
550 }