X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetworkconfiguration%2Fneutron%2Fnorthbound%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetworkconfig%2Fneutron%2Fnorthbound%2FNeutronFirewallNorthbound.java;h=b97a554f60b72feb84a4f73e26768722e34c0c17;hp=204c9f51761bdc48c833dff059d5d6f7a423ed38;hb=bfd413d87f82ee3ffed67a141a980805950a0f06;hpb=5355c84eec599e751411e9e6a43e2be6e92f77d6 diff --git a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFirewallNorthbound.java b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFirewallNorthbound.java index 204c9f5176..b97a554f60 100644 --- a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFirewallNorthbound.java +++ b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronFirewallNorthbound.java @@ -16,11 +16,6 @@ import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallCRUD; import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleCRUD; import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces; import org.opendaylight.controller.networkconfig.neutron.NeutronFirewall; -import org.opendaylight.controller.northbound.commons.RestMessages; -import org.opendaylight.controller.northbound.commons.exception.BadRequestException; -import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; -import org.opendaylight.controller.northbound.commons.exception.ServiceUnavailableException; -import org.opendaylight.controller.sal.utils.ServiceHelper; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -190,15 +185,21 @@ public class NeutronFirewallNorthbound { throw new BadRequestException("Firewall UUID already exists"); } firewallInterface.addNeutronFirewall(singleton); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronFirewallAware service = (INeutronFirewallAware) instance; - int status = service.canCreateNeutronFirewall(singleton); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronFirewallAware service = (INeutronFirewallAware) instance; + int status = service.canCreateNeutronFirewall(singleton); + if (status < 200 || status > 299) { + return Response.status(status).build(); + } } + } else { + throw new ServiceUnavailableException("No providers registered. Please try again later"); } + } else { + throw new ServiceUnavailableException("Couldn't get providers list. Please try again later"); } firewallInterface.addNeutronFirewall(singleton); if (instances != null) { @@ -211,7 +212,7 @@ public class NeutronFirewallNorthbound { List bulk = input.getBulk(); Iterator i = bulk.iterator(); HashMap testMap = new HashMap(); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); while (i.hasNext()) { NeutronFirewall test = i.next(); @@ -225,13 +226,19 @@ public class NeutronFirewallNorthbound { throw new BadRequestException("Firewall UUID already exists"); } if (instances != null) { - for (Object instance : instances) { - INeutronFirewallAware service = (INeutronFirewallAware) instance; - int status = service.canCreateNeutronFirewall(test); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronFirewallAware service = (INeutronFirewallAware) instance; + int status = service.canCreateNeutronFirewall(test); + if (status < 200 || status > 299) { + return Response.status(status).build(); + } } + } else { + throw new ServiceUnavailableException("No providers registered. Please try again later"); } + } else { + throw new ServiceUnavailableException("Couldn't get providers list. Please try again later"); } } @@ -301,15 +308,21 @@ public class NeutronFirewallNorthbound { throw new BadRequestException("Attribute edit blocked by Neutron"); } - Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronFirewallAware service = (INeutronFirewallAware) instance; - int status = service.canUpdateNeutronFirewall(delta, original); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronFirewallAware service = (INeutronFirewallAware) instance; + int status = service.canUpdateNeutronFirewall(delta, original); + if (status < 200 || status > 299) { + return Response.status(status).build(); + } } + } else { + throw new ServiceUnavailableException("No providers registered. Please try again later"); } + } else { + throw new ServiceUnavailableException("Couldn't get providers list. Please try again later"); } /* @@ -355,15 +368,21 @@ public class NeutronFirewallNorthbound { return Response.status(409).build(); } NeutronFirewall singleton = firewallInterface.getNeutronFirewall(firewallUUID); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronFirewallAware service = (INeutronFirewallAware) instance; - int status = service.canDeleteNeutronFirewall(singleton); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronFirewallAware service = (INeutronFirewallAware) instance; + int status = service.canDeleteNeutronFirewall(singleton); + if (status < 200 || status > 299) { + return Response.status(status).build(); + } } + } else { + throw new ServiceUnavailableException("No providers registered. Please try again later"); } + } else { + throw new ServiceUnavailableException("Couldn't get providers list. Please try again later"); } /*