northbound: introduce a base class for nortubhound classes
[neutron.git] / northbound-api / src / main / java / org / opendaylight / neutron / northbound / api / NeutronPortsNorthbound.java
index 7e065406658612d1f1f9658fef434bdd6ce50c8e..63d5aaf1e585e096045ebe9e0004ad3a598a0c70 100644 (file)
@@ -57,14 +57,9 @@ import org.opendaylight.neutron.spi.NeutronPort;
  */
 
 @Path("/ports")
-public class NeutronPortsNorthbound {
+public class NeutronPortsNorthbound extends AbstractNeutronNorthbound {
 
-    private static final int HTTP_OK_BOTTOM = 200;
-    private static final int HTTP_OK_TOP = 299;
-    private static final String INTERFACE_NAME = "Port CRUD Interface";
-    private static final String UUID_NO_EXIST = "Port UUID does not exist.";
-    private static final String NO_PROVIDERS = "No providers registered.  Please try again later";
-    private static final String NO_PROVIDER_LIST = "Couldn't get providers list.  Please try again later";
+    private static final String RESOURCE_NAME = "Port";
 
     private NeutronPort extractFields(NeutronPort o, List<String> fields) {
         return o.extractFields(fields);
@@ -73,8 +68,7 @@ public class NeutronPortsNorthbound {
     private NeutronCRUDInterfaces getNeutronInterfaces(boolean needNetworks, boolean needSubnets) {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronPortCRUD(this);
         if (answer.getPortInterface() == null) {
-            throw new ServiceUnavailableException(INTERFACE_NAME
-                + RestMessages.SERVICEUNAVAILABLE.toString());
+            throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME));
         }
         if (needNetworks) {
             answer = answer.fetchINeutronNetworkCRUD( this);
@@ -179,7 +173,7 @@ public class NeutronPortsNorthbound {
             @QueryParam("fields") List<String> fields ) {
         INeutronPortCRUD portInterface = getNeutronInterfaces(false, false).getPortInterface();
         if (!portInterface.portExists(portUUID)) {
-            throw new ResourceNotFoundException(UUID_NO_EXIST);
+            throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME));
         }
         if (fields.size() > 0) {
             NeutronPort ans = portInterface.getPort(portUUID);