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();
}
}
}
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();
}
}
}
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);
}
}
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));
}
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());
}
Aggregations