/** * Write */ public void writeTo(OutputStream headerOs, OutputStream bodyOs) throws IOException, MessagingException { writeTo(headerOs, bodyOs, new String[0]); }
/** * Rewritten for optimization purposes */ public void writeTo(OutputStream os, String[] ignoreList) throws IOException, MessagingException { writeTo(os, os, ignoreList); }
/** * Rewritten for optimization purposes */ public synchronized void writeTo(OutputStream os) throws IOException, MessagingException { if (source != null && !isModified()) { // We do not want to instantiate the message... just read from source // and write to this outputstream InputStream in = source.getInputStream(); try { IOUtils.copy(in, os); } finally { IOUtils.closeQuietly(in); } } else { writeTo(os, os); } }
/** * Convenience method to take any MimeMessage and write the headers and body to two * different output streams, with an ignore list * * @param message the MimeMessage reading from * @param headerOs the OutputStream writting the headers to * @param bodyOs the OutputStream writting the body to * @param ignoreList the String[] which contains headers which should be ignored * @throws IOException get thrown if an IO Error detected while writing to the streams * @throws MessagingException get thrown if an error detected while reading the message */ public static void writeTo(MimeMessage message, OutputStream headerOs, OutputStream bodyOs, String[] ignoreList) throws IOException, MessagingException { MimeMessage testMessage = message; if (message instanceof MimeMessageCopyOnWriteProxy) { MimeMessageCopyOnWriteProxy wr = (MimeMessageCopyOnWriteProxy) message; testMessage = wr.getWrappedMessage(); } if (testMessage instanceof MimeMessageWrapper) { MimeMessageWrapper wrapper = (MimeMessageWrapper)testMessage; if (!wrapper.isModified()) { wrapper.writeTo(headerOs, bodyOs, ignoreList); return; } } writeToInternal(message, headerOs, bodyOs, ignoreList); }
out = streamRepository.put(key); ((MimeMessageWrapper) message).writeTo(out, out, null, true);