Search in sources :

Example 36 with Message

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

the class ScanTibcoSolutionPipe method getHtml.

private String getHtml(String urlString) throws ConfigurationException, SenderException, TimeoutException, IOException {
    HttpSender httpSender = null;
    try {
        httpSender = new HttpSender();
        httpSender.setUrl(urlString);
        httpSender.setAllowSelfSignedCertificates(true);
        httpSender.setVerifyHostname(false);
        httpSender.setIgnoreCertificateExpiredException(true);
        httpSender.setXhtml(true);
        httpSender.configure();
        httpSender.open();
        String result = httpSender.sendMessage(new Message(""), null).asString();
        return result;
    } finally {
        if (httpSender != null) {
            httpSender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) HttpSender(nl.nn.adapterframework.http.HttpSender)

Example 37 with Message

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

the class SvnUtils method getReportHtml.

private static String getReportHtml(String urlString, String revision, String path) throws ConfigurationException, SenderException, TimeoutException, IOException {
    HttpSender httpSender = null;
    try {
        httpSender = new HttpSender();
        httpSender.setUrl(urlString);
        httpSender.setAllowSelfSignedCertificates(true);
        httpSender.setVerifyHostname(false);
        httpSender.setIgnoreCertificateExpiredException(true);
        httpSender.setXhtml(true);
        httpSender.setMethodType(HttpMethod.REPORT);
        httpSender.configure();
        httpSender.open();
        String logReportRequest = "<S:log-report xmlns:S=\"svn:\">" + "<S:start-revision>" + revision + "</S:start-revision>" + "<S:end-revision>" + revision + "</S:end-revision>" + "<S:limit>1</S:limit>" + "<S:path>" + path + "</S:path>" + "</S:log-report>";
        String result = httpSender.sendMessage(new Message(logReportRequest), null).asString();
        return result;
    } finally {
        if (httpSender != null) {
            httpSender.close();
        }
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) HttpSender(nl.nn.adapterframework.http.HttpSender)

Example 38 with Message

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

the class XfbSender method sendMessage.

@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
    try {
        File file = new File(message.asString());
        if (getCopy()) {
            File fromFile = file;
            String name = fromFile.getName();
            if (name.startsWith(getCopyPrefix())) {
                name = name.substring(getCopyPrefix().length());
            } else {
                name = getCopyPrefix() + name;
            }
            File toFile = new File(fromFile.getParentFile(), name);
            file = toFile;
            if (toFile.exists()) {
                throw new SenderException("File " + toFile.getAbsolutePath() + " already exist");
            }
            if (!FileUtils.copyFile(fromFile, toFile, false)) {
                throw new SenderException("Could not copy file");
            }
        }
        String command = getScript() + " ft=" + getFt() + " flow=" + getFlow() + " appli=" + getAppli();
        if (StringUtils.isNotEmpty(getNoname())) {
            command = command + " noname=" + getNoname();
        }
        command = command + " filename=" + file.getAbsolutePath();
        String output = ProcessUtil.executeCommand(command);
        return new Message(output);
    } catch (IOException e) {
        throw new SenderException(getLogPrefix(), e);
    }
}
Also used : Message(nl.nn.adapterframework.stream.Message) IOException(java.io.IOException) SenderException(nl.nn.adapterframework.core.SenderException) File(java.io.File)

Example 39 with Message

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

the class FtpFileSystem method readFile.

@Override
public Message readFile(FTPFile f, String charset) throws FileSystemException, IOException {
    InputStream inputStream = ftpClient.retrieveFileStream(f.getName());
    ftpClient.completePendingCommand();
    return new Message(inputStream, FileSystemUtils.getContext(this, f, charset));
}
Also used : Message(nl.nn.adapterframework.stream.Message) InputStream(java.io.InputStream)

Example 40 with Message

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

the class MailListener method extractMessage.

@Override
public Message extractMessage(M rawMessage, Map<String, Object> threadContext) throws ListenerException {
    if (MIME_MESSAGE_TYPE.equals(getMessageType())) {
        try {
            return getFileSystem().getMimeContent(rawMessage);
        } catch (FileSystemException e) {
            throw new ListenerException("cannot get MimeContents", e);
        }
    }
    if (!EMAIL_MESSAGE_TYPE.equals(getMessageType())) {
        return super.extractMessage(rawMessage, threadContext);
    }
    XmlWriter writer = new XmlWriter();
    try (SaxElementBuilder emailXml = new SaxElementBuilder("email", writer)) {
        if (isSimple()) {
            MailFileSystemUtils.addEmailInfoSimple(getFileSystem(), rawMessage, emailXml);
        } else {
            getFileSystem().extractEmail(rawMessage, emailXml);
        }
        if (StringUtils.isNotEmpty(getStoreEmailAsStreamInSessionKey())) {
            Message mimeContent = getFileSystem().getMimeContent(rawMessage);
            threadContext.put(getStoreEmailAsStreamInSessionKey(), mimeContent.asInputStream());
        }
    } catch (SAXException | IOException | FileSystemException e) {
        throw new ListenerException(e);
    }
    return new Message(writer.toString());
}
Also used : ListenerException(nl.nn.adapterframework.core.ListenerException) Message(nl.nn.adapterframework.stream.Message) SaxElementBuilder(nl.nn.adapterframework.xml.SaxElementBuilder) IOException(java.io.IOException) XmlWriter(nl.nn.adapterframework.xml.XmlWriter) SAXException(org.xml.sax.SAXException)

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