Fix LCN handling during healing 13/48013/1
authorDenes Nemeth <denes.nemeth@nokia.com>
Thu, 17 May 2018 08:54:28 +0000 (10:54 +0200)
committerDenes Nemeth <denes.nemeth@nokia.com>
Thu, 17 May 2018 08:55:09 +0000 (10:55 +0200)
Change-Id: I561d65b5861dee410aeb4b71d4037afd44cafe17
Signed-off-by: Denes Nemeth <denes.nemeth@nokia.com>
Issue-ID: VFC-728

nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/util/CbamUtils.java
nokiav2/driver/src/main/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/LifecycleChangeNotificationManager.java
nokiav2/driver/src/test/java/org/onap/vfc/nfvo/driver/vnfm/svnfm/nokia/vnfm/notification/TestLifecycleChangeNotificationManager.java

index b4e5915..116420d 100644 (file)
@@ -81,7 +81,7 @@ public class CbamUtils {
         return new OperationMustBeAborted(msg);
     }
 
-    private static class OperationMustBeAborted extends RuntimeException {
+    public static class OperationMustBeAborted extends RuntimeException {
         OperationMustBeAborted(String msg) {
             super(msg);
         }
index 9b49734..88c1e00 100644 (file)
@@ -28,6 +28,8 @@ import java.util.Optional;
 import java.util.Set;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.api.INotificationSender;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.core.SelfRegistrationManager;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils;
+import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.CbamUtils.OperationMustBeAborted;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.CbamRestApiProvider;
 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.ILifecycleChangeNotificationManager;
@@ -210,15 +212,19 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
                 JsonObject operationResult = root.getAsJsonObject().get("operationResult").getAsJsonObject();
                 if (isAbsent(operationResult, "cbam_pre") ||
                         isAbsent(operationResult, "cbam_post")) {
-                    return handleFailure(operationExecution, null);
+                    return handleFailure(operationExecution);
                 } else {
                     return of(new Gson().fromJson(operationResult, ReportedAffectedConnectionPoints.class));
                 }
             } else {
-                return handleFailure(operationExecution, null);
+                return handleFailure(operationExecution);
             }
-        } catch (Exception e) {
-            return handleFailure(operationExecution, e);
+        }
+        catch(OperationMustBeAborted handledFailuire){
+            throw handledFailuire;
+        }
+        catch (Exception e) {
+            return toleratedFailure();
         }
     }
 
@@ -226,15 +232,16 @@ public class LifecycleChangeNotificationManager implements ILifecycleChangeNotif
         return !operationResult.has(key) || !operationResult.get(key).isJsonArray();
     }
 
-    private Optional<ReportedAffectedConnectionPoints> handleFailure(OperationExecution operationExecution, Exception e) {
+    private Optional<ReportedAffectedConnectionPoints> handleFailure(OperationExecution operationExecution) {
         if (operationExecution.getStatus() == OperationStatus.FAILED) {
-            logger.warn("The operation failed and the affected connection points were not reported");
-            return empty();
+            return toleratedFailure();
         } else {
-            if (e != null) {
-                throw buildFatalFailure(logger, PROBLEM, e);
-            }
             throw buildFatalFailure(logger, PROBLEM);
         }
     }
+
+    private Optional<ReportedAffectedConnectionPoints> toleratedFailure() {
+        logger.warn("The operation failed and the affected connection points were not reported");
+        return empty();
+    }
 }