X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fmapping%2Fattributes%2Ffromxml%2FObjectNameAttributeReadingStrategy.java;h=709c8d23b864e5af11a76e21ebd723ec3efb5121;hp=8720c654c61f993f09d6503305fdc471d4065a94;hb=396cfb3692d1db20e429462cc1862e5eeb7fe4a4;hpb=f0f2ca29ae8b5caa769a77854fc5ac883b0a2264 diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java index 8720c654c6..709c8d23b8 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java @@ -8,10 +8,8 @@ package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml; import com.google.common.base.Preconditions; - 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; @@ -51,15 +49,18 @@ public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReading public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry prefixNamespace) throws NetconfDocumentedException { String serviceName = typeElement.getTextContent(); - // FIXME: comparing Entry with String: - Preconditions.checkState(!prefixNamespace.equals(""), "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; + } } }