Merge "bump the so-cnf-adapter version to 1.9.2"
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
index 9aaf439..ee8a362 100644
--- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/rest/CnfAdapterRest.java
@@ -140,7 +140,7 @@
             try {
                 aaiService.aaiUpdate(aaiRequest);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.COMPLETED);
-            } catch (BadResponseException e) {
+            } catch (Exception e) {
                 logger.warn("Failed to create resource in AAI", e);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.FAILED);
                 callbackResponse.setMessage(e.getMessage());
@@ -165,7 +165,7 @@
             try {
                 aaiService.aaiDelete(aaiRequest);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.COMPLETED);
-            } catch (BadResponseException e) {
+            } catch (Exception e) {
                 logger.warn("Failed to delete resource from AAI", e);
                 callbackResponse.setCompletionStatus(AaiCallbackResponse.CompletionStatus.FAILED);
                 callbackResponse.setMessage(e.getMessage());
diff --git a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java
index 0531728..6c03757 100644
--- a/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java
+++ b/so-cnf-adapter-application/src/main/java/org/onap/so/adapters/cnf/util/AaiRepository.java
@@ -39,8 +39,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import javax.ws.rs.NotFoundException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 import java.util.Optional;
 import java.util.stream.Collectors;
 
@@ -165,6 +167,13 @@
                         .tenant(aaiRequest.getTenantId())
                         .k8sResource(r.getId());
                 return AAIUriFactory.createResourceUri(k8sResource.build(), aaiRequest.getCloudOwner(), aaiRequest.getCloudRegion(), aaiRequest.getTenantId(), r.getId());
+            }).filter(r -> {
+                if (aaiClient.exists(r))
+                    return true;
+                else {
+                    logger.warn("K8sResource " + r.toString() + "] does not exist in AAI. Skipping delete in AAI");
+                    return false;
+                }
             }).forEach(uri -> getTransaction().delete(uri));
         }
     }