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