X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Futil%2FNetconfUtil.java;h=9443f93f920f9720e13908c6319a139f4be0f6b0;hb=e159106bc148e76fc1e3e3c780bdd740d99e74ed;hp=b0884ca2fb4bc648183841241967660c3f9fc9f3;hpb=749b52034c030428135f49f65a96c4da13f1277c;p=controller.git diff --git a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/NetconfUtil.java b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/NetconfUtil.java index b0884ca2fb..9443f93f92 100644 --- a/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/NetconfUtil.java +++ b/opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/NetconfUtil.java @@ -8,9 +8,8 @@ package org.opendaylight.controller.netconf.util; import com.google.common.base.Preconditions; -import org.opendaylight.controller.config.api.ConflictingVersionException; +import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; -import org.opendaylight.controller.netconf.util.xml.XMLNetconfUtil; import org.opendaylight.controller.netconf.util.xml.XmlElement; import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlUtil; @@ -19,8 +18,6 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.xml.sax.SAXException; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -56,31 +53,13 @@ public final class NetconfUtil { return (doc == null) ? null : new NetconfMessage(doc); } - public static Document checkIsMessageOk(NetconfMessage responseMessage) throws ConflictingVersionException { - return checkIsMessageOk(responseMessage.getDocument()); - } - - public static Document checkIsMessageOk(Document response) throws ConflictingVersionException { + public static Document checkIsMessageOk(Document response) throws NetconfDocumentedException { XmlElement element = XmlElement.fromDomDocument(response); Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY)); element = element.getOnlyChildElement(); - if (element.getName().equals(XmlNetconfConstants.OK)) { return response; } - - if (element.getName().equals(XmlNetconfConstants.RPC_ERROR)) { - logger.warn("Can not load last configuration, operation failed"); - // is it ConflictingVersionException ? - XPathExpression xPathExpression = XMLNetconfUtil.compileXPath("/netconf:rpc-reply/netconf:rpc-error/netconf:error-info/netconf:error"); - String error = (String) XmlUtil.evaluateXPath(xPathExpression, element.getDomElement(), XPathConstants.STRING); - if (error!=null && error.contains(ConflictingVersionException.class.getCanonicalName())) { - throw new ConflictingVersionException(error); - } - throw new IllegalStateException("Can not load last configuration, operation failed: " - + XmlUtil.toString(response)); - } - logger.warn("Can not load last configuration. Operation failed."); throw new IllegalStateException("Can not load last configuration. Operation failed: " + XmlUtil.toString(response));