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