northbound: introduce a base class for nortubhound classes
[neutron.git] / northbound-api / src / main / java / org / opendaylight / neutron / northbound / api / NeutronSecurityRulesNorthbound.java
index a0822a8904eeadda5caa38521e749006ad091930..38f9a07f5a877c0fa016648dee6dd718d49b46c8 100644 (file)
@@ -51,13 +51,8 @@ import org.opendaylight.neutron.spi.NeutronSecurityRule;
  */
 
 @Path ("/security-group-rules")
-public class NeutronSecurityRulesNorthbound {
-    private static final int HTTP_OK_BOTTOM = 200;
-    private static final int HTTP_OK_TOP = 299;
-    private static final String INTERFACE_NAME = "Security Rule CRUD Interface";
-    private static final String UUID_NO_EXIST = "Security Rule 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";
+public class NeutronSecurityRulesNorthbound extends AbstractNeutronNorthbound {
+    private static final String RESOURCE_NAME = "Security Rule";
 
     private NeutronSecurityRule extractFields(NeutronSecurityRule o, List<String> fields) {
         return o.extractFields(fields);
@@ -66,8 +61,7 @@ public class NeutronSecurityRulesNorthbound {
     private NeutronCRUDInterfaces getNeutronInterfaces() {
         NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSecurityRuleCRUD(this);
         if (answer.getSecurityRuleInterface() == null) {
-            throw new ServiceUnavailableException(INTERFACE_NAME
-                + RestMessages.SERVICEUNAVAILABLE.toString());
+            throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME));
         }
         return answer;
     }
@@ -155,7 +149,7 @@ public class NeutronSecurityRulesNorthbound {
                                      @QueryParam ("fields") List<String> fields) {
         INeutronSecurityRuleCRUD securityRuleInterface = getNeutronInterfaces().getSecurityRuleInterface();
         if (!securityRuleInterface.neutronSecurityRuleExists(securityRuleUUID)) {
-            throw new ResourceNotFoundException(UUID_NO_EXIST);
+            throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME));
         }
         if (!fields.isEmpty()) {
             NeutronSecurityRule ans = securityRuleInterface.getNeutronSecurityRule(securityRuleUUID);