Search in sources :

Example 1 with IDocumentBuilder

use of nl.nn.adapterframework.stream.document.IDocumentBuilder in project iaf by ibissource.

the class MongoDbSender method renderResult.

protected void renderResult(Document findResult, MessageOutputStream target) throws StreamingException {
    try (IDocumentBuilder builder = DocumentBuilderFactory.startDocument(getOutputFormat(), "FindOneResult", target)) {
        JsonWriterSettings writerSettings = JsonWriterSettings.builder().outputMode(JsonMode.RELAXED).build();
        Encoder<Document> encoder = new DocumentCodec();
        JsonDocumentWriter jsonWriter = new JsonDocumentWriter(builder, writerSettings);
        encoder.encode(jsonWriter, findResult, EncoderContext.builder().build());
    } catch (Exception e) {
        throw new StreamingException("Could not render collection", e);
    }
}
Also used : StreamingException(nl.nn.adapterframework.stream.StreamingException) DocumentCodec(org.bson.codecs.DocumentCodec) JsonWriterSettings(org.bson.json.JsonWriterSettings) IDocumentBuilder(nl.nn.adapterframework.stream.document.IDocumentBuilder) Document(org.bson.Document) NamingException(javax.naming.NamingException) TimeoutException(nl.nn.adapterframework.core.TimeoutException) StreamingException(nl.nn.adapterframework.stream.StreamingException) SAXException(org.xml.sax.SAXException) SenderException(nl.nn.adapterframework.core.SenderException) IOException(java.io.IOException) ConfigurationException(nl.nn.adapterframework.configuration.ConfigurationException) ParameterException(nl.nn.adapterframework.core.ParameterException)

Aggregations

IOException (java.io.IOException)1 NamingException (javax.naming.NamingException)1 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)1 ParameterException (nl.nn.adapterframework.core.ParameterException)1 SenderException (nl.nn.adapterframework.core.SenderException)1 TimeoutException (nl.nn.adapterframework.core.TimeoutException)1 StreamingException (nl.nn.adapterframework.stream.StreamingException)1 IDocumentBuilder (nl.nn.adapterframework.stream.document.IDocumentBuilder)1 Document (org.bson.Document)1 DocumentCodec (org.bson.codecs.DocumentCodec)1 JsonWriterSettings (org.bson.json.JsonWriterSettings)1 SAXException (org.xml.sax.SAXException)1