X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fconfig-manager-facade-xml%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Ffacade%2Fxml%2Fmapping%2Fconfig%2FServices.java;fp=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fmapping%2Fconfig%2FServices.java;h=e3505e479a82e9830386c4019cfb93d82b6b0f72;hp=74655f938fdcacf58417fe3e6a8efca79b517e59;hb=refs%2Fchanges%2F13%2F23413%2F26;hpb=071a641d7c12c0e6112d5ce0afe806b54f116ed2 diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Services.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Services.java similarity index 85% rename from opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Services.java rename to opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Services.java index 74655f938f..e3505e479a 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/Services.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/Services.java @@ -1,12 +1,13 @@ /* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * Copyright (c) 2015 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.config; +package org.opendaylight.controller.config.facade.xml.mapping.config; + import com.google.common.base.Optional; import com.google.common.base.Preconditions; @@ -18,11 +19,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.management.ObjectName; import org.opendaylight.controller.config.api.jmx.ObjectNameUtil; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.ObjectNameAttributeReadingStrategy; -import org.opendaylight.controller.netconf.util.xml.XmlElement; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.ObjectNameAttributeReadingStrategy; +import org.opendaylight.controller.config.util.xml.DocumentedException; +import org.opendaylight.controller.config.util.xml.XmlElement; +import org.opendaylight.controller.config.util.xml.XmlMappingConstants; +import org.opendaylight.controller.config.util.xml.XmlUtil; import org.opendaylight.yangtools.yang.data.api.ModifyAction; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -84,7 +85,7 @@ public final class Services { // TODO support edit strategies on services - public static Services fromXml(XmlElement xml) throws NetconfDocumentedException { + public static Services fromXml(XmlElement xml) throws DocumentedException { Map>> retVal = Maps.newHashMap(); List services = xml.getChildElements(SERVICE_KEY); @@ -103,7 +104,8 @@ public final class Services { retVal.put(prefixNamespace.getValue(), namespaceToServices); } - String serviceName = ObjectNameAttributeReadingStrategy.checkPrefixAndExtractServiceName(typeElement, prefixNamespace); + String serviceName = ObjectNameAttributeReadingStrategy + .checkPrefixAndExtractServiceName(typeElement, prefixNamespace); Map innerMap = namespaceToServices.get(serviceName); if (innerMap == null) { @@ -111,7 +113,7 @@ public final class Services { namespaceToServices.put(serviceName, innerMap); } - List instances = service.getChildElements(XmlNetconfConstants.INSTANCE_KEY); + List instances = service.getChildElements(XmlMappingConstants.INSTANCE_KEY); service.checkUnrecognisedElements(instances, typeElement); for (XmlElement instance : instances) { @@ -120,8 +122,8 @@ public final class Services { if (!ModifyAction.DELETE.toString().toLowerCase().equals( instance.getAttribute( - XmlNetconfConstants.OPERATION_ATTR_KEY, - XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))) + XmlMappingConstants.OPERATION_ATTR_KEY, + XmlMappingConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0))) { XmlElement providerElement = instance.getOnlyChildElement(PROVIDER_KEY); String providerName = providerElement.getTextContent(); @@ -140,7 +142,7 @@ public final class Services { } public static Element toXml(ServiceRegistryWrapper serviceRegistryWrapper, Document document) { - Element root = XmlUtil.createElement(document, XmlNetconfConstants.SERVICES_KEY, Optional.of(XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG)); + Element root = XmlUtil.createElement(document, XmlMappingConstants.SERVICES_KEY, Optional.of(XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG)); Map>> mappedServices = serviceRegistryWrapper.getMappedServices(); for (Entry>> namespaceToRefEntry : mappedServices.entrySet()) { @@ -152,13 +154,13 @@ public final class Services { // type belongs to config.yang namespace String serviceType = serviceEntry.getKey(); - Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlNetconfConstants.TYPE_KEY, - XmlNetconfConstants.PREFIX, namespaceToRefEntry.getKey(), serviceType); + Element typeElement = XmlUtil.createTextElementWithNamespacedContent(document, XmlMappingConstants.TYPE_KEY, + XmlMappingConstants.PREFIX, namespaceToRefEntry.getKey(), serviceType); serviceElement.appendChild(typeElement); for (Entry instanceEntry : serviceEntry.getValue().entrySet()) { - Element instanceElement = XmlUtil.createElement(document, XmlNetconfConstants.INSTANCE_KEY, Optional.absent()); + Element instanceElement = XmlUtil.createElement(document, XmlMappingConstants.INSTANCE_KEY, Optional.absent()); serviceElement.appendChild(instanceElement); Element nameElement = XmlUtil.createTextElement(document, NAME_KEY, instanceEntry.getKey(), Optional.absent()); @@ -216,22 +218,22 @@ public final class Services { } private static final String blueprint = "/" - + XmlNetconfConstants.MODULES_KEY + "/" + XmlNetconfConstants.MODULE_KEY + "[" - + XmlNetconfConstants.TYPE_KEY + "='%s'][" - + XmlNetconfConstants.NAME_KEY + "='%s']"; + + XmlMappingConstants.MODULES_KEY + "/" + XmlMappingConstants.MODULE_KEY + "[" + + XmlMappingConstants.TYPE_KEY + "='%s'][" + + XmlMappingConstants.NAME_KEY + "='%s']"; // TODO unify with xpath in RuntimeRpc // Previous version of xpath, needs to be supported for backwards compatibility (persisted configs by config-persister) - private static final String blueprintRDeprecated = "/" + XmlNetconfConstants.CONFIG_KEY + "/" - + XmlNetconfConstants.MODULES_KEY + "/" + XmlNetconfConstants.MODULE_KEY + "\\[" - + XmlNetconfConstants.NAME_KEY + "='%s'\\]/" + XmlNetconfConstants.INSTANCE_KEY + "\\[" - + XmlNetconfConstants.NAME_KEY + "='%s'\\]"; + private static final String blueprintRDeprecated = "/" + XmlMappingConstants.CONFIG_KEY + "/" + + XmlMappingConstants.MODULES_KEY + "/" + XmlMappingConstants.MODULE_KEY + "\\[" + + XmlMappingConstants.NAME_KEY + "='%s'\\]/" + XmlMappingConstants.INSTANCE_KEY + "\\[" + + XmlMappingConstants.NAME_KEY + "='%s'\\]"; private static final String blueprintR = "/" - + XmlNetconfConstants.MODULES_KEY + "/" + XmlNetconfConstants.MODULE_KEY + "\\[" - + XmlNetconfConstants.TYPE_KEY + "='%s'\\]\\[" - + XmlNetconfConstants.NAME_KEY + "='%s'\\]"; + + XmlMappingConstants.MODULES_KEY + "/" + XmlMappingConstants.MODULE_KEY + "\\[" + + XmlMappingConstants.TYPE_KEY + "='%s'\\]\\[" + + XmlMappingConstants.NAME_KEY + "='%s'\\]"; private static final Pattern pDeprecated = Pattern.compile(String.format(blueprintRDeprecated, "(.+)", "(.+)")); private static final Pattern p = Pattern.compile(String.format(blueprintR, "(.+)", "(.+)"));