X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fmdsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fmdsal%2Fconnector%2Fops%2Fget%2FAbstractGet.java;fp=opendaylight%2Fnetconf%2Fmdsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fmdsal%2Fconnector%2Fops%2Fget%2FAbstractGet.java;h=8f6ff417d6499d47dc594bc5ab5fb2de03e937d0;hp=e0c004461c116c5b1bb23f41c566537e565c05ef;hb=567b1097ccc247ea1c1bf44f0a4d0ab4b4ebb44c;hpb=7d131dccd0e29afda3e1d8ba0b3cb853d4407676 diff --git a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java index e0c004461c..8f6ff417d6 100644 --- a/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java +++ b/opendaylight/netconf/mdsal-netconf-connector/src/main/java/org/opendaylight/controller/netconf/mdsal/connector/ops/get/AbstractGet.java @@ -9,6 +9,7 @@ package org.opendaylight.controller.netconf.mdsal.connector.ops.get; import com.google.common.base.Function; +import com.google.common.base.Optional; import com.google.common.base.Throwables; import com.google.common.collect.Iterables; import java.io.IOException; @@ -115,13 +116,13 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation { } protected static final class GetConfigExecution { - private final Datastore datastore; + private final Optional datastore; - public GetConfigExecution(final Datastore datastore) { + public GetConfigExecution(final Optional datastore) { this.datastore = datastore; } - public Datastore getDatastore() { + public Optional getDatastore() { return datastore; } @@ -132,7 +133,7 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation { throw new NetconfDocumentedException("Incorrect RPC: " + e.getMessage(), e.getErrorType(), e.getErrorTag(), e.getErrorSeverity(), e.getErrorInfo()); } - final Datastore sourceDatastore; + final Optional sourceDatastore; try { sourceDatastore = parseSource(xml); } catch (final NetconfDocumentedException e) { @@ -144,14 +145,12 @@ public abstract class AbstractGet extends AbstractLastNetconfOperation { return new GetConfigExecution(sourceDatastore); } - private static Datastore parseSource(final XmlElement xml) throws NetconfDocumentedException { - final Datastore sourceDatastore; - final XmlElement sourceElement = xml.getOnlyChildElement(XmlNetconfConstants.SOURCE_KEY, + private static Optional parseSource(final XmlElement xml) throws NetconfDocumentedException { + final Optional sourceElement = xml.getOnlyChildElementOptionally(XmlNetconfConstants.SOURCE_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); - final String sourceParsed = sourceElement.getOnlyChildElement().getName(); - sourceDatastore = Datastore.valueOf(sourceParsed); - return sourceDatastore; + return sourceElement.isPresent() ? + Optional.of(Datastore.valueOf(sourceElement.get().getOnlyChildElement().getName())) : Optional.absent(); } private static void validateInputRpc(final XmlElement xml, String operationName) throws NetconfDocumentedException{