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%2FNeutronLoadBalancerListenerNorthbound.java;h=5d877c59f490a75af689d55d1961523e42d877da;hp=f3ef39f7ba40022e77689a3cd7cc47aa333d09b3;hb=3927509ec3ecfa32a51b725d2b7155d425f5b877;hpb=687598acd2f6b71397b105e93f6a2d1b21a7c0ef diff --git a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerListenerNorthbound.java b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerListenerNorthbound.java index f3ef39f7ba..5d877c59f4 100644 --- a/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerListenerNorthbound.java +++ b/opendaylight/networkconfiguration/neutron/northbound/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronLoadBalancerListenerNorthbound.java @@ -9,17 +9,10 @@ package org.opendaylight.controller.networkconfig.neutron.northbound; -import org.codehaus.enunciate.jaxrs.ResponseCode; -import org.codehaus.enunciate.jaxrs.StatusCodes; -import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerAware; -import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD; -import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces; -import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener; -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 java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -32,10 +25,13 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; + +import org.codehaus.enunciate.jaxrs.ResponseCode; +import org.codehaus.enunciate.jaxrs.StatusCodes; +import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerAware; +import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerListenerCRUD; +import org.opendaylight.controller.networkconfig.neutron.NeutronCRUDInterfaces; +import org.opendaylight.controller.networkconfig.neutron.NeutronLoadBalancerListener; /** * Neutron Northbound REST APIs for LoadBalancerListener Policies.
@@ -200,15 +196,21 @@ public class NeutronLoadBalancerListenerNorthbound { } loadBalancerListenerInterface.addNeutronLoadBalancerListener(singleton); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; - int status = service.canCreateNeutronLoadBalancerListener(singleton); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; + int status = service.canCreateNeutronLoadBalancerListener(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"); } loadBalancerListenerInterface.addNeutronLoadBalancerListener(singleton); if (instances != null) { @@ -221,7 +223,7 @@ public class NeutronLoadBalancerListenerNorthbound { List bulk = input.getBulk(); Iterator i = bulk.iterator(); HashMap testMap = new HashMap(); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); while (i.hasNext()) { NeutronLoadBalancerListener test = i.next(); @@ -236,13 +238,19 @@ public class NeutronLoadBalancerListenerNorthbound { throw new BadRequestException("LoadBalancerListener UUID already exists"); } if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; - int status = service.canCreateNeutronLoadBalancerListener(test); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; + int status = service.canCreateNeutronLoadBalancerListener(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"); } } /* @@ -314,15 +322,21 @@ public class NeutronLoadBalancerListenerNorthbound { throw new BadRequestException("Attribute edit blocked by Neutron"); } - Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; - int status = service.canUpdateNeutronLoadBalancerListener(delta, original); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; + int status = service.canUpdateNeutronLoadBalancerListener(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"); } /* @@ -368,15 +382,21 @@ public class NeutronLoadBalancerListenerNorthbound { return Response.status(409).build(); } NeutronLoadBalancerListener singleton = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID); - Object[] instances = ServiceHelper.getGlobalInstances(INeutronLoadBalancerListenerAware.class, this, null); + Object[] instances = NeutronUtil.getInstances(INeutronLoadBalancerListenerAware.class, this); if (instances != null) { - for (Object instance : instances) { - INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; - int status = service.canDeleteNeutronLoadBalancerListener(singleton); - if (status < 200 || status > 299) { - return Response.status(status).build(); + if (instances.length > 0) { + for (Object instance : instances) { + INeutronLoadBalancerListenerAware service = (INeutronLoadBalancerListenerAware) instance; + int status = service.canDeleteNeutronLoadBalancerListener(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"); } loadBalancerListenerInterface.removeNeutronLoadBalancerListener(loadBalancerListenerID);