- NeutronCRUDInterfaces interfaces = getNeutronInterfaces(true, true);
- INeutronPortCRUD portInterface = interfaces.getPortInterface();
- if (input.isSingleton()) {
- NeutronPort singleton = input.getSingleton();
-
- Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canCreatePort(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);
- }
-
- // add the port to the cache
- portInterface.addPort(singleton);
- if (instances != null) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- service.neutronPortCreated(singleton);
- }
- }
- } else {
- Object[] instances = NeutronUtil.getInstances(INeutronPortAware.class, this);
- for (NeutronPort test : input.getBulk()) {
-
- if (instances != null) {
- if (instances.length > 0) {
- for (Object instance : instances) {
- INeutronPortAware service = (INeutronPortAware) instance;
- int status = service.canCreatePort(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);
- }
- }