/** * Parse a byte[] containing SiteWhere XML configuration for JSON * representation. * * @param config * @return * @throws SiteWhereException */ public static ElementContent parse(byte[] config) throws SiteWhereException { try { DocumentBuilderFactory factory = DataUtils.getDocumentBuilderFactory(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(new InputSource(new ByteArrayInputStream(config))); Element element = document.getDocumentElement(); ElementContent content = parse(element); return content; } catch (Exception e) { throw new SiteWhereException("Unable to parse configuration content.", e); } }
/** * Parse a byte[] containing SiteWhere XML configuration for JSON * representation. * * @param config * @param configurationModel * @return * @throws SiteWhereException */ public static ElementContent parse(byte[] config, IConfigurationModel configurationModel) throws SiteWhereException { try { DocumentBuilderFactory factory = DataUtils.getDocumentBuilderFactory(); DocumentBuilder builder = factory.newDocumentBuilder(); Document document = builder.parse(new InputSource(new ByteArrayInputStream(config))); Element element = document.getDocumentElement(); ElementContent content = parse(element, configurationModel); return content; } catch (Exception e) { throw new SiteWhereException("Unable to parse configuration content.", e); } }