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=5fd53dce55639e0b5c8a811e11ab4b7b2a637117;hb=3a71a222b896b9d07e638af62300180799bdac67;hp=9443f93f920f9720e13908c6319a139f4be0f6b0;hpb=d7a972ac145d9f0ac8870dac2d7835520e92c02a;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 9443f93f92..5fd53dce55 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 @@ -9,50 +9,19 @@ package org.opendaylight.controller.netconf.util; import com.google.common.base.Preconditions; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; -import org.opendaylight.controller.netconf.api.NetconfMessage; +import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlElement; -import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; -import org.xml.sax.SAXException; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; public final class NetconfUtil { - private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class); + private static final Logger LOG = LoggerFactory.getLogger(NetconfUtil.class); private NetconfUtil() {} - public static NetconfMessage createMessage(final File f) { - Preconditions.checkNotNull(f, "File parameter was null"); - try { - return createMessage(new FileInputStream(f)); - } catch (final FileNotFoundException e) { - logger.warn("File {} not found.", f, e); - } - return null; - } - - public static NetconfMessage createMessage(final InputStream is) { - Preconditions.checkNotNull(is, "InputStream parameter was null"); - Document doc = null; - try { - doc = XmlUtil.readXmlToDocument(is); - } catch (final IOException e) { - logger.warn("Error ocurred while parsing stream.", e); - } catch (final SAXException e) { - logger.warn("Error ocurred while final parsing stream.", e); - } - return (doc == null) ? null : new NetconfMessage(doc); - } - public static Document checkIsMessageOk(Document response) throws NetconfDocumentedException { XmlElement element = XmlElement.fromDomDocument(response); Preconditions.checkState(element.getName().equals(XmlNetconfConstants.RPC_REPLY_KEY)); @@ -60,7 +29,7 @@ public final class NetconfUtil { if (element.getName().equals(XmlNetconfConstants.OK)) { return response; } - logger.warn("Can not load last configuration. Operation failed."); + LOG.warn("Can not load last configuration. Operation failed."); throw new IllegalStateException("Can not load last configuration. Operation failed: " + XmlUtil.toString(response)); }