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