use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class SimpleJdbcListener method getRawMessage.
protected Object getRawMessage(Connection conn, Map threadContext) throws ListenerException {
String query = getSelectQuery();
try {
Statement stmt = null;
try {
stmt = conn.createStatement();
stmt.setFetchSize(1);
ResultSet rs = null;
try {
if (trace && log.isDebugEnabled())
log.debug("executing query for [" + query + "]");
rs = stmt.executeQuery(query);
if (!rs.next()) {
return null;
}
int count = rs.getInt(1);
if (count == 0) {
return null;
}
return "<count>" + count + "</count>";
} finally {
if (rs != null) {
rs.close();
}
}
} finally {
if (stmt != null) {
stmt.close();
}
}
} catch (Exception e) {
throw new ListenerException(getLogPrefix() + "caught exception retrieving message using query [" + query + "]", e);
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class DirectoryListener method archiveFile.
/**
* Moves a file to another directory and places a UUID in the name.
* @return String with the name of the (renamed and moved) file
*/
protected String archiveFile(IPipeLineSession session, File file) throws ListenerException {
// Move file to new directory
String newFilename = null;
try {
File rename2 = new File(getOutputDirectory(), FileUtils.getFilename(null, session, file, getOutputFilenamePattern()));
newFilename = FileUtils.moveFile(file, rename2, isOverwrite(), getNumberOfBackups(), getNumberOfAttempts(), getWaitBeforeRetry());
if (newFilename == null) {
throw new ListenerException(getName() + " was unable to rename file [" + file.getAbsolutePath() + "] to [" + getOutputDirectory() + "]");
}
if (passWithoutDirectory) {
File newFile = new File(newFilename);
newFilename = newFile.getName();
}
return newFilename;
} catch (Exception e) {
throw new ListenerException(getName() + " was unable to rename file [" + file.getAbsolutePath() + "] to [" + getOutputDirectory() + "]", e);
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class DirectoryListener method afterMessageProcessed.
public void afterMessageProcessed(PipeLineResult processResult, Object rawMessage, Map context) throws ListenerException {
if (isDelete() || StringUtils.isNotEmpty(getProcessedDirectory())) {
if (getFileList() != null) {
try {
XmlUtils.parseXml(new AfterMessageProcessedHandler(), (String) rawMessage);
} catch (Exception e) {
throw new ListenerException("Could not move files [" + rawMessage + "]", e);
}
} else {
String filename = getStringFromRawMessage(rawMessage, context);
moveFileAfterProcessing(filename);
}
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class ExchangeMailListener method getStringFromRawMessage.
public String getStringFromRawMessage(Object rawMessage, Map threadContext) throws ListenerException {
Item item = (Item) rawMessage;
try {
XmlBuilder emailXml = new XmlBuilder("email");
EmailMessage emailMessage;
PropertySet ps;
if (isSimple()) {
ps = new PropertySet(EmailMessageSchema.Subject);
emailMessage = EmailMessage.bind(exchangeService, item.getId(), ps);
addEmailInfoSimple(emailMessage, emailXml);
} else {
ps = new PropertySet(EmailMessageSchema.DateTimeReceived, EmailMessageSchema.From, EmailMessageSchema.Subject, EmailMessageSchema.Body, EmailMessageSchema.DateTimeSent);
emailMessage = EmailMessage.bind(exchangeService, item.getId(), ps);
addEmailInfo(emailMessage, emailXml);
}
if (StringUtils.isNotEmpty(getStoreEmailAsStreamInSessionKey())) {
emailMessage.load(new PropertySet(ItemSchema.MimeContent));
MimeContent mc = emailMessage.getMimeContent();
ByteArrayInputStream bis = new ByteArrayInputStream(mc.getContent());
threadContext.put(getStoreEmailAsStreamInSessionKey(), bis);
}
return emailXml.toXML();
} catch (Exception e) {
throw new ListenerException(e);
}
}
use of nl.nn.adapterframework.core.ListenerException in project iaf by ibissource.
the class ExchangeMailListener method getRawMessage.
public Object getRawMessage(Map threadContext) throws ListenerException {
try {
ItemView view = new ItemView(1);
view.getOrderBy().add(ItemSchema.DateTimeReceived, SortDirection.Ascending);
FindItemsResults<Item> findResults;
if ("NDR".equalsIgnoreCase(getFilter())) {
SearchFilter searchFilterBounce = new SearchFilter.IsEqualTo(ItemSchema.ItemClass, "REPORT.IPM.Note.NDR");
findResults = exchangeService.findItems(folderIn.getId(), searchFilterBounce, view);
} else {
findResults = exchangeService.findItems(folderIn.getId(), view);
}
if (findResults.getTotalCount() == 0) {
return null;
} else {
return findResults.getItems().get(0);
}
} catch (Exception e) {
throw new ListenerException(e);
}
}
Aggregations