Search in sources :

Example 16 with Message

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);
}
Also used : MailMessage(com.aspose.email.MailMessage) Message(nl.nn.adapterframework.stream.Message)

Example 17 with Message

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;
}
Also used : Message(nl.nn.adapterframework.stream.Message) IOException(java.io.IOException)

Example 18 with Message

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);
    }
}
Also used : ParameterValueList(nl.nn.adapterframework.parameters.ParameterValueList) Message(nl.nn.adapterframework.stream.Message) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ParameterException(nl.nn.adapterframework.core.ParameterException) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException)

Example 19 with Message

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);
        }
    }
}
Also used : StringWriter(java.io.StringWriter) Message(nl.nn.adapterframework.stream.Message)

Example 20 with Message

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"));
}
Also used : Message(nl.nn.adapterframework.stream.Message) Test(org.junit.Test)

Aggregations

Message (nl.nn.adapterframework.stream.Message)598 Test (org.junit.Test)385 PipeLineSession (nl.nn.adapterframework.core.PipeLineSession)220 PipeRunResult (nl.nn.adapterframework.core.PipeRunResult)114 IOException (java.io.IOException)112 SenderException (nl.nn.adapterframework.core.SenderException)97 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)54 ParameterValueList (nl.nn.adapterframework.parameters.ParameterValueList)54 Parameter (nl.nn.adapterframework.parameters.Parameter)52 PipeForward (nl.nn.adapterframework.core.PipeForward)41 Date (java.util.Date)37 TimeoutException (nl.nn.adapterframework.core.TimeoutException)31 UrlMessage (nl.nn.adapterframework.stream.UrlMessage)31 PipeRunException (nl.nn.adapterframework.core.PipeRunException)30 ByteArrayInputStream (java.io.ByteArrayInputStream)29 InputStream (java.io.InputStream)29 ParameterList (nl.nn.adapterframework.parameters.ParameterList)28 ListenerException (nl.nn.adapterframework.core.ListenerException)27 ParameterException (nl.nn.adapterframework.core.ParameterException)25 SAXException (org.xml.sax.SAXException)19