[BORON] Remove checks that require neutron providers 91/27291/6
authorFlavio Fernandes <ffernand@redhat.com>
Tue, 22 Sep 2015 14:51:09 +0000 (10:51 -0400)
committerFlavio Fernandes <ffernand@redhat.com>
Fri, 15 Jan 2016 20:10:02 +0000 (15:10 -0500)
DO NOT MERGE in Beryllium.

- Remove exceptions caused when there are no I*Aware providers registered

Patch set 2: Make I*Aware interfaces deprecated in a separate gerrit [1]
Patch set 6: Rebase and use AbstractNeutronNorthboundIAware

With this change, we take one step closer to the desired goal of making
neutron northbound md-sal based. By Boron, ODL applications will be expected
to access all neutron northbound related data via the API provided by
the corresponding yang data models.

[1]: https://git.opendaylight.org/gerrit/#/c/27297/

Change-Id: I15ae07ff85620b3ceaf9e13b6aa386ec0aa669b0
Signed-off-by: Flavio Fernandes <ffernand@redhat.com>
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthboundIAware.java

index cbaa73d6ba6357a1f490db0764e51b77c9712ebb..96e628276acff9fb1c7fa792b7248c9b4914c596 100644 (file)
@@ -47,18 +47,12 @@ public abstract class AbstractNeutronNorthboundIAware<T extends INeutronObject,
 
             Object[] instances = this.getInstances();
             if (instances != null) {
-                if (instances.length > 0) {
-                    for (Object instance : instances) {
-                        int status = this.canCreate(instance, singleton);
-                        if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                            return Response.status(status).build();
-                        }
+                for (Object instance : instances) {
+                    int status = this.canCreate(instance, singleton);
+                    if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
+                        return Response.status(status).build();
                     }
-                } else {
-                    throw new ServiceUnavailableException(NO_PROVIDERS);
                 }
-            } else {
-                throw new ServiceUnavailableException(NO_PROVIDER_LIST);
             }
             singleton.initDefaults();
             neutronCRUD.add(singleton);
@@ -71,18 +65,12 @@ public abstract class AbstractNeutronNorthboundIAware<T extends INeutronObject,
             Object[] instances = this.getInstances();
             for (T test : input.getBulk()) {
                 if (instances != null) {
-                    if (instances.length > 0) {
-                        for (Object instance : instances) {
-                            int status = canCreate(instance, test);
-                            if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                                return Response.status(status).build();
-                            }
+                    for (Object instance : instances) {
+                        int status = canCreate(instance, test);
+                        if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
+                            return Response.status(status).build();
                         }
-                    } else {
-                        throw new ServiceUnavailableException(NO_PROVIDERS);
                     }
-                } else {
-                    throw new ServiceUnavailableException(NO_PROVIDER_LIST);
                 }
             }
 
@@ -117,18 +105,12 @@ public abstract class AbstractNeutronNorthboundIAware<T extends INeutronObject,
 
         Object[] instances = getInstances();
         if (instances != null) {
-            if (instances.length > 0) {
-                for (Object instance : instances) {
-                    int status = canUpdate(instance, delta, original);
-                    if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                        return Response.status(status).build();
-                    }
+            for (Object instance : instances) {
+                int status = canUpdate(instance, delta, original);
+                if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
+                    return Response.status(status).build();
                 }
-            } else {
-                throw new ServiceUnavailableException(NO_PROVIDERS);
             }
-        } else {
-            throw new ServiceUnavailableException(NO_PROVIDER_LIST);
         }
 
         /*
@@ -151,18 +133,12 @@ public abstract class AbstractNeutronNorthboundIAware<T extends INeutronObject,
         T singleton = neutronCRUD.get(uuid);
         Object[] instances = getInstances();
         if (instances != null) {
-            if (instances.length > 0) {
-                for (Object instance : instances) {
-                    int status = canDelete(instance, singleton);
-                    if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                        return Response.status(status).build();
-                    }
+            for (Object instance : instances) {
+                int status = canDelete(instance, singleton);
+                if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
+                    return Response.status(status).build();
                 }
-            } else {
-                throw new ServiceUnavailableException(NO_PROVIDERS);
             }
-        } else {
-            throw new ServiceUnavailableException(NO_PROVIDER_LIST);
         }
 
         /*