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