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;
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) {
List<NeutronFirewall> bulk = input.getBulk();
Iterator<NeutronFirewall> i = bulk.iterator();
HashMap<String, NeutronFirewall> testMap = new HashMap<String, NeutronFirewall>();
- Object[] instances = ServiceHelper.getGlobalInstances(INeutronFirewallAware.class, this, null);
+ Object[] instances = NeutronUtil.getInstances(INeutronFirewallAware.class, this);
while (i.hasNext()) {
NeutronFirewall test = i.next();
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");
}
}
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");
}
/*
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");
}
/*