From 313c816abdbbe988e03f6dd2bf39a090206fa04e Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Wed, 10 Dec 2014 14:12:17 +0100 Subject: [PATCH] Improve error reporting in ServiceRegistry Change-Id: Ia2619921a8c5dab2d0613a7e6ba724512f077bfa Signed-off-by: Maros Marsalek --- .../config/ServiceRegistryWrapper.java | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ServiceRegistryWrapper.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ServiceRegistryWrapper.java index 8c2c74f2ac..9ce550e505 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ServiceRegistryWrapper.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/ServiceRegistryWrapper.java @@ -24,24 +24,30 @@ public class ServiceRegistryWrapper { this.configServiceRefRegistry = configServiceRefRegistry; } - public ObjectName getByServiceAndRefName(String namespace, String serviceName, String refName) { - Map> serviceNameToRefNameToInstance = getMappedServices().get(namespace); + public ObjectName getByServiceAndRefName(String namespace, String serviceType, String refName) { + Map>> mappedServices = getMappedServices(); + Map> serviceNameToRefNameToInstance = mappedServices.get(namespace); - Preconditions.checkNotNull(serviceNameToRefNameToInstance, "No serviceInstances mapped to " + namespace); + Preconditions.checkArgument(serviceNameToRefNameToInstance != null, + "No service mapped to %s:%s:%s. Wrong namespace, available namespaces: %s", + namespace, serviceType, refName, mappedServices.keySet()); - Map refNameToInstance = serviceNameToRefNameToInstance.get(serviceName); - Preconditions.checkNotNull(refNameToInstance, "No serviceInstances mapped to " + serviceName + " , " - + serviceNameToRefNameToInstance.keySet()); + Map refNameToInstance = serviceNameToRefNameToInstance.get(serviceType); + Preconditions.checkArgument(refNameToInstance != null, + "No service mapped to %s:%s:%s. Wrong service type, available service types: %s" + , namespace, serviceType, refName, serviceNameToRefNameToInstance.keySet()); String instanceId = refNameToInstance.get(refName); - Preconditions.checkArgument(instanceId != null, "No serviceInstances mapped to " + serviceName + ":" - + refName + ", " + serviceNameToRefNameToInstance.keySet()); + Preconditions.checkArgument(instanceId != null, + "No service mapped to %s:%s:%s. Wrong ref name, available ref names: %s" + ,namespace, serviceType, refName, refNameToInstance.keySet()); Services.ServiceInstance serviceInstance = Services.ServiceInstance.fromString(instanceId); - Preconditions.checkArgument(serviceInstance != null, "No serviceInstance mapped to " + refName - + " under service name " + serviceName + " , " + refNameToInstance.keySet()); + Preconditions.checkArgument(serviceInstance != null, + "No service mapped to %s:%s:%s. Wrong ref name, available ref names: %s" + ,namespace, serviceType, refName, refNameToInstance.keySet()); - String qNameOfService = configServiceRefRegistry.getServiceInterfaceName(namespace, serviceName); + String qNameOfService = configServiceRefRegistry.getServiceInterfaceName(namespace, serviceType); try { /* Remove transaction name as this is redundant - will be stripped in DynamicWritableWrapper, @@ -51,7 +57,7 @@ public class ServiceRegistryWrapper { configServiceRefRegistry.getServiceReference(qNameOfService, refName)); } catch (InstanceNotFoundException e) { throw new IllegalArgumentException("No serviceInstance mapped to " + refName - + " under service name " + serviceName + " , " + refNameToInstance.keySet(), e); + + " under service name " + serviceType + " , " + refNameToInstance.keySet(), e); } } -- 2.36.6