CDS: Add stress test RPC to the cars model
[controller.git] / opendaylight / netconf / config-netconf-connector / src / main / java / org / opendaylight / controller / netconf / confignetconfconnector / mapping / attributes / fromxml / ObjectNameAttributeReadingStrategy.java
index 1d12292edb2624ee12b7d1c469c44102ab617dfc..709c8d23b864e5af11a76e21ebd723ec3efb5121 100644 (file)
@@ -8,11 +8,8 @@
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml;
 
 import com.google.common.base.Preconditions;
-
-import com.google.common.base.Strings;
 import java.util.List;
 import java.util.Map;
-
 import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
 import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectNameAttributeMappingStrategy;
@@ -52,15 +49,18 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading
 
     public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry<String, String> prefixNamespace) throws NetconfDocumentedException {
         String serviceName = typeElement.getTextContent();
-        // FIXME: comparing Entry with String:
-        Preconditions.checkState(!Strings.isNullOrEmpty(prefixNamespace.getKey()), "Service %s value not prefixed with namespace",
+        Preconditions.checkNotNull(prefixNamespace.getKey(), "Service %s value cannot be linked to namespace",
                 XmlNetconfConstants.TYPE_KEY);
-        String prefix = prefixNamespace.getKey() + PREFIX_SEPARATOR;
-        Preconditions.checkState(serviceName.startsWith(prefix),
-                "Service %s not correctly prefixed, expected %s, but was %s", XmlNetconfConstants.TYPE_KEY, prefix,
-                serviceName);
-        serviceName = serviceName.substring(prefix.length());
-        return serviceName;
+        if(prefixNamespace.getKey().isEmpty()) {
+            return serviceName;
+        } else {
+            String prefix = prefixNamespace.getKey() + PREFIX_SEPARATOR;
+            Preconditions.checkState(serviceName.startsWith(prefix),
+                    "Service %s not correctly prefixed, expected %s, but was %s", XmlNetconfConstants.TYPE_KEY, prefix,
+                    serviceName);
+            serviceName = serviceName.substring(prefix.length());
+            return serviceName;
+        }
     }
 
 }