88441271b1d825b0de15e6d6ecec0fa7d5ed5e42
[so.git] /
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.json.JSONObject
24 import org.json.XML
25
26 import static org.apache.commons.lang3.StringUtils.*
27 import groovy.xml.XmlUtil
28 import groovy.json.*
29 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
30 import org.onap.so.bpmn.common.scripts.ExceptionUtil
31 import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
32 import org.onap.so.bpmn.common.scripts.AaiUtil
33 import org.onap.so.bpmn.common.scripts.MsoUtils
34 import org.onap.so.bpmn.common.recipe.ResourceInput
35 import org.onap.so.bpmn.common.resource.ResourceRequestBuilder
36 import org.onap.so.bpmn.core.WorkflowException
37 import org.onap.so.bpmn.core.json.JsonUtils
38 import org.onap.so.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
39 import org.onap.so.rest.APIResponse
40 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
41 import org.onap.so.bpmn.infrastructure.workflow.service.ServicePluginFactory
42 import java.util.UUID
43
44 import org.camunda.bpm.engine.runtime.Execution
45 import org.camunda.bpm.engine.delegate.BpmnError
46 import org.camunda.bpm.engine.delegate.DelegateExecution
47 import org.apache.commons.lang3.*
48 import org.apache.commons.codec.binary.Base64
49 import org.springframework.web.util.UriUtils
50 import org.onap.so.rest.RESTClient
51 import org.onap.so.rest.RESTConfig
52
53 /**
54  * This groovy class supports the <class>Delete3rdONAPE2EServiceInstance.bpmn</class> process.
55  * flow for Delete E2EServiceInstance 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         public void checkSPPartnerInfoFromAAI (DelegateExecution execution) {
66                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
67                 utils.log("INFO"," ***** Started checkSPPartnerInfo *****",  isDebugEnabled)
68                 try {
69                         //get bpmn inputs from resource request.
70                         String requestId = execution.getVariable("mso-request-id")
71                         String requestAction = execution.getVariable("requestAction")
72                         utils.log("INFO","The requestAction is: " + requestAction,  isDebugEnabled)
73                         String recipeParamsFromRequest = execution.getVariable("recipeParams")
74                         utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest,  isDebugEnabled)
75                         String resourceInput = execution.getVariable("resourceInput")
76                         utils.log("INFO","The resourceInput is: " + resourceInput,  isDebugEnabled)
77                         //Get ResourceInput Object
78                         ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)                                       
79                         // set local resourceInput
80                         execution.setVariable(Prefix + "ResourceInput", resourceInputObj)
81                         
82                         String resourceInstanceId = resourceInputObj.getResourceInstancenUuid()
83                         String sppartnerId = resourceInstanceId
84                         execution.setVariable(Prefix + "SppartnerId", sppartnerId)
85                         utils.log("INFO", "sppartnerId:" + sppartnerId, isDebugEnabled)
86                         
87                         // Get Sppartner from AAI
88                         AaiUtil aaiUriUtil = new AaiUtil(this)
89                         String aai_uri = aaiUriUtil.getBusinessSPPartnerUri(execution)
90                         String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)                      
91                         String aai_endpoint = execution.getVariable("URN_aai_endpoint")
92                         String serviceAaiPath = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(sppartnerId,"UTF-8")
93                         execution.setVariable(Prefix + "serviceAaiPath", serviceAaiPath)
94                         
95                         getSPPartnerInAAI(execution)
96                         
97                         String callSource = "UUI"
98                         String sppartnerUrl = ""
99                         String sppartnerVersion = ""
100                         if(execution.getVariable(Prefix + "SuccessIndicator")) {
101                                 callSource = execution.getVariable(Prefix + "CallSource")
102                                 sppartnerId = execution.getVariable(Prefix + "SppartnerId")
103                                 sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
104                                 sppartnerVersion = execution.getVariable(Prefix + "SppartnerVersion")                           
105                         }
106                         
107                         boolean is3rdONAPExist = false  
108                         if(!isBlank(sppartnerUrl)) {                            
109                                 is3rdONAPExist = true
110                         }
111                         
112                         execution.setVariable("Is3rdONAPExist", is3rdONAPExist)
113                         execution.setVariable(Prefix + "ServiceInstanceId", resourceInputObj.getServiceInstanceId())
114                         execution.setVariable("mso-request-id", requestId)
115                         execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
116
117                 } catch (BpmnError e) {
118                         throw e
119                 } catch (Exception ex){
120                         String msg = "Exception in checkSPPartnerInfoFromAAI " + ex.getMessage()
121                         utils.log("DEBUG", msg, isDebugEnabled)
122                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
123                 }
124         }
125
126         public void checkLocallCall (DelegateExecution execution) {
127                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
128                 utils.log("INFO"," ***** Started checkLocallCall *****",  isDebugEnabled)
129                 
130                 boolean isLocalCall = true
131                 String callSource = execution.getVariable(Prefix + "CallSource")
132                 if("ExternalAPI".equalsIgnoreCase(callSource)) {
133                         isLocalCall = false
134                 }
135                 execution.setVariable("IsLocalCall", isLocalCall)
136         }
137
138         public void preProcessRequest(DelegateExecution execution){
139                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
140                 utils.log("INFO"," ***** Started preProcessRequest *****",  isDebugEnabled)
141                 try {
142                         ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
143                         String msg = ""                 
144
145                         String globalSubscriberId = resourceInputObj.getGlobalSubscriberId()
146                         if (isBlank(globalSubscriberId)) {
147                                 msg = "Input globalSubscriberId is null"
148                                 utils.log("INFO", msg, isDebugEnabled)
149                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
150                         }
151                         //set local variable
152                         execution.setVariable("globalSubscriberId", globalSubscriberId)
153                         utils.log("INFO", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
154
155                         String serviceType = resourceInputObj.getServiceType()
156                         if (isBlank(serviceType)) {
157                                 msg = "Input serviceType is null"
158                                 utils.log("INFO", msg, isDebugEnabled)
159                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
160                         }
161                         execution.setVariable("serviceType", serviceType)
162                         utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
163                         
164                         String operationId = resourceInputObj.getOperationId()                  
165                         if (isBlank(operationId)) {
166                                 msg = "Input operationId is null"
167                                 utils.log("INFO", msg, isDebugEnabled)
168                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
169                         }
170                         execution.setVariable("operationId", operationId)
171                         utils.log("INFO", "operationId:" + operationId, isDebugEnabled)
172                         
173                         String resourceName = resourceInputObj.getResourceInstanceName()                        
174                         if (isBlank(resourceName)) {
175                                 msg = "Input resourceName is null"
176                                 utils.log("INFO", msg, isDebugEnabled)
177                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
178                         }
179                         execution.setVariable("resourceName", resourceName)
180                         utils.log("INFO", "resourceInstanceId:" + resourceName, isDebugEnabled)
181                         
182                         String resourceTemplateId = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
183                         if (isBlank(resourceTemplateId)) {
184                                 msg = "Input resourceTemplateId is null"
185                                 utils.log("INFO", msg, isDebugEnabled)
186                                 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
187                         }
188                         execution.setVariable("resourceTemplateId", resourceTemplateId)
189                         utils.log("INFO", "resourceTemplateId:" + resourceTemplateId, isDebugEnabled)
190
191                 } catch (BpmnError e) {
192                         throw e
193                 } catch (Exception ex){
194                         String msg = "Exception in preProcessRequest " + ex.getMessage()
195                         utils.log("DEBUG", msg, isDebugEnabled)
196                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
197                 }
198         }
199
200         public void prepareUpdateProgress(DelegateExecution execution) {
201                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
202                 utils.log("INFO"," ***** Started prepareUpdateProgress *****",  isDebugEnabled)
203                 ResourceInput resourceInputObj = execution.getVariable(Prefix + "ResourceInput")
204                 String operType = resourceInputObj.getOperationType()
205                 String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
206                 String ServiceInstanceId = resourceInputObj.getServiceInstanceId()
207                 String modelName = resourceInputObj.getResourceModelInfo().getModelName()
208                 String operationId = resourceInputObj.getOperationId()
209                 String progress = execution.getVariable("progress")
210                 String status = execution.getVariable("status")
211                 String statusDescription = execution.getVariable("statusDescription")
212
213                 String body = """
214                 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
215                         xmlns:ns="http://org.openecomp.mso/requestsdb">
216                         <soapenv:Header/>
217                 <soapenv:Body>
218                     <ns:updateResourceOperationStatus>
219                                <operType>${operType}</operType>
220                                <operationId>${operationId}</operationId>
221                                <progress>${progress}</progress>
222                                <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
223                                <serviceId>${ServiceInstanceId}</serviceId>
224                                <status>${status}</status>
225                                <statusDescription>${statusDescription}</statusDescription>
226                     </ns:updateResourceOperationStatus>
227                 </soapenv:Body>
228                 </soapenv:Envelope>"""
229
230                 setProgressUpdateVariables(execution, body)
231                 utils.log("INFO"," ***** End prepareUpdateProgress *****",  isDebugEnabled)
232         }
233
234         public void prepare3rdONAPRequest(DelegateExecution execution) {
235                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
236                 utils.log("INFO"," ***** Started prepare3rdONAPRequest *****",  isDebugEnabled)
237                 
238                 String sppartnerUrl = execution.getVariable(Prefix + "SppartnerUrl")
239                 String extAPIPath = sppartnerUrl + 'serviceOrder'
240                 execution.setVariable("ExternalAPIURL", extAPIPath)
241                 
242                 // ExternalAPI message format
243                 String externalId = execution.getVariable("resourceName")
244                 String category = "E2E Service"
245                 String description = "Service Order from SPPartner"
246                 String requestedStartDate = utils.generateCurrentTimeInUtc()
247                 String requestedCompletionDate = utils.generateCurrentTimeInUtc()
248                 String priority = "1" // 0-4 0:highest
249                 String subscriberId = execution.getVariable("globalSubscriberId")
250                 String customerRole = ""
251                 String subscriberName = ""
252                 String referredType = "Consumer"
253                 String orderItemId = "1"
254                 String action = "delete" //for delete
255                 String serviceState = "active"
256                 String serviceName = ""
257                 String serviceType = execution.getVariable("serviceType")
258                 String serviceId = execution.getVariable(Prefix + "ServiceInstanceId")
259                 
260                 Map<String, String> valueMap = new HashMap<>()
261                 valueMap.put("externalId", '"' + externalId + '"')
262                 valueMap.put("category", '"' + category + '"')
263                 valueMap.put("description", '"' + description + '"')
264                 valueMap.put("requestedStartDate", '"' + requestedStartDate + '"')
265                 valueMap.put("requestedCompletionDate", '"' + requestedCompletionDate + '"')
266                 valueMap.put("priority", '"'+ priority + '"')
267                 valueMap.put("subscriberId", '"' + subscriberId + '"')
268                 valueMap.put("customerRole", '"' + customerRole + '"')
269                 valueMap.put("subscriberName", '"' + subscriberName + '"')
270                 valueMap.put("referredType", '"' + referredType + '"')
271                 valueMap.put("orderItemId", '"' + orderItemId + '"')
272                 valueMap.put("action", '"' + action + '"')
273                 valueMap.put("serviceState", '"' + serviceState + '"')
274                 valueMap.put("serviceName", '"' + serviceName + '"')
275                 valueMap.put("serviceType", '"' + serviceType + '"')
276                 valueMap.put("serviceId", '"' + serviceId + '"')
277                 
278                 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)             
279          
280                 valueMap.put("_requestInputs_",  "")
281                 
282                 String payload = externalAPIUtil.setTemplate(ExternalAPIUtil.PostServiceOrderRequestsTemplate, valueMap)
283                 execution.setVariable(Prefix + "Payload", payload)
284                 utils.log("INFO", "Exit " + prepare3rdONAPRequest, isDebugEnabled)
285         }
286
287         public void doDeleteE2ESIin3rdONAP(DelegateExecution execution) {
288                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
289                 utils.log("INFO"," ***** Started doDeleteE2ESIin3rdONAP *****",  isDebugEnabled)
290                 
291                 String extAPIPath = execution.getVariable("ExternalAPIURL")
292                 String payload = execution.getVariable(Prefix + "Payload")
293                 
294                 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
295
296                 APIResponse response = externalAPIUtil.executeExternalAPIPostCall(execution, extAPIPath, payload)
297
298                 int responseCode = response.getStatusCode()
299                 execution.setVariable(Prefix + "postServiceOrderResponseCode", responseCode)
300                 utils.log("DEBUG", "Post ServiceOrder response code is: " + responseCode, isDebugEnabled)
301
302                 String extApiResponse = response.getResponseBodyAsString()
303                 JSONObject responseObj = new JSONObject(extApiResponse)
304                 execution.setVariable(Prefix + "postServiceOrderResponse", extApiResponse)
305                 //Process Response
306                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
307                         //200 OK 201 CREATED 202 ACCEPTED
308                 {
309                         utils.log("DEBUG", "Post ServiceOrder Received a Good Response", isDebugEnabled)
310                         String serviceOrderId = responseObj.get("ServiceOrderId")
311                         execution.setVariable(Prefix + "SuccessIndicator", true)
312                         execution.setVariable("serviceOrderId", serviceOrderId)
313                 }
314                 else{
315                         utils.log("DEBUG", "Post ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
316                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Post ServiceOrder Received a bad response from 3rdONAP External API")
317                 }
318                 
319                 utils.log("INFO", "Exit " + doDeleteE2ESIin3rdONAP, isDebugEnabled)
320         }
321         
322
323         public void getE2ESIProgressin3rdONAP(DelegateExecution execution) {
324                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
325                 utils.log("INFO"," ***** Started getE2ESIProgressin3rdONAP *****",  isDebugEnabled)
326                 
327                 String extAPIPath = execution.getVariable("ExternalAPIURL")
328                 extAPIPath += "/" + execution.getVariable("ServiceOrderId")
329                 
330                 ExternalAPIUtil externalAPIUtil = new ExternalAPIUtil(this)
331
332                 APIResponse response = externalAPIUtil.executeExternalAPIGetCall(execution, extAPIPath)
333
334                 int responseCode = response.getStatusCode()
335                 execution.setVariable(Prefix + "getServiceOrderResponseCode", responseCode)
336                 utils.log("DEBUG", "Get ServiceOrder response code is: " + responseCode, isDebugEnabled)
337
338                 String extApiResponse = response.getResponseBodyAsString()
339                 JSONObject responseObj = new JSONObject(extApiResponse)
340                 execution.setVariable(Prefix + "getServiceOrderResponse", extApiResponse)
341                 
342                 //Process Response //200 OK 201 CREATED 202 ACCEPTED
343                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )                  
344                 {
345                         utils.log("DEBUG", "Get ServiceOrder Received a Good Response", isDebugEnabled)
346                         String serviceOrderState = responseObj.get("State")
347                         execution.setVariable(Prefix + "SuccessIndicator", true)
348                         execution.setVariable("serviceOrderState", serviceOrderState)                   
349                         
350                         // Get serviceOrder State and process progress
351                         if("ACKNOWLEDGED".equalsIgnoreCase(serviceOrderState)) {
352                                 execution.setVariable("progress", 15)
353                                 execution.setVariable("status", "processing")                           
354                         }
355                         if("INPROGRESS".equalsIgnoreCase(serviceOrderState)) {
356                                 execution.setVariable("progress", 40)
357                                 execution.setVariable("status", "processing")
358                         }
359                         if("COMPLETED".equalsIgnoreCase(serviceOrderState)) {
360                                 execution.setVariable("progress", 100)
361                                 execution.setVariable("status", "finished")
362                         }
363                         if("FAILED".equalsIgnoreCase(serviceOrderState)) {
364                                 execution.setVariable("progress", 100)
365                                 execution.setVariable("status", "error")
366                         }
367                         else {
368                                 execution.setVariable("progress", 100)
369                                 execution.setVariable("status", "error")
370                                 execution.setVariable("statusDescription", "Delete Service Order Status is unknown")
371                         }
372                         execution.setVariable("statusDescription", "Delete Service Order Status is " + serviceOrderState)
373                 }
374                 else{                   
375                         utils.log("DEBUG", "Get ServiceOrder Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
376                         execution.setVariable("progress", 100)
377                         execution.setVariable("status", "error")
378                         execution.setVariable("statusDescription", "Get ServiceOrder Received a bad response")
379                         exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Get ServiceOrder Received a bad response from 3rdONAP External API")
380                 }               
381                 
382                 utils.log("INFO", "Exit " + getE2ESIProgressin3rdONAP, isDebugEnabled)
383         }
384         
385         /**
386          * delay 5 sec
387          */
388         public void timeDelay(DelegateExecution execution) {
389                 def isDebugEnabled= execution.getVariable("isDebugLogEnabled")
390                 try {
391                         Thread.sleep(5000)
392                 } catch(InterruptedException e) {
393                         utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
394                 }
395         }
396
397         private void getSPPartnerInAAI(DelegateExecution execution) {
398                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
399                 utils.log("INFO"," ***** Started postDeleteE2ESIin3rdONAP *****",  isDebugEnabled)      
400                 
401                 AaiUtil aaiUriUtil = new AaiUtil(this)
402                 String serviceAaiPath = execution.getVariable(Prefix + "serviceAaiPath")                
403                 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, serviceAaiPath)
404                 int responseCode = response.getStatusCode()
405                 execution.setVariable(Prefix + "GetSppartnerResponseCode", responseCode)
406                 utils.log("DEBUG", "  Get sppartner response code is: " + responseCode, isDebugEnabled)
407
408                 String aaiResponse = response.getResponseBodyAsString()
409                 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
410                 aaiResponse = aaiResponse.replaceAll("&", "&amp;")
411                 execution.setVariable(Prefix + "GetSppartnerResponse", aaiResponse)
412
413                 //Process Response
414                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
415                         //200 OK 201 CREATED 202 ACCEPTED
416                 {
417                         utils.log("DEBUG", "GET sppartner Received a Good Response", isDebugEnabled)
418                         execution.setVariable(Prefix + "SuccessIndicator", true)
419                         execution.setVariable(Prefix + "FoundIndicator", true)
420                         
421                         String sppartnerId = utils.getNodeText1(aaiResponse, "sppartner-id")
422                         execution.setVariable(Prefix + "SppartnerId", sppartnerId)
423                         utils.log("DEBUG", " SppartnerId is: " + sppartnerId, isDebugEnabled)
424                         String sppartnerUrl = utils.getNodeText1(aaiResponse, "sppartner-url")
425                         execution.setVariable(Prefix + "SppartnerUrl", sppartnerUrl)
426                         utils.log("DEBUG", " SppartnerUrl is: " + sppartnerUrl, isDebugEnabled)
427                         String callSource = utils.getNodeText1(aaiResponse, "sppartner-callsource")
428                         execution.setVariable(Prefix + "CallSource", callSource)
429                         utils.log("DEBUG", " CallSource is: " + callSource, isDebugEnabled)
430                         String sppartnerVersion = utils.getNodeText1(aaiResponse, "resource-version")
431                         execution.setVariable(Prefix + "SppartnerVersion", sppartnerVersion)
432                         utils.log("DEBUG", " Resource Version is: " + sppartnerVersion, isDebugEnabled)
433                 }
434                 else
435                 {
436                         utils.log("DEBUG", "Get sppartner Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
437                         exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
438                         throw new BpmnError("MSOWorkflowException")
439                 }
440                 
441                 utils.log("INFO", "Exit " + deleteSPPartnerInAAI, isDebugEnabled)
442         }
443         
444         public void deleteSPPartnerInAAI(DelegateExecution execution) {
445                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
446                 utils.log("INFO"," ***** Started postDeleteE2ESIin3rdONAP *****",  isDebugEnabled)
447                 
448                 String sppartnerId = execution.getVariable(Prefix + "SppartnerId")
449                 String sppartnerUrl = execution.getVariable(Prefix + "sppartnerUrl")
450                 String sppartnerVersion = execution.getVariable(Prefix + "sppartnerVersion")
451                 
452                 AaiUtil aaiUriUtil = new AaiUtil(this)
453                 String serviceAaiPath = execution.getVariable(Prefix + "serviceAaiPath") + "?resource-version=${sppartnerVersion}"
454                 APIResponse response = aaiUriUtil.executeAAIDeleteCall(execution, serviceAaiPath)
455                 int responseCode = response.getStatusCode()
456                 execution.setVariable(Prefix + "DeleteSppartnerResponseCode", responseCode)
457                 utils.log("DEBUG", "  Get sppartner response code is: " + responseCode, isDebugEnabled)
458
459                 String aaiResponse = response.getResponseBodyAsString()
460                 aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse)
461                 execution.setVariable(Prefix + "DeleteSppartnerResponse", aaiResponse)
462
463                 //Process Response
464                 if(responseCode == 200 || responseCode == 201 || responseCode == 202 )
465                         //200 OK 201 CREATED 202 ACCEPTED
466                 {
467                         utils.log("DEBUG", "Delete sppartner Received a Good Response", isDebugEnabled)
468                         execution.setVariable(Prefix + "SuccessIndicator", true)
469                 }
470                 else if(responseCode == 404){
471                         utils.log("DEBUG", " Delete sppartner Received a Not Found (404) Response", isDebugEnabled)
472                         execution.setVariable(Prefix + "FoundIndicator", false)
473                 }
474                 else
475                 {
476                         utils.log("DEBUG", "Delete sppartner Received a Bad Response Code. Response Code is: " + responseCode, isDebugEnabled)
477                         exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode)
478                         throw new BpmnError("MSOWorkflowException")
479                 }
480                 
481                 utils.log("INFO", "Exit " + deleteSPPartnerInAAI, isDebugEnabled)
482         }
483         
484         private void setProgressUpdateVariables(DelegateExecution execution, String body) {
485                 def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
486                 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
487                 execution.setVariable("CVFMI_updateResOperStatusRequest", body)
488         }       
489
490         public void postProcess(DelegateExecution execution){
491                 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
492                 utils.log("INFO"," ***** Started postProcess *****",  isDebugEnabled)
493                 String responseCode = execution.getVariable(Prefix + "putSppartnerResponseCode")
494                 String responseObj = execution.getVariable(Prefix + "putSppartnerResponse")
495
496                 utils.log("INFO","response from AAI for put sppartner, response code :" + responseCode + "  response object :" + responseObj,  isDebugEnabled)
497                 utils.log("INFO"," ***** Exit postProcess *****",  isDebugEnabled)
498         }
499
500         public void sendSyncResponse (DelegateExecution execution) {
501                 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
502                 utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
503
504                 try {
505                         String operationStatus = "finished"
506                         // RESTResponse for main flow
507                         String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
508                         utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
509                         sendWorkflowResponse(execution, 202, resourceOperationResp)
510                         execution.setVariable("sentSyncResponse", true)
511
512                 } catch (Exception ex) {
513                         String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
514                         utils.log("DEBUG", msg, isDebugEnabled)
515                         exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
516                 }
517                 utils.log("DEBUG"," ***** Exit sendSyncResopnse *****",  isDebugEnabled)
518         }
519 }