use of nl.nn.adapterframework.stream.StreamingException 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);
}
}
use of nl.nn.adapterframework.stream.StreamingException in project iaf by ibissource.
the class ForEachChildElementPipe method provideOutputStream.
@Override
protected MessageOutputStream provideOutputStream(PipeLineSession session) throws StreamingException {
HandlerRecord handlerRecord = new HandlerRecord();
try {
ThreadConnector threadConnector = streamingXslt ? new ThreadConnector(this, threadLifeCycleEventListener, txManager, session) : null;
MessageOutputStream target = getTargetStream(session);
Writer resultWriter = target.asWriter();
ItemCallback callback = createItemCallBack(session, getSender(), resultWriter);
createHandler(handlerRecord, threadConnector, session, callback);
return new MessageOutputStream(this, handlerRecord.inputHandler, target, threadLifeCycleEventListener, txManager, session, threadConnector);
} catch (TransformerException e) {
throw new StreamingException(handlerRecord.errorMessage, e);
}
}
use of nl.nn.adapterframework.stream.StreamingException in project iaf by ibissource.
the class Base64Pipe method provideOutputStream.
@SuppressWarnings("resource")
@Override
protected MessageOutputStream provideOutputStream(PipeLineSession session) throws StreamingException {
MessageOutputStream target = getTargetStream(session);
// TRUE encode - FALSE decode
boolean directionEncode = getDirection() == Direction.ENCODE;
OutputStream targetStream;
String outputCharset = directionEncode ? StandardCharsets.US_ASCII.name() : getCharset();
if (getOutputTypeEnum() == OutputTypes.STRING) {
targetStream = new WriterOutputStream(target.asWriter(), outputCharset != null ? outputCharset : StreamUtil.DEFAULT_INPUT_STREAM_ENCODING);
} else {
targetStream = target.asStream(outputCharset);
}
OutputStream base64 = new Base64OutputStream(targetStream, directionEncode, getLineLength(), lineSeparatorArray);
if (directionEncode && StringUtils.isNotEmpty(getCharset())) {
try {
return new MessageOutputStream(this, new OutputStreamWriter(base64, getCharset()), target);
} catch (UnsupportedEncodingException e) {
throw new StreamingException("cannot open OutputStreamWriter", e);
}
}
return new MessageOutputStream(this, base64, target);
}
Aggregations