javax.mail.internet.SharedInputStream Java Examples
The following examples show how to use
javax.mail.internet.SharedInputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SimpleMailboxMessage.java From james-project with Apache License 2.0 | 6 votes |
public SimpleMailboxMessage(MessageId messageId, Date internalDate, long size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxId mailboxId, List<MessageAttachmentMetadata> attachments, boolean hasAttachment) { super(new SimpleMessage( messageId, content, size, internalDate, propertyBuilder.getSubType(), propertyBuilder.getMediaType(), bodyStartOctet, propertyBuilder.getTextualLineCount(), propertyBuilder.toProperties(), attachments, hasAttachment)); setFlags(flags); this.mailboxId = mailboxId; this.userFlags = flags.getUserFlags(); }
Example #2
Source File: MessageFullViewFactory.java From james-project with Apache License 2.0 | 6 votes |
private MetaDataWithContent(MessageUid uid, Keywords keywords, long size, Instant internalDate, InputStream content, SharedInputStream sharedContent, List<MessageAttachmentMetadata> attachments, Set<MailboxId> mailboxIds, MessageId messageId) { this.uid = uid; this.keywords = keywords; this.size = size; this.internalDate = internalDate; this.content = content; this.sharedContent = sharedContent; this.attachments = attachments; this.mailboxIds = mailboxIds; this.messageId = messageId; }
Example #3
Source File: JPAStreamingMailboxMessage.java From james-project with Apache License 2.0 | 5 votes |
public JPAStreamingMailboxMessage(JPAMailbox mailbox, Date internalDate, int size, Flags flags, SharedInputStream content, int bodyStartOctet, PropertyBuilder propertyBuilder) throws MailboxException { super(mailbox, internalDate, flags, size, bodyStartOctet, propertyBuilder); this.content = content; try { this.header = getHeaderContent(); this.body = getBodyContent(); } catch (IOException e) { throw new MailboxException("Unable to parse message",e); } }
Example #4
Source File: JPAMailboxMessage.java From james-project with Apache License 2.0 | 5 votes |
public JPAMailboxMessage(JPAMailbox mailbox, Date internalDate, int size, Flags flags, SharedInputStream content, int bodyStartOctet, PropertyBuilder propertyBuilder) throws MailboxException { super(mailbox, internalDate, flags, size, bodyStartOctet, propertyBuilder); try { int headerEnd = bodyStartOctet; if (headerEnd < 0) { headerEnd = 0; } this.header = IOUtils.toByteArray(content.newStream(0, headerEnd)); this.body = IOUtils.toByteArray(content.newStream(getBodyStartOctet(), -1)); } catch (IOException e) { throw new MailboxException("Unable to parse message",e); } }
Example #5
Source File: JPAEncryptedMailboxMessage.java From james-project with Apache License 2.0 | 5 votes |
public JPAEncryptedMailboxMessage(JPAMailbox mailbox, Date internalDate, int size, Flags flags, SharedInputStream content, int bodyStartOctet, PropertyBuilder propertyBuilder) throws MailboxException { super(mailbox, internalDate, flags, size, bodyStartOctet, propertyBuilder); try { int headerEnd = bodyStartOctet; if (headerEnd < 0) { headerEnd = 0; } this.header = IOUtils.toByteArray(content.newStream(0, headerEnd)); this.body = IOUtils.toByteArray(content.newStream(getBodyStartOctet(), -1)); } catch (IOException e) { throw new MailboxException("Unable to parse message",e); } }
Example #6
Source File: OpenJPAMessageFactory.java From james-project with Apache License 2.0 | 5 votes |
@Override public AbstractJPAMailboxMessage createMessage(MessageId messageId, Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, List<MessageAttachmentMetadata> attachments) throws MailboxException { switch (feature) { case Streaming: return new JPAStreamingMailboxMessage(JPAMailbox.from(mailbox), internalDate, size, flags, content, bodyStartOctet, propertyBuilder); case Encryption: return new JPAEncryptedMailboxMessage(JPAMailbox.from(mailbox), internalDate, size, flags, content, bodyStartOctet, propertyBuilder); default: return new JPAMailboxMessage(JPAMailbox.from(mailbox), internalDate, size, flags, content, bodyStartOctet, propertyBuilder); } }
Example #7
Source File: MessageFactory.java From james-project with Apache License 2.0 | 5 votes |
@Override public SimpleMailboxMessage createMessage(MessageId messageId, Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, List<MessageAttachmentMetadata> attachments) { return new SimpleMailboxMessage(messageId, internalDate, size, bodyStartOctet, content, flags, propertyBuilder, mailbox.getMailboxId(), attachments); }
Example #8
Source File: MessageStorer.java From james-project with Apache License 2.0 | 5 votes |
@Override public Pair<MessageMetaData, Optional<List<MessageAttachmentMetadata>>> appendMessageToStore(Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxSession session) throws MailboxException { MessageMapper messageMapper = mapperFactory.getMessageMapper(session); MessageId messageId = messageIdFactory.generate(); return mapperFactory.getMessageMapper(session).execute(() -> { List<MessageAttachmentMetadata> attachments = storeAttachments(messageId, content, session); MailboxMessage message = messageFactory.createMessage(messageId, mailbox, internalDate, size, bodyStartOctet, content, flags, propertyBuilder, attachments); MessageMetaData metadata = messageMapper.add(mailbox, message); return Pair.of(metadata, Optional.of(attachments)); }); }
Example #9
Source File: MessageStorer.java From james-project with Apache License 2.0 | 5 votes |
private List<ParsedAttachment> extractAttachments(SharedInputStream contentIn) { try { return messageParser.retrieveAttachments(contentIn.newStream(START, UNLIMITED)); } catch (Exception e) { LOGGER.warn("Error while parsing mail's attachments: {}", e.getMessage(), e); return ImmutableList.of(); } }
Example #10
Source File: MessageStorer.java From james-project with Apache License 2.0 | 5 votes |
@Override public Pair<MessageMetaData, Optional<List<MessageAttachmentMetadata>>> appendMessageToStore(Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxSession session) throws MailboxException { MessageMapper messageMapper = mapperFactory.getMessageMapper(session); MessageId messageId = messageIdFactory.generate(); return mapperFactory.getMessageMapper(session).execute(() -> { MailboxMessage message = messageFactory.createMessage(messageId, mailbox, internalDate, size, bodyStartOctet, content, flags, propertyBuilder, ImmutableList.of()); MessageMetaData metadata = messageMapper.add(mailbox, message); return Pair.of(metadata, Optional.empty()); }); }
Example #11
Source File: SimpleMailboxMessage.java From james-project with Apache License 2.0 | 5 votes |
public SimpleMailboxMessage(MessageId messageId, Date internalDate, long size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxId mailboxId, List<MessageAttachmentMetadata> attachments) { this(messageId, internalDate, size, bodyStartOctet, content, flags, propertyBuilder, mailboxId, attachments, !attachments.isEmpty()); }
Example #12
Source File: SimpleMailboxMessage.java From james-project with Apache License 2.0 | 5 votes |
public SimpleMailboxMessage(MessageId messageId, Date internalDate, long size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxId mailboxId) { this(messageId, internalDate, size, bodyStartOctet, content, flags, propertyBuilder, mailboxId, ImmutableList.of()); }
Example #13
Source File: SimpleMessage.java From james-project with Apache License 2.0 | 5 votes |
public SimpleMessage(MessageId messageId, SharedInputStream content, long size, Date internalDate, String subType, String mediaType, int bodyStartOctet, Long textualLineCount, List<Property> properties, List<MessageAttachmentMetadata> attachments, boolean hasAttachments) { this.messageId = messageId; this.subType = subType; this.mediaType = mediaType; this.content = content; this.bodyStartOctet = bodyStartOctet; this.internalDate = internalDate; this.size = size; this.textualLineCount = textualLineCount; this.properties = properties; this.attachments = attachments; this.hasAttachments = hasAttachments; }
Example #14
Source File: MessageFactory.java From james-project with Apache License 2.0 | 4 votes |
T createMessage(MessageId messageId, Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, List<MessageAttachmentMetadata> attachments) throws MailboxException;
Example #15
Source File: MessageStorer.java From james-project with Apache License 2.0 | 4 votes |
private List<MessageAttachmentMetadata> storeAttachments(MessageId messageId, SharedInputStream messageContent, MailboxSession session) throws MailboxException { List<ParsedAttachment> attachments = extractAttachments(messageContent); return attachmentMapperFactory.getAttachmentMapper(session) .storeAttachmentsForMessage(attachments, messageId); }
Example #16
Source File: MessageStorer.java From james-project with Apache License 2.0 | 2 votes |
/** * If supported by the underlying implementation, this method will parse the messageContent to retrieve associated * attachments and will store them. * * Otherwize an empty optional will be returned on the right side of the pair. */ Pair<MessageMetaData, Optional<List<MessageAttachmentMetadata>>> appendMessageToStore(Mailbox mailbox, Date internalDate, int size, int bodyStartOctet, SharedInputStream content, Flags flags, PropertyBuilder propertyBuilder, MailboxSession session) throws MailboxException;