X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fimpl%2Fmapping%2Foperations%2FDefaultCommit.java;h=d6940a1a453fcaaf14f4e6e30292f8dbc427256d;hp=1a9f5d7393ad469f5e1c8d1cc0862589e65fe185;hb=6dae254dbc2940d1f0f372d65d69b0e0dda415fe;hpb=7787fed520d06122c9b9d80934b73c7e77d44112 diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java index 1a9f5d7393..d6940a1a45 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultCommit.java @@ -8,9 +8,7 @@ package org.opendaylight.controller.netconf.impl.mapping.operations; -import java.io.InputStream; -import java.util.Map; - +import com.google.common.base.Preconditions; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouter; import org.opendaylight.controller.netconf.impl.DefaultCommitNotificationProducer; @@ -26,8 +24,7 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import com.google.common.base.Preconditions; -import com.google.common.collect.Maps; +import java.io.InputStream; public class DefaultCommit extends AbstractNetconfOperation { @@ -100,8 +97,14 @@ public class DefaultCommit extends AbstractNetconfOperation { } private boolean isCommitWithoutNotification(Document message) { - XmlElement xmlElement = XmlElement.fromDomElementWithExpected(message.getDocumentElement(), - XmlNetconfConstants.RPC_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); + XmlElement xmlElement = null; + try { + xmlElement = XmlElement.fromDomElementWithExpected(message.getDocumentElement(), + XmlNetconfConstants.RPC_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); + } catch (NetconfDocumentedException e) { + logger.trace("Commit operation is not valid due to {}",e); + return false; + } String attr = xmlElement.getAttribute(NOTIFY_ATTR); @@ -120,20 +123,9 @@ public class DefaultCommit extends AbstractNetconfOperation { getConfigMessage, null); XmlElement dataElement; - try { - XmlElement xmlElement = XmlElement.fromDomElementWithExpected(responseDocument.getDocumentElement(), - XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); - dataElement = xmlElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY); - } catch (IllegalArgumentException e) { - final String msg = "Unexpected response from get-config operation"; - logger.warn(msg, e); - Map info = Maps.newHashMap(); - info.put(NetconfDocumentedException.ErrorTag.operation_failed.toString(), e.getMessage()); - throw new NetconfDocumentedException(msg, e, NetconfDocumentedException.ErrorType.application, - NetconfDocumentedException.ErrorTag.operation_failed, - NetconfDocumentedException.ErrorSeverity.error, info); - } - + XmlElement xmlElement = XmlElement.fromDomElementWithExpected(responseDocument.getDocumentElement(), + XmlNetconfConstants.RPC_REPLY_KEY, XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0); + dataElement = xmlElement.getOnlyChildElement(XmlNetconfConstants.DATA_KEY); return dataElement.getDomElement(); }