From 58234da0bd3710227656ca8d8b4eb1082c28340a Mon Sep 17 00:00:00 2001 From: Isaku Yamahata Date: Wed, 26 Aug 2015 18:00:54 -0700 Subject: [PATCH] northbound: introduce a base class for nortubhound classes This patch introduces a base class for nortubhound classes to consolidate some codes. Related-Bug: 4218 Change-Id: I6a82944cbab555114b294aef1aff4282e03b0d87 Signed-off-by: Isaku Yamahata --- .../api/AbstractNeutronNorthbound.java | 29 +++++++++++++++++++ .../api/NeutronFirewallNorthbound.java | 14 +++------ .../api/NeutronFirewallPolicyNorthbound.java | 14 +++------ .../api/NeutronFirewallRulesNorthbound.java | 15 +++------- .../api/NeutronFloatingIPsNorthbound.java | 14 +++------ ...onLoadBalancerHealthMonitorNorthbound.java | 15 +++------- ...NeutronLoadBalancerListenerNorthbound.java | 15 +++------- .../api/NeutronLoadBalancerNorthbound.java | 14 +++------ .../NeutronLoadBalancerPoolNorthbound.java | 20 +++++-------- .../NeutronMeteringLabelRulesNorthbound.java | 5 +--- .../api/NeutronMeteringLabelsNorthbound.java | 5 +--- .../api/NeutronNetworksNorthbound.java | 14 +++------ .../api/NeutronPortsNorthbound.java | 14 +++------ .../api/NeutronRoutersNorthbound.java | 23 +++++---------- .../api/NeutronSecurityGroupsNorthbound.java | 14 +++------ .../api/NeutronSecurityRulesNorthbound.java | 14 +++------ .../api/NeutronSubnetsNorthbound.java | 14 +++------ .../api/NeutronVPNIKEPoliciesNorthbound.java | 10 ++----- .../NeutronVPNIPSECPoliciesNorthbound.java | 10 ++----- ...tronVPNIPSECSiteConnectionsNorthbound.java | 11 ++----- .../api/NeutronVPNServicesNorthbound.java | 14 +++------ 21 files changed, 106 insertions(+), 192 deletions(-) create mode 100644 northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java new file mode 100644 index 000000000..f46f92a2e --- /dev/null +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/AbstractNeutronNorthbound.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015 Intel Corporation All rights reserved. + * Copyright (c) 2015 Isaku Yamahata All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.neutron.northbound.api; + +import java.util.List; + +public abstract class AbstractNeutronNorthbound { + protected static final int HTTP_OK_BOTTOM = 200; + protected static final int HTTP_OK_TOP = 299; + + private static final String INTERFACE_NAME_BASE = " CRUD Interface"; + private static final String UUID_NO_EXIST_BASE = " UUID does not exist."; + protected static final String NO_PROVIDERS = "No providers registered. Please try again later"; + protected static final String NO_PROVIDER_LIST = "Couldn't get providers list. Please try again later"; + + protected static final String serviceUnavailable(String resourceName) { + return resourceName + INTERFACE_NAME_BASE + RestMessages.SERVICEUNAVAILABLE.toString(); + } + protected static final String uuidNoExist(String resourceName) { + return resourceName + UUID_NO_EXIST_BASE; + } +} diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java index 285bfc245..3bd8e9f7c 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallNorthbound.java @@ -49,14 +49,9 @@ import java.util.List; * */ @Path("/fw/firewalls") -public class NeutronFirewallNorthbound { +public class NeutronFirewallNorthbound extends AbstractNeutronNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Firewall CRUD Interface"; - private static final String UUID_NO_EXIST = "Firewall 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 = "Firewall"; private NeutronFirewall extractFields(NeutronFirewall o, List fields) { return o.extractFields(fields); @@ -65,8 +60,7 @@ public class NeutronFirewallNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFirewallCRUD(this); if (answer.getFirewallInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -147,7 +141,7 @@ public class NeutronFirewallNorthbound { @QueryParam("fields") List fields) { INeutronFirewallCRUD firewallInterface = getNeutronInterfaces().getFirewallInterface(); if (!firewallInterface.neutronFirewallExists(firewallUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronFirewall ans = firewallInterface.getNeutronFirewall(firewallUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java index 6509c3d0d..585347ce3 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallPolicyNorthbound.java @@ -50,14 +50,9 @@ import org.opendaylight.neutron.spi.NeutronFirewallPolicy; * */ @Path("/fw/firewall_policies") -public class NeutronFirewallPolicyNorthbound { +public class NeutronFirewallPolicyNorthbound extends AbstractNeutronNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Firewall Policy CRUD Interface"; - private static final String UUID_NO_EXIST = "Firewall Policy 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 = "Firewall Policy"; private NeutronFirewallPolicy extractFields(NeutronFirewallPolicy o, List fields) { return o.extractFields(fields); @@ -66,8 +61,7 @@ public class NeutronFirewallPolicyNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFirewallPolicyCRUD(this); if (answer.getFirewallPolicyInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -145,7 +139,7 @@ public class NeutronFirewallPolicyNorthbound { @QueryParam("fields") List fields) { INeutronFirewallPolicyCRUD firewallPolicyInterface = getNeutronInterfaces().getFirewallPolicyInterface(); if (!firewallPolicyInterface.neutronFirewallPolicyExists(firewallPolicyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronFirewallPolicy ans = firewallPolicyInterface.getNeutronFirewallPolicy(firewallPolicyUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java index 60595a4be..b70f88452 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFirewallRulesNorthbound.java @@ -50,14 +50,8 @@ import org.opendaylight.neutron.spi.NeutronFirewallRule; */ @Path("fw/firewall_rules") -public class NeutronFirewallRulesNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Firewall Rule CRUD Interface"; - private static final String UUID_NO_EXIST = "Firewall 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 NeutronFirewallRulesNorthbound extends AbstractNeutronNorthbound { + private static final String RESOURCE_NAME = "Firewall Rule"; private NeutronFirewallRule extractFields(NeutronFirewallRule o, List fields) { return o.extractFields(fields); @@ -66,8 +60,7 @@ public class NeutronFirewallRulesNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFirewallRuleCRUD(this); if (answer.getFirewallRuleInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -173,7 +166,7 @@ public class NeutronFirewallRulesNorthbound { @QueryParam("fields") List fields) { INeutronFirewallRuleCRUD firewallRuleInterface = getNeutronInterfaces().getFirewallRuleInterface(); if (!firewallRuleInterface.neutronFirewallRuleExists(firewallRuleUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronFirewallRule ans = firewallRuleInterface.getNeutronFirewallRule(firewallRuleUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java index 03b014fba..7e282d25c 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronFloatingIPsNorthbound.java @@ -56,13 +56,8 @@ import org.opendaylight.neutron.spi.NeutronNetwork; */ @Path("/floatingips") -public class NeutronFloatingIPsNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Floating IP CRUD Interface"; - private static final String UUID_NO_EXIST = "Floating IP 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 NeutronFloatingIPsNorthbound extends AbstractNeutronNorthbound { + private static final String RESOURCE_NAME = "Floating IP"; private NeutronFloatingIP extractFields(NeutronFloatingIP o, List fields) { @@ -72,8 +67,7 @@ public class NeutronFloatingIPsNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces(boolean flag) { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronFloatingIPCRUD(this); if (answer.getFloatingIPInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } if (flag) { answer = answer.fetchINeutronNetworkCRUD(this).fetchINeutronSubnetCRUD(this).fetchINeutronPortCRUD(this); @@ -165,7 +159,7 @@ public class NeutronFloatingIPsNorthbound { @QueryParam("fields") List fields ) { INeutronFloatingIPCRUD floatingIPInterface = getNeutronInterfaces(false).getFloatingIPInterface(); if (!floatingIPInterface.floatingIPExists(floatingipUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronFloatingIP ans = floatingIPInterface.getFloatingIP(floatingipUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java index a4b536d80..35e7b8606 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerHealthMonitorNorthbound.java @@ -51,15 +51,9 @@ import org.opendaylight.neutron.spi.NeutronLoadBalancerHealthMonitor; * */ @Path("/lbaas/healthmonitors") -public class NeutronLoadBalancerHealthMonitorNorthbound { - - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "LoadBalancerHealthMonitor CRUD Interface"; - private static final String UUID_NO_EXIST = "LoadBalancerHealthMonitor 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 NeutronLoadBalancerHealthMonitorNorthbound extends AbstractNeutronNorthbound { + private static final String RESOURCE_NAME = "LoadBalancerHealthMonitor"; private NeutronLoadBalancerHealthMonitor extractFields(NeutronLoadBalancerHealthMonitor o, List fields) { return o.extractFields(fields); @@ -68,8 +62,7 @@ public class NeutronLoadBalancerHealthMonitorNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronLoadBalancerHealthMonitorCRUD(this); if (answer.getLoadBalancerHealthMonitorInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -168,7 +161,7 @@ public class NeutronLoadBalancerHealthMonitorNorthbound { @QueryParam("fields") List fields) { INeutronLoadBalancerHealthMonitorCRUD loadBalancerHealthMonitorInterface = getNeutronInterfaces().getLoadBalancerHealthMonitorInterface(); if (!loadBalancerHealthMonitorInterface.neutronLoadBalancerHealthMonitorExists(loadBalancerHealthMonitorID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronLoadBalancerHealthMonitor ans = loadBalancerHealthMonitorInterface.getNeutronLoadBalancerHealthMonitor(loadBalancerHealthMonitorID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java index 4fc54705f..bd9ff1026 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerListenerNorthbound.java @@ -51,15 +51,9 @@ import org.opendaylight.neutron.spi.NeutronLoadBalancerListener; * */ @Path("/lbaas/listeners") -public class NeutronLoadBalancerListenerNorthbound { - - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "LoadBalancerListener CRUD Interface"; - private static final String UUID_NO_EXIST = "LoadBalancerListener 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 NeutronLoadBalancerListenerNorthbound extends AbstractNeutronNorthbound { + private static final String RESOURCE_NAME = "LoadBalancerListener"; private NeutronLoadBalancerListener extractFields(NeutronLoadBalancerListener o, List fields) { return o.extractFields(fields); @@ -68,8 +62,7 @@ public class NeutronLoadBalancerListenerNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronLoadBalancerListenerCRUD(this); if (answer.getLoadBalancerListenerInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -152,7 +145,7 @@ public class NeutronLoadBalancerListenerNorthbound { @QueryParam("fields") List fields) { INeutronLoadBalancerListenerCRUD loadBalancerListenerInterface = getNeutronInterfaces().getLoadBalancerListenerInterface(); if (!loadBalancerListenerInterface.neutronLoadBalancerListenerExists(loadBalancerListenerID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronLoadBalancerListener ans = loadBalancerListenerInterface.getNeutronLoadBalancerListener(loadBalancerListenerID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java index 1703856da..cdbbb37fb 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerNorthbound.java @@ -51,14 +51,9 @@ import org.opendaylight.neutron.spi.NeutronLoadBalancer; * */ @Path("/lbaas/loadbalancers") -public class NeutronLoadBalancerNorthbound { +public class NeutronLoadBalancerNorthbound extends AbstractNeutronNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "LoadBalancer CRUD Interface"; - private static final String UUID_NO_EXIST = "LoadBalancer 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 = "LoadBalancer"; private NeutronLoadBalancer extractFields(NeutronLoadBalancer o, List fields) { return o.extractFields(fields); @@ -67,8 +62,7 @@ public class NeutronLoadBalancerNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronLoadBalancerCRUD(this); if (answer.getLoadBalancerInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -147,7 +141,7 @@ public class NeutronLoadBalancerNorthbound { @QueryParam("fields") List fields) { INeutronLoadBalancerCRUD loadBalancerInterface = getNeutronInterfaces().getLoadBalancerInterface(); if (!loadBalancerInterface.neutronLoadBalancerExists(loadBalancerID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronLoadBalancer ans = loadBalancerInterface.getNeutronLoadBalancer(loadBalancerID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java index 286850286..b56adf813 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronLoadBalancerPoolNorthbound.java @@ -59,14 +59,9 @@ import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember; */ @Path("/lbaas/pools") -public class NeutronLoadBalancerPoolNorthbound { +public class NeutronLoadBalancerPoolNorthbound extends AbstractNeutronNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "LoadBalancerPool CRUD Interface"; - private static final String UUID_NO_EXIST = "LoadBalancerPool 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 = "LoadBalancerPool"; private NeutronLoadBalancerPool extractFields(NeutronLoadBalancerPool o, List fields) { return o.extractFields(fields); @@ -76,8 +71,7 @@ public class NeutronLoadBalancerPoolNorthbound { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces(). fetchINeutronLoadBalancerPoolCRUD(this); if (answer.getLoadBalancerPoolInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -163,7 +157,7 @@ public class NeutronLoadBalancerPoolNorthbound { @QueryParam("fields") List fields) { INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = getNeutronInterfaces().getLoadBalancerPoolInterface(); if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronLoadBalancerPool ans = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolID); @@ -377,7 +371,7 @@ public class NeutronLoadBalancerPoolNorthbound { ) { INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = getNeutronInterfaces().getLoadBalancerPoolInterface(); if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } List members = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID).getLoadBalancerPoolMembers(); @@ -429,7 +423,7 @@ public class NeutronLoadBalancerPoolNorthbound { INeutronLoadBalancerPoolCRUD loadBalancerPoolInterface = getNeutronInterfaces().getLoadBalancerPoolInterface(); if (!loadBalancerPoolInterface.neutronLoadBalancerPoolExists(loadBalancerPoolUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } List members = loadBalancerPoolInterface.getNeutronLoadBalancerPool(loadBalancerPoolUUID).getLoadBalancerPoolMembers(); @@ -446,7 +440,7 @@ public class NeutronLoadBalancerPoolNorthbound { new NeutronLoadBalancerPoolMemberRequest(ans)).build(); } } - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } /** diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java index c687b6e9a..13aa5335d 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelRulesNorthbound.java @@ -55,10 +55,7 @@ import org.opendaylight.neutron.spi.NeutronMeteringLabelRule; */ @Path("/metering/metering-label-rules") -public class NeutronMeteringLabelRulesNorthbound { - - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; +public class NeutronMeteringLabelRulesNorthbound extends AbstractNeutronNorthbound { private NeutronMeteringLabelRule extractFields(NeutronMeteringLabelRule o, List fields) { return o.extractFields(fields); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java index cf997dbd3..ffb32449b 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronMeteringLabelsNorthbound.java @@ -55,10 +55,7 @@ import org.opendaylight.neutron.spi.NeutronMeteringLabel; */ @Path("/metering/metering-labels") -public class NeutronMeteringLabelsNorthbound { - - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; +public class NeutronMeteringLabelsNorthbound extends AbstractNeutronNorthbound { private NeutronMeteringLabel extractFields(NeutronMeteringLabel o, List fields) { return o.extractFields(fields); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java index 1831f718f..1b14b6d3a 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNetworksNorthbound.java @@ -56,17 +56,12 @@ import org.opendaylight.neutron.spi.NeutronNetwork; */ @Path("/networks") -public class NeutronNetworksNorthbound { +public class NeutronNetworksNorthbound extends AbstractNeutronNorthbound { @Context UriInfo uriInfo; - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Network CRUD Interface"; - private static final String UUID_NO_EXIST = "Network 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 = "Network"; private NeutronNetwork extractFields(NeutronNetwork o, List fields) { return o.extractFields(fields); @@ -75,8 +70,7 @@ public class NeutronNetworksNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronNetworkCRUD(this); if (answer.getNetworkInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -177,7 +171,7 @@ public class NeutronNetworksNorthbound { ) { INeutronNetworkCRUD networkInterface = getNeutronInterfaces().getNetworkInterface(); if (!networkInterface.networkExists(netUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronNetwork ans = networkInterface.getNetwork(netUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java index 7e0654066..63d5aaf1e 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronPortsNorthbound.java @@ -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 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 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); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java index eedfee35c..62cec5778 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronRoutersNorthbound.java @@ -57,15 +57,10 @@ import org.opendaylight.neutron.spi.NeutronRouter_Interface; */ @Path("/routers") -public class NeutronRoutersNorthbound { +public class NeutronRoutersNorthbound extends AbstractNeutronNorthbound { static final String ROUTER_INTERFACE_STR = "network:router_interface"; static final String ROUTER_GATEWAY_STR = "network:router_gateway"; - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Router CRUD Interface"; - private static final String UUID_NO_EXIST = "Router 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 = "Router"; private NeutronRouter extractFields(NeutronRouter o, List fields) { return o.extractFields(fields); @@ -74,8 +69,7 @@ public class NeutronRoutersNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces(boolean flag) { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronRouterCRUD(this); if (answer.getRouterInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } if (flag) { answer = answer.fetchINeutronNetworkCRUD(this); @@ -90,8 +84,7 @@ public class NeutronRoutersNorthbound { private NeutronCRUDInterfaces getAttachInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronRouterCRUD(this); if (answer.getRouterInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } answer = answer.fetchINeutronPortCRUD(this).fetchINeutronSubnetCRUD(this); if (answer.getPortInterface() == null) { @@ -134,8 +127,7 @@ public class NeutronRoutersNorthbound { ) { INeutronRouterCRUD routerInterface = getNeutronInterfaces(false).getRouterInterface(); if (routerInterface == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } List allRouters = routerInterface.getAllRouters(); List ans = new ArrayList(); @@ -180,11 +172,10 @@ public class NeutronRoutersNorthbound { @QueryParam("fields") List fields) { INeutronRouterCRUD routerInterface = getNeutronInterfaces(false).getRouterInterface(); if (routerInterface == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } if (!routerInterface.routerExists(routerUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronRouter ans = routerInterface.getRouter(routerUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java index f9dd4cb8e..681fefb32 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityGroupsNorthbound.java @@ -50,13 +50,8 @@ import org.opendaylight.neutron.spi.NeutronSecurityGroup; * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration */ @Path ("/security-groups") -public class NeutronSecurityGroupsNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Security Group CRUD Interface"; - private static final String UUID_NO_EXIST = "Security Group 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 NeutronSecurityGroupsNorthbound extends AbstractNeutronNorthbound { + private static final String RESOURCE_NAME = "Security Group"; private NeutronSecurityGroup extractFields(NeutronSecurityGroup o, List fields) { return o.extractFields(fields); @@ -65,8 +60,7 @@ public class NeutronSecurityGroupsNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSecurityGroupCRUD(this); if (answer.getSecurityGroupInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -137,7 +131,7 @@ public class NeutronSecurityGroupsNorthbound { @QueryParam ("fields") List fields) { INeutronSecurityGroupCRUD securityGroupInterface = getNeutronInterfaces().getSecurityGroupInterface(); if (!securityGroupInterface.neutronSecurityGroupExists(securityGroupUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (!fields.isEmpty()) { NeutronSecurityGroup ans = securityGroupInterface.getNeutronSecurityGroup(securityGroupUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java index a0822a890..38f9a07f5 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSecurityRulesNorthbound.java @@ -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 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 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); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java index 0add6b865..fdcb6374f 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSubnetsNorthbound.java @@ -56,13 +56,8 @@ import org.opendaylight.neutron.spi.NeutronSubnet; */ @Path("/subnets") -public class NeutronSubnetsNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "Subnet CRUD Interface"; - private static final String UUID_NO_EXIST = "Subnet 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 NeutronSubnetsNorthbound extends AbstractNeutronNorthbound { + private static final String RESOURCE_NAME = "Subnet"; private NeutronSubnet extractFields(NeutronSubnet o, List fields) { return o.extractFields(fields); @@ -71,8 +66,7 @@ public class NeutronSubnetsNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces(boolean needNetwork) { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSubnetCRUD(this); if (answer.getSubnetInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } if (needNetwork) { answer = answer.fetchINeutronNetworkCRUD(this); @@ -171,7 +165,7 @@ public class NeutronSubnetsNorthbound { @QueryParam("fields") List fields) { INeutronSubnetCRUD subnetInterface = getNeutronInterfaces(false).getSubnetInterface(); if (!subnetInterface.subnetExists(subnetUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronSubnet ans = subnetInterface.getSubnet(subnetUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java index f086a2e3f..042ba6b29 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIKEPoliciesNorthbound.java @@ -55,12 +55,8 @@ import org.opendaylight.neutron.spi.NeutronVPNIKEPolicy; */ @Path("/vpn/ikepolicies") -public class NeutronVPNIKEPoliciesNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String UUID_NO_EXIST = "VPNIKEPolicy 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 NeutronVPNIKEPoliciesNorthbound extends AbstractNeutronNorthbound { + private static final String RESOURCE_NAME = "VPNIKEPolicy"; private NeutronVPNIKEPolicy extractFields(NeutronVPNIKEPolicy o, List fields) { return o.extractFields(fields); @@ -150,7 +146,7 @@ public class NeutronVPNIKEPoliciesNorthbound { ) { INeutronVPNIKEPolicyCRUD policyInterface = getNeutronInterfaces().getVPNIKEPolicyInterface(); if (!policyInterface.neutronVPNIKEPolicyExists(policyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronVPNIKEPolicy ans = policyInterface.getNeutronVPNIKEPolicy(policyUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java index 9c3a10b01..59c935f53 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECPoliciesNorthbound.java @@ -55,13 +55,9 @@ import org.opendaylight.neutron.spi.NeutronVPNIPSECPolicy; */ @Path("/vpn/ipsecpolicies") -public class NeutronVPNIPSECPoliciesNorthbound { +public class NeutronVPNIPSECPoliciesNorthbound extends AbstractNeutronNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String UUID_NO_EXIST = "VPNIPSECPolicy 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 = "VPNIPSECPolicy"; private NeutronVPNIPSECPolicy extractFields(NeutronVPNIPSECPolicy o, List fields) { return o.extractFields(fields); @@ -151,7 +147,7 @@ public class NeutronVPNIPSECPoliciesNorthbound { ) { INeutronVPNIPSECPolicyCRUD policyInterface = getNeutronInterfaces().getVPNIPSECPolicyInterface(); if (!policyInterface.neutronVPNIPSECPolicyExists(policyUUID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronVPNIPSECPolicy ans = policyInterface.getNeutronVPNIPSECPolicy(policyUUID); diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java index b2dcbb0b1..71c62ac4d 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNIPSECSiteConnectionsNorthbound.java @@ -55,13 +55,9 @@ import org.opendaylight.neutron.spi.NeutronVPNIPSECSiteConnection; */ @Path("/vpn/ipsecsiteconnections") -public class NeutronVPNIPSECSiteConnectionsNorthbound { +public class NeutronVPNIPSECSiteConnectionsNorthbound extends AbstractNeutronNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "VPNIPSECSiteConnections CRUD Interface"; - 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 = "VPNIPSECSiteConnections"; private NeutronVPNIPSECSiteConnection extractFields(NeutronVPNIPSECSiteConnection o, List fields) { return o.extractFields(fields); @@ -70,8 +66,7 @@ public class NeutronVPNIPSECSiteConnectionsNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronVPNIPSECSiteConnectionsCRUD(this); if (answer.getVPNIPSECSiteConnectionsInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java index 0825b0a25..59a331613 100644 --- a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java +++ b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronVPNServicesNorthbound.java @@ -55,14 +55,9 @@ import org.opendaylight.neutron.spi.NeutronVPNService; */ @Path("/vpn/vpnservices") -public class NeutronVPNServicesNorthbound { +public class NeutronVPNServicesNorthbound extends AbstractNeutronNorthbound { - private static final int HTTP_OK_BOTTOM = 200; - private static final int HTTP_OK_TOP = 299; - private static final String INTERFACE_NAME = "VPNService CRUD Interface"; - private static final String UUID_NO_EXIST = "VPNService 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 = "VPNService"; private NeutronVPNService extractFields(NeutronVPNService o, List fields) { return o.extractFields(fields); @@ -74,8 +69,7 @@ public class NeutronVPNServicesNorthbound { private NeutronCRUDInterfaces getNeutronInterfaces() { NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronVPNServiceCRUD(this); if (answer.getVPNServiceInterface() == null) { - throw new ServiceUnavailableException(INTERFACE_NAME - + RestMessages.SERVICEUNAVAILABLE.toString()); + throw new ServiceUnavailableException(serviceUnavailable(RESOURCE_NAME)); } return answer; } @@ -148,7 +142,7 @@ public class NeutronVPNServicesNorthbound { @QueryParam("fields") List fields) { INeutronVPNServiceCRUD VPNServiceInterface = getNeutronInterfaces().getVPNServiceInterface(); if (!VPNServiceInterface.neutronVPNServiceExists(serviceID)) { - throw new ResourceNotFoundException(UUID_NO_EXIST); + throw new ResourceNotFoundException(uuidNoExist(RESOURCE_NAME)); } if (fields.size() > 0) { NeutronVPNService ans = VPNServiceInterface.getVPNService(serviceID); -- 2.36.6