Checkstyle Import issues fix (SPI tests,Northbound API)
[neutron.git] / northbound-api / src / main / java / org / opendaylight / neutron / northbound / api / NeutronRoutersNorthbound.java
index 9fc2598652633bfbd57889ebf69ffe66a4135f66..8fd50b2abcd8a59521d0537958439d4ee2273347 100644 (file)
@@ -9,11 +9,9 @@
 package org.opendaylight.neutron.northbound.api;
 
 import java.net.HttpURLConnection;
-
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-
 import javax.ws.rs.Consumes;
 import javax.ws.rs.DELETE;
 import javax.ws.rs.GET;
@@ -25,14 +23,9 @@ import javax.ws.rs.Produces;
 import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
-
 import org.codehaus.enunciate.jaxrs.ResponseCode;
 import org.codehaus.enunciate.jaxrs.StatusCodes;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronRouterAware;
 import org.opendaylight.neutron.spi.INeutronRouterCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
 import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
 import org.opendaylight.neutron.spi.NeutronRouter;
 import org.opendaylight.neutron.spi.NeutronRouter_Interface;
@@ -58,7 +51,7 @@ import org.opendaylight.neutron.spi.NeutronRouter_Interface;
 
 @Path("/routers")
 public class NeutronRoutersNorthbound
-    extends AbstractNeutronNorthbound<NeutronRouter, NeutronRouterRequest, INeutronRouterCRUD, INeutronRouterAware> {
+    extends AbstractNeutronNorthbound<NeutronRouter, NeutronRouterRequest, INeutronRouterCRUD> {
     static final String ROUTER_INTERFACE_STR = "network:router_interface";
     static final String ROUTER_GATEWAY_STR = "network:router_gateway";
     private static final String RESOURCE_NAME = "Router";
@@ -115,47 +108,6 @@ public class NeutronRoutersNorthbound
         return new NeutronRouterRequest(o);
     }
 
-    @Override
-    protected Object[] getInstances() {
-        return NeutronUtil.getInstances(INeutronRouterAware.class, this);
-    }
-
-    @Override
-    protected int canCreate(Object instance, NeutronRouter singleton) {
-        INeutronRouterAware service = (INeutronRouterAware) instance;
-        return service.canCreateRouter(singleton);
-    }
-
-    @Override
-    protected void created(Object instance, NeutronRouter singleton) {
-        INeutronRouterAware service = (INeutronRouterAware) instance;
-        service.neutronRouterCreated(singleton);
-    }
-
-    @Override
-    protected int canUpdate(Object instance, NeutronRouter delta, NeutronRouter original) {
-        INeutronRouterAware service = (INeutronRouterAware) instance;
-        return service.canUpdateRouter(delta, original);
-    }
-
-    @Override
-    protected void updated(Object instance, NeutronRouter updated) {
-        INeutronRouterAware service = (INeutronRouterAware) instance;
-        service.neutronRouterUpdated(updated);
-    }
-
-    @Override
-    protected int canDelete(Object instance, NeutronRouter singleton) {
-        INeutronRouterAware service = (INeutronRouterAware) instance;
-        return service.canDeleteRouter(singleton);
-    }
-
-    @Override
-    protected void deleted(Object instance, NeutronRouter singleton) {
-        INeutronRouterAware service = (INeutronRouterAware) instance;
-        service.neutronRouterDeleted(singleton);
-    }
-
     /**
      * Returns a list of all Routers */
 
@@ -173,7 +125,7 @@ public class NeutronRoutersNorthbound
             // note: openstack isn't clear about filtering on lists, so we aren't handling them
             @QueryParam("id") String queryID,
             @QueryParam("name") String queryName,
-            @QueryParam("admin_state_up") String queryAdminStateUp,
+            @QueryParam("admin_state_up") Boolean queryAdminStateUp,
             @QueryParam("status") String queryStatus,
             @QueryParam("tenant_id") String queryTenantID,
             @QueryParam("external_gateway_info") String queryExternalGatewayInfo,
@@ -187,7 +139,7 @@ public class NeutronRoutersNorthbound
         if (routerInterface == null) {
             throw new ServiceUnavailableException(serviceUnavailable());
         }
-        List<NeutronRouter> allRouters = routerInterface.getAllRouters();
+        List<NeutronRouter> allRouters = routerInterface.getAll();
         List<NeutronRouter> ans = new ArrayList<NeutronRouter>();
         Iterator<NeutronRouter> i = allRouters.iterator();
         while (i.hasNext()) {
@@ -262,6 +214,7 @@ public class NeutronRoutersNorthbound
     //@TypeHint(OpenStackRouters.class)
     @StatusCodes({
             @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
+            @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
     public Response updateRouter(
             @PathParam("routerUUID") String routerUUID,
@@ -278,6 +231,7 @@ public class NeutronRoutersNorthbound
     @DELETE
     @StatusCodes({
             @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT, condition = "No Content"),
+            @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
             @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
     public Response deleteRouter(
             @PathParam("routerUUID") String routerUUID) {
@@ -293,96 +247,27 @@ public class NeutronRoutersNorthbound
     @Consumes({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackRouterInterfaces.class)
     @StatusCodes({
-            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
-            @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful") })
     public Response addRouterInterface(
             @PathParam("routerUUID") String routerUUID,
             NeutronRouter_Interface input
             ) {
-        NeutronCRUDInterfaces interfaces = getAttachInterfaces();
-        INeutronRouterCRUD routerInterface = interfaces.getRouterInterface();
-
-        NeutronRouter target = routerInterface.getRouter(routerUUID);
-        Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
-        if (instances != null) {
-            if (instances.length > 0) {
-                for (Object instance : instances) {
-                    INeutronRouterAware service = (INeutronRouterAware) instance;
-                    int status = service.canAttachInterface(target, input);
-                    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);
-        }
-
-        target.addInterface(input.getPortUUID(), input);
-        if (instances != null) {
-            for (Object instance : instances) {
-                INeutronRouterAware service = (INeutronRouterAware) instance;
-                service.neutronRouterInterfaceAttached(target, input);
-            }
-        }
-
+        // Do nothing. Keep this interface for compatibility
         return Response.status(HttpURLConnection.HTTP_OK).entity(input).build();
     }
 
-
-    private int checkDownstreamDetach(NeutronRouter target, NeutronRouter_Interface input) {
-        Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
-        if (instances != null) {
-            if (instances.length > 0) {
-                for (Object instance : instances) {
-                    INeutronRouterAware service = (INeutronRouterAware) instance;
-                    int status = service.canDetachInterface(target, input);
-                    if (status < HTTP_OK_BOTTOM || status > HTTP_OK_TOP) {
-                        return status;
-                    }
-                }
-            } else {
-                throw new ServiceUnavailableException(NO_PROVIDERS);
-            }
-        } else {
-            throw new ServiceUnavailableException(NO_PROVIDER_LIST);
-        }
-        return HTTP_OK_BOTTOM;
-    }
-
-    /**
-     * Removes an interface to a router */
-
     @Path("{routerUUID}/remove_router_interface")
     @PUT
     @Produces({ MediaType.APPLICATION_JSON })
     @Consumes({ MediaType.APPLICATION_JSON })
     //@TypeHint(OpenStackRouterInterfaces.class)
     @StatusCodes({
-            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
-            @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful") })
     public Response removeRouterInterface(
             @PathParam("routerUUID") String routerUUID,
             NeutronRouter_Interface input
             ) {
-        NeutronCRUDInterfaces interfaces = getAttachInterfaces();
-        INeutronRouterCRUD routerInterface = interfaces.getRouterInterface();
-        Object[] instances = NeutronUtil.getInstances(INeutronRouterAware.class, this);
-
-        NeutronRouter target = routerInterface.getRouter(routerUUID);
-        input.setID(target.getID());
-        input.setTenantID(target.getTenantID());
-        int status = checkDownstreamDetach(target, input);
-        if (status != HTTP_OK_BOTTOM) {
-            return Response.status(status).build();
-        }
-        target.removeInterface(input.getPortUUID());
-        for (Object instance : instances) {
-            INeutronRouterAware service = (INeutronRouterAware) instance;
-            service.neutronRouterInterfaceDetached(target, input);
-        }
+        // Do nothing. Keep this interface for compatibility
         return Response.status(HttpURLConnection.HTTP_OK).entity(input).build();
     }
 }