X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Foperations%2Fget%2FGet.java;h=4665c2cc89cf23d9f5efbb876b532b377ef22896;hb=1ded3b4311dc761d39c132f9f38fcceb761ea997;hp=ea602091a0423ec0957a5c0974f163b89f0fd72a;hpb=79eba117e59f10c8bff34d0dd6bbb67b8ccc3e10;p=controller.git diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java index ea602091a0..4665c2cc89 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java @@ -11,13 +11,9 @@ package org.opendaylight.controller.netconf.confignetconfconnector.operations.ge import com.google.common.collect.Maps; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.config.util.ConfigTransactionClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag; -import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorType; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.InstanceConfig; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ModuleConfig; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.ServiceRegistryWrapper; @@ -27,7 +23,11 @@ import org.opendaylight.controller.netconf.confignetconfconnector.mapping.runtim import org.opendaylight.controller.netconf.confignetconfconnector.operations.AbstractConfigNetconfOperation; import org.opendaylight.controller.netconf.confignetconfconnector.operations.Datastore; import org.opendaylight.controller.netconf.confignetconfconnector.operations.editconfig.EditConfig; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider; +import org.opendaylight.controller.netconf.util.exception.MissingNameSpaceException; +import org.opendaylight.controller.netconf.util.exception.UnexpectedElementException; +import org.opendaylight.controller.netconf.util.exception.UnexpectedNamespaceException; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; import org.slf4j.Logger; @@ -36,7 +36,6 @@ import org.w3c.dom.Document; import org.w3c.dom.Element; import javax.management.ObjectName; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -70,12 +69,14 @@ public class Get extends AbstractConfigNetconfOperation { RuntimeBeanEntry root = null; for (RuntimeBeanEntry rbe : mbe.getRuntimeBeans()) { cache.put(rbe, new InstanceConfig(configRegistryClient, rbe.getYangPropertiesToTypesMap())); - if (rbe.isRoot()) + if (rbe.isRoot()){ root = rbe; + } } - if (root == null) + if (root == null){ continue; + } InstanceRuntime rootInstanceRuntime = createInstanceRuntime(root, cache); ModuleRuntime moduleRuntime = new ModuleRuntime(module, rootInstanceRuntime); @@ -104,13 +105,14 @@ public class Get extends AbstractConfigNetconfOperation { return jmxToYangNamesForChildRbe; } - private static void checkXml(XmlElement xml) { + private static void checkXml(XmlElement xml) throws UnexpectedElementException, UnexpectedNamespaceException, MissingNameSpaceException { xml.checkName(XmlNetconfConstants.GET); xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); // Filter option - unsupported - if (xml.getChildElements(XmlNetconfConstants.FILTER).size() != 0) + if (xml.getChildElements(XmlNetconfConstants.FILTER).size() != 0){ throw new UnsupportedOperationException("Unsupported option " + XmlNetconfConstants.FILTER + " for " + XmlNetconfConstants.GET); + } } @Override @@ -119,41 +121,27 @@ public class Get extends AbstractConfigNetconfOperation { } @Override - protected Element handle(Document document, XmlElement xml) throws NetconfDocumentedException { - try { - checkXml(xml); - } catch (final IllegalArgumentException e) { - logger.warn("Error parsing xml", e); - final Map errorInfo = new HashMap<>(); - errorInfo.put(ErrorTag.bad_attribute.name(), e.getMessage()); - throw new NetconfDocumentedException(e.getMessage(), e, ErrorType.rpc, ErrorTag.bad_attribute, - ErrorSeverity.error, errorInfo); - } catch (final UnsupportedOperationException e) { - logger.warn("Unsupported", e); - final Map errorInfo = new HashMap<>(); - errorInfo.put(ErrorTag.operation_not_supported.name(), "Unsupported option for 'get'"); - throw new NetconfDocumentedException(e.getMessage(), e, ErrorType.application, - ErrorTag.operation_not_supported, ErrorSeverity.error, errorInfo); - } + protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws NetconfDocumentedException { + checkXml(xml); - final Set runtimeBeans = configRegistryClient.lookupRuntimeBeans(); + final Set runtimeBeans = getConfigRegistryClient().lookupRuntimeBeans(); //Transaction provider required only for candidate datastore final Set configBeans = Datastore.getInstanceQueryStrategy(Datastore.running, null) - .queryInstances(configRegistryClient); + .queryInstances(getConfigRegistryClient()); - final Map> moduleRuntimes = createModuleRuntimes(configRegistryClient, + final Map> moduleRuntimes = createModuleRuntimes(getConfigRegistryClient(), yangStoreSnapshot.getModuleMXBeanEntryMap()); final Map> moduleConfigs = EditConfig.transformMbeToModuleConfigs( - configRegistryClient, yangStoreSnapshot.getModuleMXBeanEntryMap()); + getConfigRegistryClient(), yangStoreSnapshot.getModuleMXBeanEntryMap()); final Runtime runtime = new Runtime(moduleRuntimes, moduleConfigs); ObjectName txOn = transactionProvider.getOrCreateTransaction(); - ConfigTransactionClient ta = configRegistryClient.getConfigTransactionClient(txOn); + ConfigTransactionClient ta = getConfigRegistryClient().getConfigTransactionClient(txOn); final Element element = runtime.toXml(runtimeBeans, configBeans, document, new ServiceRegistryWrapper(ta)); - logger.info("{} operation successful", XmlNetconfConstants.GET); + logger.trace("{} operation successful", XmlNetconfConstants.GET); return element; }