Пример #1
0
  public AttachmentHandler getAttachment(long attachmentId)
      throws IOException, PortalException, SystemException {

    Attachment attachment = AttachmentLocalServiceUtil.getAttachment(attachmentId);

    Message message = MessageLocalServiceUtil.getMessage(attachment.getMessageId());

    if (account.getDraftFolderId() == attachment.getFolderId()) {
      return new DefaultAttachmentHandler(
          AttachmentLocalServiceUtil.getInputStream(attachmentId), null);
    } else {
      return _imapAccessor.getAttachment(
          attachment.getFolderId(), message.getRemoteMessageId(), attachment.getContentPath());
    }
  }