public class StoreMessageManager<Id> extends Object implements MessageManager
MessageManager
implementations.
This base class take care of dispatching events to the registered
MailboxListener and so help with handling concurrent
MailboxSession's.MessageManager.MetaData| Modifier and Type | Field and Description |
|---|---|
protected static javax.mail.Flags |
MINIMAL_PERMANET_FLAGS
The minimal Permanent flags the
MessageManager must support. |
| Constructor and Description |
|---|
StoreMessageManager(MessageMapperFactory<Id> mapperFactory,
MessageSearchIndex<Id> index,
MailboxEventDispatcher<Id> dispatcher,
MailboxPathLocker locker,
Mailbox<Id> mailbox,
MailboxACLResolver aclResolver,
GroupMembershipResolver groupMembershipResolver) |
| Modifier and Type | Method and Description |
|---|---|
long |
appendMessage(InputStream msgIn,
Date internalDate,
MailboxSession mailboxSession,
boolean isRecent,
javax.mail.Flags flagsToBeSet)
Appends a message to this mailbox.
|
protected MessageMetaData |
appendMessageToStore(Message<Id> message,
MailboxSession session) |
List<MessageRange> |
copyTo(MessageRange set,
StoreMessageManager<Id> toMailbox,
MailboxSession session)
Copy the
MessageRange to the StoreMessageManager |
protected long |
countUnseenMessagesInMailbox(MailboxSession session)
Return the count of unseen messages
|
protected Message<Id> |
createMessage(Date internalDate,
int size,
int bodyStartOctet,
javax.mail.internet.SharedInputStream content,
javax.mail.Flags flags,
PropertyBuilder propertyBuilder)
Create a new
Message for the given data |
protected Map<Long,MessageMetaData> |
deleteMarkedInMailbox(MessageRange range,
MailboxSession session) |
Iterator<Long> |
expunge(MessageRange set,
MailboxSession mailboxSession)
Expunges messages in the given range from this mailbox.
|
protected Long |
findFirstUnseenMessageUid(MailboxSession session)
Return the uid of the first unseen message or null of none is found
|
protected MailboxEventDispatcher<Id> |
getDispatcher()
Return the
MailboxEventDispatcher for this Mailbox |
protected MailboxPathLocker |
getLocker()
Return the
MailboxPathLocker |
Mailbox<Id> |
getMailboxEntity()
Return the underlying
Mailbox |
long |
getMessageCount(MailboxSession mailboxSession)
Return the count
|
MessageResultIterator |
getMessages(MessageRange set,
MessageResult.FetchGroup fetchGroup,
MailboxSession mailboxSession)
Gets messages in the given range.
|
MessageManager.MetaData |
getMetaData(boolean resetRecent,
MailboxSession mailboxSession,
MessageManager.MetaData.FetchGroup fetchGroup)
Gets current meta data for the mailbox.
Consolidates common calls together to allow improved performance. The meta-data returned should be immutable and represent the current state of the mailbox. |
protected javax.mail.Flags |
getPermanentFlags(MailboxSession session)
Return
Flags which are permanent stored by the mailbox. |
protected MailboxACL |
getResolvedMailboxACL(MailboxSession mailboxSession)
Applies the global ACL (if there are any) to the mailbox ACL.
|
protected javax.mail.Flags |
getSharedPermanentFlags(MailboxSession session)
Returns the flags which are shared for the current mailbox, i.e.
|
boolean |
hasRight(MailboxACL.MailboxACLRight right,
MailboxSession session)
Tells whether the given
MailboxSession's user has the given
MailboxACL.MailboxACLRight for this MessageManager's mailbox. |
protected boolean |
isGroupFolder(MailboxSession session)
Returns true if the current mailbox does not reside neither in private
nor other users' namespace.
|
boolean |
isModSeqPermanent(MailboxSession session)
Return true.
|
boolean |
isWriteable(MailboxSession session)
This mailbox is writable
|
MailboxACL.MailboxACLRights[] |
listRigths(MailboxACL.MailboxACLEntryKey key,
MailboxSession session)
Computes a result suitable for the LISTRIGHTS IMAP command.
|
MailboxACL.MailboxACLRights |
myRights(MailboxSession session)
Returns the rights applicable to the user who has sent the current
request.
|
protected List<Long> |
recent(boolean reset,
MailboxSession mailboxSession)
Return a List which holds all uids of recent messages and optional reset
the recent flag on the messages for the uids
|
Iterator<Long> |
search(SearchQuery query,
MailboxSession mailboxSession)
Searches for messages matching the given query.
|
void |
setFetchBatchSize(int fetchBatchSize) |
Map<Long,javax.mail.Flags> |
setFlags(javax.mail.Flags flags,
boolean value,
boolean replace,
MessageRange set,
MailboxSession mailboxSession)
Sets flags on messages within the given range.
|
void |
setRights(MailboxACL.MailboxACLEntryKey mailboxACLEntryKey,
MailboxACL.EditMode editMode,
MailboxACL.MailboxACLRights mailboxAclRights)
TODO setRights.
|
protected static final javax.mail.Flags MINIMAL_PERMANET_FLAGS
MessageManager must support. public StoreMessageManager(MessageMapperFactory<Id> mapperFactory, MessageSearchIndex<Id> index, MailboxEventDispatcher<Id> dispatcher, MailboxPathLocker locker, Mailbox<Id> mailbox, MailboxACLResolver aclResolver, GroupMembershipResolver groupMembershipResolver) throws MailboxException
MailboxExceptionpublic void setFetchBatchSize(int fetchBatchSize)
protected MailboxPathLocker getLocker()
MailboxPathLockerprotected MailboxEventDispatcher<Id> getDispatcher()
MailboxEventDispatcher for this Mailboxpublic Mailbox<Id> getMailboxEntity() throws MailboxException
MailboxMailboxExceptionprotected javax.mail.Flags getPermanentFlags(MailboxSession session)
Flags which are permanent stored by the mailbox. By
default this are the following flags: Flags.Flag.ANSWERED, Flags.Flag.DELETED, Flags.Flag.DRAFT,
Flags.Flag.FLAGGED, Flags.Flag.RECENT, Flags.Flag.SEEN Flags.Flag.USER to the list of returned
Flags. If only a special set of user flags / keywords should be
allowed just add them directly.session - protected javax.mail.Flags getSharedPermanentFlags(MailboxSession session)
getPermanentFlags(MailboxSession)session - UnionMailboxACLResolver#isReadWrite(MailboxACLRights, Flags)public boolean isModSeqPermanent(MailboxSession session)
isModSeqPermanent in interface MessageManagerpublic Iterator<Long> expunge(MessageRange set, MailboxSession mailboxSession) throws MailboxException
MessageManagerexpunge in interface MessageManagerset - not nullmailboxSession - not nullMailboxException - if anything went wrongMessageManager.expunge(org.apache.james.mailbox.model.MessageRange,
org.apache.james.mailbox.MailboxSession)public long appendMessage(InputStream msgIn, Date internalDate, MailboxSession mailboxSession, boolean isRecent, javax.mail.Flags flagsToBeSet) throws MailboxException
MessageManagerappendMessage in interface MessageManagerinternalDate - the time of addition to be set, not nullmailboxSession - not nullisRecent - true when the message should be marked recent, false otherwiseflagsToBeSet - optionally set these flags on created message, or null when no
additional flags should be setMailboxException - when message cannot be appendedMessageManager.appendMessage(java.io.InputStream,
java.util.Date, org.apache.james.mailbox.MailboxSession, boolean,
javax.mail.Flags)protected Message<Id> createMessage(Date internalDate, int size, int bodyStartOctet, javax.mail.internet.SharedInputStream content, javax.mail.Flags flags, PropertyBuilder propertyBuilder) throws MailboxException
Message for the given datainternalDate - size - bodyStartOctet - content - flags - MailboxExceptionpublic boolean isWriteable(MailboxSession session) throws MailboxException
isWriteable in interface MessageManagerMailboxExceptionpublic MessageManager.MetaData getMetaData(boolean resetRecent, MailboxSession mailboxSession, MessageManager.MetaData.FetchGroup fetchGroup) throws MailboxException
MessageManagergetMetaData in interface MessageManagerresetRecent - true when recent flags should be reset, false otherwisemailboxSession - context, not nullfetchGroup - describes which optional data should be returnedMailboxExceptionMessageManager.getMetaData(boolean, MailboxSession,
org.apache.james.mailbox.MessageManager.MetaData.FetchGroup)public Map<Long,javax.mail.Flags> setFlags(javax.mail.Flags flags, boolean value, boolean replace, MessageRange set, MailboxSession mailboxSession) throws MailboxException
MessageManagersetFlags in interface MessageManagerflags - Flags to be setvalue - true = set, false = unsetreplace - replace all Flags with this flags, value has to be trueset - the range of messagesmailboxSession - not nullMailboxExceptionMessageManager.setFlags(javax.mail.Flags,
boolean, boolean, org.apache.james.mailbox.model.MessageRange,
org.apache.james.mailbox.MailboxSession)public List<MessageRange> copyTo(MessageRange set, StoreMessageManager<Id> toMailbox, MailboxSession session) throws MailboxException
MessageRange to the StoreMessageManagerset - toMailbox - session - MailboxExceptionprotected MessageMetaData appendMessageToStore(Message<Id> message, MailboxSession session) throws MailboxException
MailboxExceptionpublic long getMessageCount(MailboxSession mailboxSession) throws MailboxException
MessageManagergetMessageCount in interface MessageManagerMailboxExceptionMessageManager.getMessageCount(org.apache.james.mailbox.MailboxSession)public MessageResultIterator getMessages(MessageRange set, MessageResult.FetchGroup fetchGroup, MailboxSession mailboxSession) throws MailboxException
MessageManagerMessageResultIterator.getException() returns null
after Iterator.hasNext() returns false.getMessages in interface MessageManagerfetchGroup - data to fetchmailboxSession - not nullMailboxExceptionMessageManager.getMessages(org.apache.james.mailbox.model.MessageRange,
org.apache.james.mailbox.model.MessageResult.FetchGroup,
org.apache.james.mailbox.MailboxSession)protected List<Long> recent(boolean reset, MailboxSession mailboxSession) throws MailboxException
reset - mailboxSession - MailboxExceptionprotected Map<Long,MessageMetaData> deleteMarkedInMailbox(MessageRange range, MailboxSession session) throws MailboxException
MailboxExceptionpublic Iterator<Long> search(SearchQuery query, MailboxSession mailboxSession) throws MailboxException
MessageManagersearch in interface MessageManagermailboxSession - not nullUnsupportedCriteriaException - when any of the search parameters are not supported by this
mailboxMailboxException - when search fails for other reasonsMessageManager.search(org.apache.james.mailbox.model.SearchQuery,
org.apache.james.mailbox.MailboxSession)protected long countUnseenMessagesInMailbox(MailboxSession session) throws MailboxException
session - MailboxExceptionprotected Long findFirstUnseenMessageUid(MailboxSession session) throws MailboxException
session - MailboxExceptionpublic boolean hasRight(MailboxACL.MailboxACLRight right, MailboxSession session) throws UnsupportedRightException
MessageManagerMailboxSession's user has the given
MailboxACL.MailboxACLRight for this MessageManager's mailbox.hasRight in interface MessageManagerMailboxSession's user has the given
MailboxACL.MailboxACLRight for this MessageManager's
mailbox; false otherwise.UnsupportedRightExceptionorg.apache.james.mailbox.MessageManager#hasRight(org.apache.james.mailbox.MailboxACL.MailboxACLRight,
org.apache.james.mailbox.MailboxSession)public MailboxACL.MailboxACLRights myRights(MailboxSession session) throws MailboxException
MessageManagermyRights in interface MessageManagerSimpleMailboxACL.NO_RIGHTS if
session.getUser() is null.UnsupportedRightExceptionMailboxExceptionMessageManager.myRights(org.apache.james.mailbox.MailboxSession)public MailboxACL.MailboxACLRights[] listRigths(MailboxACL.MailboxACLEntryKey key, MailboxSession session) throws UnsupportedRightException
MessageManageridentifier.
From RFC 4314 section 3.7:
The first element of the resulting array contains the (possibly empty)
set of rights the identifier will always be granted in the mailbox.
Following this are zero or more right sets the identifier can be granted
in the mailbox. Rights mentioned in the same set are tied together. The
server MUST either grant all tied rights to the identifier in the mailbox
or grant none.
The same right MUST NOT be listed more than once in the LISTRIGHTS
command.listRigths in interface MessageManagerkey - the identifier from the LISTRIGHTS command.UnsupportedRightExceptionorg.apache.james.mailbox.MessageManager#listRigths(java.lang.String, org.apache.james.mailbox.MailboxSession)public void setRights(MailboxACL.MailboxACLEntryKey mailboxACLEntryKey, MailboxACL.EditMode editMode, MailboxACL.MailboxACLRights mailboxAclRights) throws UnsupportedRightException
MessageManagersetRights in interface MessageManagerUnsupportedRightExceptionorg.apache.james.mailbox.MessageManager#setRights(java.lang.String, org.apache.james.mailbox.model.MailboxACL.EditMode, org.apache.james.mailbox.model.MailboxACL.MailboxACLRights)protected MailboxACL getResolvedMailboxACL(MailboxSession mailboxSession) throws UnsupportedRightException
mailboxSession - UnsupportedRightExceptionprotected boolean isGroupFolder(MailboxSession session)
session - Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.