1 package org.opendaylight.controller.netconf.impl.util;
5 import org.opendaylight.controller.netconf.api.NetconfMessage;
6 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory;
9 import org.w3c.dom.Document;
10 import org.xml.sax.SAXException;
13 public class NetconfUtil {
15 private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class);
17 public static NetconfMessage createMessage(final File f) {
19 return createMessage(new FileInputStream(f));
20 } catch (final FileNotFoundException e) {
21 logger.warn("File {} not found.", f, e);
26 public static NetconfMessage createMessage(final InputStream is) {
29 doc = XmlUtil.readXmlToDocument(is);
30 } catch (final IOException e) {
31 logger.warn("Error ocurred while parsing stream.", e);
32 } catch (final SAXException e) {
33 logger.warn("Error ocurred while final parsing stream.", e);
35 return (doc == null) ? null : new NetconfMessage(doc);