X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fconfig-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fconfignetconfconnector%2Foperations%2FDiscardChanges.java;h=96a43b104d7d58a687f68744f79f6536b669f468;hp=639d4dac726d4d156659739bb5addaf54578d0ce;hb=31b7a44c89d1057489338492fcf62a64147bea24;hpb=b23703bef6c3aaafe2dc83608a03b738ad42f945 diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/DiscardChanges.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/DiscardChanges.java index 639d4dac72..96a43b104d 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/DiscardChanges.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/DiscardChanges.java @@ -6,11 +6,9 @@ * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.netconf.confignetconfconnector.operations; - -import java.util.HashMap; -import java.util.Map; + package org.opendaylight.controller.netconf.confignetconfconnector.operations; +import com.google.common.base.Optional; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity; @@ -25,7 +23,9 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import com.google.common.base.Optional; +import java.util.HashMap; +import java.util.Map; + public class DiscardChanges extends AbstractConfigNetconfOperation { @@ -41,7 +41,7 @@ public class DiscardChanges extends AbstractConfigNetconfOperation { this.transactionProvider = transactionProvider; } - private static void fromXml(XmlElement xml) { + private static void fromXml(XmlElement xml) throws NetconfDocumentedException { xml.checkName(DISCARD); xml.checkNamespace(XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); } @@ -53,21 +53,10 @@ public class DiscardChanges extends AbstractConfigNetconfOperation { @Override protected Element handleWithNoSubsequentOperations(Document document, XmlElement xml) throws NetconfDocumentedException { - try { - fromXml(xml); - } catch (final IllegalArgumentException e) { - //FIXME where can IllegalStateException be thrown? - logger.warn("Rpc error: {}", ErrorTag.bad_attribute, 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); - } - + fromXml(xml); try { this.transactionProvider.abortTransaction(); } catch (final IllegalStateException e) { - //FIXME where can IllegalStateException be thrown? logger.warn("Abort failed: ", e); final Map errorInfo = new HashMap<>(); errorInfo @@ -78,6 +67,7 @@ public class DiscardChanges extends AbstractConfigNetconfOperation { } logger.trace("Changes discarded successfully from datastore {}", Datastore.candidate); + return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent()); } }