X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fmapping%2Fattributes%2Ffromxml%2FObjectNameAttributeReadingStrategy.java;fp=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fmapping%2Fattributes%2Ffromxml%2FObjectNameAttributeReadingStrategy.java;h=0000000000000000000000000000000000000000;hb=23fe9ca678ada6263fec5dd996f4025e4a32fcf5;hp=709c8d23b864e5af11a76e21ebd723ec3efb5121;hpb=071a641d7c12c0e6112d5ce0afe806b54f116ed2;p=controller.git 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 deleted file mode 100644 index 709c8d23b8..0000000000 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/attributes/fromxml/ObjectNameAttributeReadingStrategy.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. 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.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; -import org.opendaylight.controller.netconf.util.xml.XmlElement; - -public class ObjectNameAttributeReadingStrategy extends AbstractAttributeReadingStrategy { - - private static final Object PREFIX_SEPARATOR = ":"; - - public ObjectNameAttributeReadingStrategy(String nullableDefault) { - super(nullableDefault); - } - - @Override - AttributeConfigElement readElementHook(List configNodes) throws NetconfDocumentedException { - - XmlElement firstChild = configNodes.get(0); - Preconditions.checkState(configNodes.size() == 1, "This element should be present only once " + firstChild - + " but was " + configNodes.size()); - - Preconditions.checkNotNull(firstChild, "Element %s should be present", firstChild); - return AttributeConfigElement.create(getNullableDefault(), resolve(firstChild)); - } - - private ObjectNameAttributeMappingStrategy.MappedDependency resolve(XmlElement firstChild) throws NetconfDocumentedException{ - XmlElement typeElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY); - Map.Entry prefixNamespace = typeElement.findNamespaceOfTextContent(); - - String serviceName = checkPrefixAndExtractServiceName(typeElement, prefixNamespace); - - XmlElement nameElement = firstChild.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.NAME_KEY); - String dependencyName = nameElement.getTextContent(); - - return new ObjectNameAttributeMappingStrategy.MappedDependency(prefixNamespace.getValue(), serviceName, - dependencyName); - } - - public static String checkPrefixAndExtractServiceName(XmlElement typeElement, Map.Entry prefixNamespace) throws NetconfDocumentedException { - String serviceName = typeElement.getTextContent(); - Preconditions.checkNotNull(prefixNamespace.getKey(), "Service %s value cannot be linked to namespace", - XmlNetconfConstants.TYPE_KEY); - 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; - } - } - -}