use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class MailConvertor method convertAttachmentInPdf.
/**
* Converts an email attachment to a pdf via the cisConversionService.
*/
private CisConversionResult convertAttachmentInPdf(Attachment attachment, ConversionOption conversionOption) throws IOException {
LOGGER.debug("Convert attachment... (" + attachment.getName() + ")");
// Get the name of the file (segment) (this is the last part.
String[] segments = attachment.getName().split("/");
String segmentFilename = segments[segments.length - 1];
return cisConversionService.convertToPdf(new Message(attachment.getContentStream()), segmentFilename, conversionOption);
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class NetStorageSender method getResponseBodyAsString.
/**
* When an exception occurs and the response cannot be parsed, we do not want to throw a 'missing response' exception.
* Since this method is used when handling exceptions, silently return null, to avoid NPE's and IOExceptions
*/
public String getResponseBodyAsString(HttpResponseHandler responseHandler, boolean throwIOExceptionWhenParsingResponse) throws IOException {
String charset = responseHandler.getCharset();
if (log.isDebugEnabled())
log.debug(getLogPrefix() + "response body uses charset [" + charset + "]");
Message response = responseHandler.getResponseMessage();
String responseBody = null;
try {
responseBody = response.asString();
} catch (IOException e) {
if (throwIOExceptionWhenParsingResponse) {
throw e;
}
return null;
}
int rbLength = responseBody.length();
long rbSizeWarn = Misc.getResponseBodySizeWarnByDefault();
if (rbLength >= rbSizeWarn) {
log.warn(getLogPrefix() + "retrieved result size [" + Misc.toFileSize(rbLength) + "] exceeds [" + Misc.toFileSize(rbSizeWarn) + "]");
}
return responseBody;
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class ZipWriterSender method sendMessage.
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
ParameterValueList pvl;
try {
pvl = paramList.getValues(message, session);
} catch (ParameterException e) {
throw new SenderException("cannot determine filename and/or contents of zip entry", e);
}
ZipWriter sessionData = ZipWriter.getZipWriter(session, getZipWriterHandle());
if (sessionData == null) {
throw new SenderException("zipWriterHandle in session key [" + getZipWriterHandle() + "] is not open");
}
try {
String filename = filenameParameter == null ? message.asString() : (String) pvl.getParameterValue(PARAMETER_FILENAME).getValue();
if (contentsParameter == null) {
if (message != null) {
sessionData.writeEntry(filename, message, isCloseInputstreamOnExit(), getCharset());
}
} else {
Message paramValue = Message.asMessage(pvl.getParameterValue(PARAMETER_CONTENTS).getValue());
sessionData.writeEntry(filename, paramValue, isCloseInputstreamOnExit(), getCharset());
}
return message;
} catch (UnsupportedEncodingException e) {
throw new SenderException(getLogPrefix() + "cannot encode zip entry", e);
} catch (CompressionException e) {
throw new SenderException(getLogPrefix() + "cannot store zip entry", e);
} catch (IOException e) {
throw new SenderException(getLogPrefix() + "cannot store zip entry", e);
}
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class ResultBlock2Sender method closeBlock.
@Override
public void closeBlock(PipeLineSession session, String streamId, String blockName) throws Exception {
super.closeBlock(session, streamId, blockName);
int level = decLevel(streamId);
if (level == 0) {
StringWriter writer = (StringWriter) getWriter(session, streamId, false);
if (writer != null) {
Message message = new Message(writer.getBuffer().toString());
log.debug("sending block [" + message + "] to sender [" + sender.getName() + "]");
writer.getBuffer().setLength(0);
/*
* This used to be:
* getSender().sendMessage(streamId+"-"+incCounter(streamId),message, session);
* Be aware that 'correlationId' no longer reflects streamId and counter
*/
getSender().sendMessage(message, session);
}
}
}
use of nl.nn.adapterframework.stream.Message in project iaf by ibissource.
the class CmisDeleteAction method deleteObject.
@Test
public void deleteObject() throws Exception {
sender.setBindingType("browser");
sender.setAction("delete");
sender.configure();
Message result = sendMessage(ALLOWED_SELECTOR);
assertThat(result.asString(), Matchers.startsWith("testmessage"));
}
Aggregations