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