use of com.adaptris.interlok.InterlokException in project interlok by adaptris.
the class FilesystemRetryStore method buildForRetry.
@Override
public AdaptrisMessage buildForRetry(String msgId, Map<String, String> metadata, AdaptrisMessageFactory msgFac) throws InterlokException {
try {
File dir = validateMsgId(msgId, true);
File payloadFile = FsWorker.isFile(FsWorker.checkReadable(new File(dir, PAYLOAD_FILE_NAME)));
AdaptrisMessage msg = DefaultMessageFactory.defaultIfNull(msgFac).newMessage();
if (msg instanceof FileBackedMessage) {
((FileBackedMessage) msg).initialiseFrom(payloadFile);
} else {
try (InputStream in = new FileInputStream(payloadFile);
OutputStream out = msg.getOutputStream()) {
IOUtils.copy(in, out);
}
}
msg.setMessageHeaders(metadata);
msg.setUniqueId(msgId);
return msg;
} catch (Exception e) {
throw ExceptionHelper.wrapInterlokException(e);
}
}
Aggregations