1 package org.opendaylight.controller.netconf.impl.util;
4 import java.io.FileInputStream;
5 import java.io.FileNotFoundException;
6 import java.io.IOException;
7 import java.io.InputStream;
9 import org.opendaylight.controller.netconf.api.NetconfMessage;
10 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13 import org.w3c.dom.Document;
14 import org.xml.sax.SAXException;
17 public class NetconfUtil {
19 private static final Logger logger = LoggerFactory.getLogger(NetconfUtil.class);
21 public static NetconfMessage createMessage(final File f) {
23 return createMessage(new FileInputStream(f));
24 } catch (final FileNotFoundException e) {
25 logger.warn("File {} not found.", f, e);
30 public static NetconfMessage createMessage(final InputStream is) {
33 doc = XmlUtil.readXmlToDocument(is);
34 } catch (final IOException e) {
35 logger.warn("Error ocurred while parsing stream.", e);
36 } catch (final SAXException e) {
37 logger.warn("Error ocurred while final parsing stream.", e);
39 return (doc == null) ? null : new NetconfMessage(doc);