use of nl.nn.adapterframework.xml.PrettyPrintFilter in project iaf by ibissource.
the class MessageOutputStream method captureBinaryStream.
@SuppressWarnings("resource")
public void captureBinaryStream(OutputStream outputStream, int maxSize) {
log.debug("creating capture of " + ClassUtils.nameOf(requestStream));
closeOnClose(outputStream);
if (requestStream instanceof OutputStream) {
requestStream = StreamUtil.captureOutputStream((OutputStream) requestStream, outputStream, maxSize);
return;
}
if (requestStream instanceof ContentHandler) {
requestStream = new XmlTee((ContentHandler) requestStream, new PrettyPrintFilter(new XmlWriter(StreamUtil.limitSize(outputStream, maxSize))));
return;
}
if (requestStream instanceof JsonEventHandler) {
requestStream = new JsonTee((JsonEventHandler) requestStream, new JsonWriter(StreamUtil.limitSize(outputStream, maxSize)));
return;
}
if (requestStream instanceof Writer) {
requestStream = StreamUtil.captureWriter((Writer) requestStream, new OutputStreamWriter(outputStream, StreamUtil.DEFAULT_CHARSET), maxSize);
return;
}
log.warn("captureBinaryStream() called before stream is installed.");
}
use of nl.nn.adapterframework.xml.PrettyPrintFilter in project iaf by ibissource.
the class MessageOutputStream method captureCharacterStream.
@SuppressWarnings("resource")
public void captureCharacterStream(Writer writer, int maxSize) {
log.debug("creating capture of " + ClassUtils.nameOf(requestStream));
closeOnClose(writer);
if (requestStream instanceof Writer) {
requestStream = StreamUtil.captureWriter((Writer) requestStream, writer, maxSize);
return;
}
if (requestStream instanceof ContentHandler) {
requestStream = new XmlTee((ContentHandler) requestStream, new PrettyPrintFilter(new XmlWriter(StreamUtil.limitSize(writer, maxSize))));
return;
}
if (requestStream instanceof JsonEventHandler) {
requestStream = new JsonTee((JsonEventHandler) requestStream, new JsonWriter(StreamUtil.limitSize(writer, maxSize)));
return;
}
if (requestStream instanceof OutputStream) {
requestStream = StreamUtil.captureOutputStream((OutputStream) requestStream, new WriterOutputStream(writer, StreamUtil.DEFAULT_CHARSET), maxSize);
return;
}
log.warn("captureCharacterStream() called before stream is installed.");
}
use of nl.nn.adapterframework.xml.PrettyPrintFilter in project iaf by ibissource.
the class XmlBuilder method toXML.
public String toXML(boolean xmlHeader) {
XmlWriter writer = new XmlWriter();
PrettyPrintFilter ppf = new PrettyPrintFilter(writer);
try {
toXML(ppf);
} catch (SAXException | IOException e) {
log.warn("cannot write XML", e);
return e.getMessage();
}
return writer.toString();
}
use of nl.nn.adapterframework.xml.PrettyPrintFilter in project iaf by ibissource.
the class MatchUtils method xmlPretty.
public static String xmlPretty(String xml, boolean removeNamespaces) {
XmlWriter xmlWriter = new XmlWriter();
xmlWriter.setIncludeComments(false);
ContentHandler contentHandler = new PrettyPrintFilter(xmlWriter);
if (removeNamespaces) {
contentHandler = new NamespaceRemovingFilter(contentHandler);
}
try {
XmlUtils.parseXml(xml, contentHandler);
return xmlWriter.toString();
} catch (IOException | SAXException e) {
throw new RuntimeException("ERROR: could not prettify [" + xml + "]", e);
}
}
use of nl.nn.adapterframework.xml.PrettyPrintFilter in project iaf by ibissource.
the class ConfigurationDigester method parseAndResolveEntitiesAndProperties.
/**
* Performs an Identity-transform, which resolves entities with content from files found on the ClassPath.
* Resolve all non-attribute properties
*/
public void parseAndResolveEntitiesAndProperties(ContentHandler digester, Configuration configuration, Resource resource, Properties appConstants) throws IOException, SAXException, TransformerConfigurationException {
ContentHandler handler;
XmlWriter loadedHiddenWriter = new XmlWriter();
handler = new PrettyPrintFilter(loadedHiddenWriter);
handler = new AttributePropertyResolver(handler, appConstants, getPropsToHide(appConstants));
handler = new XmlTee(digester, handler);
handler = getStub4TesttoolContentHandler(handler, appConstants);
handler = getConfigurationCanonicalizer(handler);
handler = new OnlyActiveFilter(handler, appConstants);
handler = new ElementPropertyResolver(handler, appConstants);
XmlWriter originalConfigWriter = new XmlWriter();
handler = new XmlTee(handler, originalConfigWriter);
XmlUtils.parseXml(resource, handler);
configuration.setOriginalConfiguration(originalConfigWriter.toString());
configuration.setLoadedConfiguration(loadedHiddenWriter.toString());
}
Aggregations