List of usage examples for org.dom4j.io OutputFormat OutputFormat
public OutputFormat()
OutputFormat
with no additional whitespace (indent or new lines) added. From source file:org.sipfoundry.sipxconfig.admin.dialplan.config.XmlFile.java
License:Contributor Agreement License
/** * Overwrite to prepare XML format for this file. */// w w w . j a v a2s. c o m public OutputFormat createFormat() { OutputFormat format = new OutputFormat(); format.setNewlines(true); format.setIndent(true); return format; }
From source file:org.sipfoundry.sipxconfig.dialplan.config.AuthRules.java
License:Contributor Agreement License
@Override public Document getDocument() { Location location = getLocation(); if (location == null) { return null; }/*from ww w. jav a2 s . co m*/ try { StringWriter stringWriter = new StringWriter(); OutputFormat format = new OutputFormat(); format.setNewlines(true); format.setIndent(true); XMLWriter xmlWriter = new XMLWriter(stringWriter, format); xmlWriter.write(m_doc); String rulesString = stringWriter.toString(); rulesString = rulesString.replace("${SIPXCHANGE_DOMAIN_NAME}", getDomainName()); rulesString = rulesString.replace("${MY_IP_ADDR}", location.getAddress()); rulesString = rulesString.replace("${MY_FULL_HOSTNAME}", location.getFqdn()); rulesString = rulesString.replace("${MY_HOSTNAME}", location.getHostname()); StringReader stringReader = new StringReader(rulesString); SAXReader saxReader = new SAXReader(); return saxReader.read(stringReader); } catch (IOException ioe) { throw new RuntimeException(ioe); } catch (DocumentException de) { throw new RuntimeException(de); } }
From source file:org.sipfoundry.sipxconfig.dialplan.config.MappingRules.java
License:Contributor Agreement License
@Override protected Document getDocument() { Location location = getLocation(); if (location == null) { return m_doc; }/*w ww.j a v a 2 s. c o m*/ try { OutputFormat format = new OutputFormat(); StringWriter stringWriter = new StringWriter(); XMLWriter xmlWriter = new XMLWriter(stringWriter, format); xmlWriter.write(m_doc); String rulesString = stringWriter.toString(); rulesString = rulesString.replace(SIPXCHANGE_DOMAIN_NAME, getDomainName()); rulesString = rulesString.replace(MY_IP_ADDR, location.getAddress()); rulesString = rulesString.replace(MY_FULL_HOSTNAME, location.getFqdn()); rulesString = rulesString.replace(MY_HOSTNAME, location.getHostname()); // Not sure why these addresses cannot use dialplan interfaces Address rls = m_addressManager.getSingleAddress(Rls.TCP_SIP, location); if (rls != null) { rulesString = rulesString.replace(RLS_SIP_SRV_OR_HOSTPORT, rls.addressColonPort()); } Address park = m_addressManager.getSingleAddress(ParkOrbitContext.SIP_TCP_PORT, location); if (park != null) { rulesString = rulesString.replace(ORBIT_SERVER_SIP_SRV_OR_HOSTPORT, park.addressColonPort()); } Address page = m_addressManager.getSingleAddress(PagingContext.SIP_TCP, location); if (page != null) { rulesString = rulesString.replace("${PAGE_SERVER_ADDR}", page.getAddress()); rulesString = rulesString.replace("${PAGE_SERVER_SIP_PORT}", String.valueOf(page.getPort())); } StringReader stringReader = new StringReader(rulesString); SAXReader saxReader = new SAXReader(); return saxReader.read(stringReader); } catch (IOException ioe) { throw new RuntimeException(ioe); } catch (DocumentException de) { throw new RuntimeException(de); } }
From source file:org.sipfoundry.sipxconfig.dialplan.config.XmlFile.java
License:Contributor Agreement License
/** * Overwrite to prepare XML format for this file. */// w ww.j a v a 2 s.c o m public OutputFormat getFormat() { if (m_format != null) { return m_format; } OutputFormat format = new OutputFormat(); format.setNewlines(true); format.setIndent(true); return format; }
From source file:org.sipfoundry.sipxivr.MailboxPreferencesWriter.java
License:Contributor Agreement License
@Override public void writeObject(MailboxPreferences prefs, Writer output) { m_prefs = prefs;/*from w w w . j a va 2 s.c o m*/ OutputFormat format = new OutputFormat(); format.setNewlines(true); format.setIndent(true); XMLWriter xmlWriter = new XMLWriter(output, format); try { xmlWriter.write(getDocument()); } catch (IOException e) { LOG.error("Error writing mailboxprefs.xml", e); throw new RuntimeException(e); } }
From source file:org.sipfoundry.voicemail.mailbox.MessageDescriptorWriter.java
License:Contributor Agreement License
@Override public void writeObject(MessageDescriptor messageDescriptor, Writer output) { m_messageDescriptor = messageDescriptor; OutputFormat format = new OutputFormat(); format.setNewlines(true);/*from w ww .j av a 2 s . co m*/ format.setIndent(true); XMLWriter xmlWriter = new XMLWriter(output, format); try { xmlWriter.write(getDocument()); } catch (IOException e) { LOG.error("Error writing MessageDescriptor to " + output.toString(), e); throw new RuntimeException(e); } }
From source file:org.snipsnap.jsp.ContentTag.java
License:Open Source License
public int doStartTag() throws JspException { if (null != snip) { String content = snip.getXMLContent(); if (removeHtml) { Filter filter = new HtmlRemoveFilter(); content = filter.filter(content, null); if (extract) { if (content.length() > 40) { content = content.substring(0, 40); int ampIndex = content.lastIndexOf("&"); int colonIndex = content.lastIndexOf(";"); // did we cut a entity like &x1212; ? if (ampIndex > colonIndex) { content = content.substring(0, ampIndex - 1); }//from w w w .j a v a 2s. com content = content + " ..."; } } } if (encodeHtml) { StringWriter stringWriter = new StringWriter(); try { OutputFormat outputFormat = new OutputFormat(); outputFormat.setNewlines(true); XMLWriter xmlWriter = new XMLWriter(stringWriter, outputFormat); xmlWriter.write(content); xmlWriter.flush(); } catch (IOException e) { Logger.warn("ContentTag: unable to write encoded content: " + e); } content = stringWriter.toString(); } try { JspWriter out = pageContext.getOut(); out.print(content); } catch (IOException e) { Logger.warn("doStartTag in ContentTag", e); } } return super.doStartTag(); }
From source file:org.snipsnap.snip.storage.XMLFileSnipStorage.java
License:Open Source License
protected void storeSnip(snipsnap.api.snip.Snip snip, OutputStream out) { Document snipDocument = DocumentHelper.createDocument(); snipDocument.add(serializer.serialize(snip)); try {/* w w w . jav a 2s . co m*/ OutputFormat outputFormat = new OutputFormat(); outputFormat.setEncoding("UTF-8"); XMLWriter xmlWriter = new XMLWriter(out, outputFormat); xmlWriter.write(snipDocument); xmlWriter.flush(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.snipsnap.snip.XMLSnipExport.java
License:Open Source License
public static void store(OutputStream out, List snips, List users, String filter, List ignoreElements, File fileStore) {/*from w w w.j a va2 s .co m*/ try { OutputFormat outputFormat = new OutputFormat(); outputFormat.setEncoding("UTF-8"); outputFormat.setNewlines(true); XMLWriter xmlWriter = new XMLWriter(out, outputFormat); Element root = DocumentHelper.createElement("snipspace"); xmlWriter.writeOpen(root); storeUsers(xmlWriter, users); storeSnips(xmlWriter, snips, filter, ignoreElements, fileStore); xmlWriter.writeClose(root); xmlWriter.flush(); } catch (Exception e) { e.printStackTrace(); } }
From source file:org.snipsnap.util.JDBCDatabaseExport.java
License:Open Source License
/** * Store snips and users from the SnipSpace to an xml document into a stream. * @param out outputstream to write to/*w w w . j a v a 2 s. c o m*/ */ public static void store(OutputStream out, String appOid, Connection connection) { try { OutputFormat outputFormat = new OutputFormat(); outputFormat.setEncoding("UTF-8"); outputFormat.setNewlines(true); XMLWriter xmlWriter = new XMLWriter(out, outputFormat); xmlWriter.startDocument(); Element root = DocumentHelper.createElement("snipspace"); xmlWriter.writeOpen(root); // storeUsers(xmlWriter, connection); storeSnips(xmlWriter, appOid, connection); xmlWriter.writeClose(root); xmlWriter.endDocument(); xmlWriter.flush(); xmlWriter.close(); } catch (Exception e) { System.err.println("JDBCDatabaseExport: error while writing document: " + e.getMessage()); } }