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%2FInstanceConfig.java;fp=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Fmapping%2Fconfig%2FInstanceConfig.java;h=84fb06418af9570ae71eb91972a705aef9468b40;hp=7cfeb453bb58f6615d64144bc4e88dd377c7b17e;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/InstanceConfig.java b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java similarity index 77% rename from opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/InstanceConfig.java rename to opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java index 7cfeb453bb..84fb06418a 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/config/InstanceConfig.java +++ b/opendaylight/config/config-manager-facade-xml/src/main/java/org/opendaylight/controller/config/facade/xml/mapping/config/InstanceConfig.java @@ -1,12 +1,12 @@ /* - * 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.collect.Lists; @@ -17,25 +17,25 @@ import java.util.Map; import java.util.Map.Entry; import javax.management.ObjectName; import javax.management.openmbean.OpenType; +import org.opendaylight.controller.config.facade.xml.mapping.IdentityMapping; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeConfigElement; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.AttributeReadingStrategy; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.fromxml.ObjectXmlReader; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.mapping.AttributeMappingStrategy; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.mapping.ObjectMapper; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.AttributeResolvingStrategy; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.resolving.ObjectResolver; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.toxml.AttributeWritingStrategy; +import org.opendaylight.controller.config.facade.xml.mapping.attributes.toxml.ObjectXmlWriter; +import org.opendaylight.controller.config.facade.xml.osgi.EnumResolver; +import org.opendaylight.controller.config.facade.xml.strategy.EditStrategyType; import org.opendaylight.controller.config.util.BeanReader; +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.controller.config.yangjmxgenerator.RuntimeBeanEntry; import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeReadingStrategy; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.ObjectXmlReader; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.AttributeMappingStrategy; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.mapping.ObjectMapper; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving.AttributeResolvingStrategy; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.resolving.ObjectResolver; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml.AttributeWritingStrategy; -import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.toxml.ObjectXmlWriter; -import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditConfig; -import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditStrategyType; -import org.opendaylight.controller.netconf.confignetconfconnector.osgi.EnumResolver; -import org.opendaylight.controller.netconf.util.xml.XmlElement; -import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; @@ -136,14 +136,14 @@ public final class InstanceConfig { public InstanceConfigElementResolved fromXml(XmlElement moduleElement, ServiceRegistryWrapper services, String moduleNamespace, EditStrategyType defaultStrategy, - Map> identityMap, final EnumResolver enumResolver) throws NetconfDocumentedException { + Map> identityMap, final EnumResolver enumResolver) throws DocumentedException { Map retVal = Maps.newHashMap(); Map strats = new ObjectXmlReader().prepareReading(yangToAttrConfig, identityMap); List recognisedChildren = Lists.newArrayList(); - XmlElement typeElement = moduleElement.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.TYPE_KEY); - XmlElement nameElement = moduleElement.getOnlyChildElementWithSameNamespace(XmlNetconfConstants.NAME_KEY); + XmlElement typeElement = moduleElement.getOnlyChildElementWithSameNamespace(XmlMappingConstants.TYPE_KEY); + XmlElement nameElement = moduleElement.getOnlyChildElementWithSameNamespace(XmlMappingConstants.NAME_KEY); List typeAndNameElements = Lists.newArrayList(typeElement, nameElement); // if dummy container was defined in yang, set moduleElement to its content @@ -151,7 +151,7 @@ public final class InstanceConfig { int size = moduleElement.getChildElements().size(); int expectedChildNodes = 1 + typeAndNameElements.size(); if (size > expectedChildNodes) { - throw new NetconfDocumentedException("Error reading module " + typeElement.getTextContent() + " : " + + throw new DocumentedException("Error reading module " + typeElement.getTextContent() + " : " + nameElement.getTextContent() + " - Expected " + expectedChildNodes +" child nodes, " + "one of them with name " + nullableDummyContainerName + ", got " + size + " elements."); @@ -159,8 +159,8 @@ public final class InstanceConfig { if (size == expectedChildNodes) { try { moduleElement = moduleElement.getOnlyChildElement(nullableDummyContainerName, moduleNamespace); - } catch (NetconfDocumentedException e) { - throw new NetconfDocumentedException("Error reading module " + typeElement.getTextContent() + " : " + + } catch (DocumentedException e) { + throw new DocumentedException("Error reading module " + typeElement.getTextContent() + " : " + nameElement.getTextContent() + " - Expected child node with name " + nullableDummyContainerName + "." + e.getMessage()); } @@ -177,14 +177,14 @@ public final class InstanceConfig { recognisedChildren.addAll(typeAndNameElements); try { moduleElement.checkUnrecognisedElements(recognisedChildren); - } catch (NetconfDocumentedException e) { - throw new NetconfDocumentedException("Error reading module " + typeElement.getTextContent() + " : " + + } catch (DocumentedException e) { + throw new DocumentedException("Error reading module " + typeElement.getTextContent() + " : " + nameElement.getTextContent() + " - " + e.getMessage(), e.getErrorType(), e.getErrorTag(),e.getErrorSeverity(),e.getErrorInfo()); } // TODO: add check for conflicts between global and local edit strategy - String perInstanceEditStrategy = moduleElement.getAttribute(XmlNetconfConstants.OPERATION_ATTR_KEY, - XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); + String perInstanceEditStrategy = moduleElement.getAttribute(XmlMappingConstants.OPERATION_ATTR_KEY, + XmlMappingConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); InstanceConfigElementResolved instanceConfigElementResolved = perInstanceEditStrategy.equals("") ? new InstanceConfigElementResolved( retVal, defaultStrategy) : new InstanceConfigElementResolved(perInstanceEditStrategy, retVal, defaultStrategy); @@ -194,13 +194,13 @@ public final class InstanceConfig { } private List getConfigNodes(XmlElement moduleElement, String moduleNamespace, String name, - List recognisedChildren, List typeAndName) throws NetconfDocumentedException { + List recognisedChildren, List typeAndName) throws DocumentedException { List foundConfigNodes = moduleElement.getChildElementsWithinNamespace(name, moduleNamespace); if (foundConfigNodes.isEmpty()) { LOG.debug("No config nodes {}:{} found in {}", moduleNamespace, name, moduleElement); LOG.debug("Trying lookup of config nodes without specified namespace"); foundConfigNodes = moduleElement.getChildElementsWithinNamespace(name, - XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG); + XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG); // In case module type or name element is not present in config it // would be matched with config type or name // We need to remove config type and name from available module @@ -210,14 +210,14 @@ public final class InstanceConfig { moduleElement); } else { List foundWithoutNamespaceNodes = moduleElement.getChildElementsWithinNamespace(name, - XmlNetconfConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG); + XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG); foundWithoutNamespaceNodes.removeAll(typeAndName); if (!foundWithoutNamespaceNodes.isEmpty()){ - throw new NetconfDocumentedException(String.format("Element %s present multiple times with different namespaces: %s, %s", name, foundConfigNodes, + throw new DocumentedException(String.format("Element %s present multiple times with different namespaces: %s, %s", name, foundConfigNodes, foundWithoutNamespaceNodes), - NetconfDocumentedException.ErrorType.application, - NetconfDocumentedException.ErrorTag.invalid_value, - NetconfDocumentedException.ErrorSeverity.error); + DocumentedException.ErrorType.application, + DocumentedException.ErrorTag.invalid_value, + DocumentedException.ErrorSeverity.error); } }