private FetchResponse.BodyElement text(final MessageResult messageResult, String name, final int[] path, final boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; Content body; if (isBase) { try { body = messageResult.getBody(); } catch (IOException e) { throw new MailboxException("Unable to get TEXT of body", e); } } else { MessageResult.MimePath mimePath = new MimePathImpl(path); body = messageResult.getBody(mimePath); } if (body == null) { body = new EmptyContent(); } result = new ContentBodyElement(name, body); return result; }
private FetchResponse.BodyElement text(MessageResult messageResult, String name, int[] path, boolean isBase) throws MailboxException { final FetchResponse.BodyElement result; Content body; if (isBase) { try { body = messageResult.getBody(); } catch (IOException e) { throw new MailboxException("Unable to get TEXT of body", e); } } else { MessageResult.MimePath mimePath = new MimePathImpl(path); body = messageResult.getBody(mimePath); } if (body == null) { body = new EmptyContent(); } result = new ContentBodyElement(name, body); return result; }
@Override public InputStream getMessageBody(String uid) throws IOException { try { mailboxManager.startProcessingRequest(session); Iterator<MessageResult> results = manager.getMessages(MessageUid.of(Long.valueOf(uid)).toRange(), BODY_GROUP, session); if (results.hasNext()) { return results.next().getBody().getInputStream(); } else { return null; } } catch (MailboxException e) { throw new IOException("Unable to retrieve message body for uid " + uid, e); } finally { mailboxManager.endProcessingRequest(session); } }