Class MaildirMailboxStore
java.lang.Object
org.bluezoo.gumdrop.mailbox.maildir.MaildirMailboxStore
- All Implemented Interfaces:
MailboxStore
Mail store implementation using Maildir++ format.
This implementation provides multi-folder mailbox support for IMAP
using the Maildir++ format. Each mailbox is a directory containing
cur/, new/, and tmp/ subdirectories.
Directory structure (Maildir++):
root/
username/
cur/ (INBOX messages)
new/ (INBOX new messages)
tmp/ (INBOX temp files)
.Sent/
cur/ new/ tmp/ (Sent folder)
.Drafts/
cur/ new/ tmp/ (Drafts folder)
.folder.subfolder/
cur/ new/ tmp/ (nested folder)
.subscriptions (subscribed mailboxes)
The hierarchy delimiter is "/" but folder directories use "." prefix and "." as separator (Maildir++ convention).
Security: All paths are sandboxed to prevent directory traversal attacks. Paths containing ".." or absolute references are rejected.
- Author:
- Chris Burdess
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.bluezoo.gumdrop.mailbox.MailboxStore
MailboxStore.Quota -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the mail store and releases any resources.voidcreateMailbox(String mailboxName) Creates a new mailbox.voiddeleteMailbox(String mailboxName) Deletes a mailbox.charReturns the hierarchy delimiter character used by this store.getMailboxAttributes(String mailboxName) Returns the mailbox attributes for the specified mailbox.Returns the quota information for the specified quota root.getQuotaRoot(String mailboxName) Returns the quota root for the specified mailbox.listMailboxes(String reference, String pattern) Lists mailboxes matching the given reference and pattern.listSubscribed(String reference, String pattern) Returns subscription status for mailboxes matching the pattern.voidOpens the mail store for the specified user.openMailbox(String mailboxName, boolean readOnly) Opens a mailbox by name.voidrenameMailbox(String oldName, String newName) Renames a mailbox.voidSubscribes to a mailbox.voidunsubscribe(String mailboxName) Unsubscribes from a mailbox.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.bluezoo.gumdrop.mailbox.MailboxStore
getOtherUsersNamespace, getPersonalNamespace, getSharedNamespace
-
Constructor Details
-
MaildirMailboxStore
Creates a new Maildir mail store.- Parameters:
rootDirectory- the root directory for all user mailboxes
-
-
Method Details
-
open
Description copied from interface:MailboxStoreOpens the mail store for the specified user. This should be called after successful authentication.- Specified by:
openin interfaceMailboxStore- Parameters:
username- the user whose mail store to open- Throws:
IOException- if the store cannot be opened
-
close
Description copied from interface:MailboxStoreCloses the mail store and releases any resources. All open mailboxes should be closed before calling this.- Specified by:
closein interfaceMailboxStore- Throws:
IOException- if the store cannot be closed properly
-
getHierarchyDelimiter
public char getHierarchyDelimiter()Description copied from interface:MailboxStoreReturns the hierarchy delimiter character used by this store. This separates levels in mailbox names (e.g., "INBOX/Subfolder").- Specified by:
getHierarchyDelimiterin interfaceMailboxStore- Returns:
- the hierarchy delimiter (typically "/" or ".")
-
listMailboxes
Description copied from interface:MailboxStoreLists mailboxes matching the given reference and pattern.The reference is a prefix that is prepended to the pattern. The pattern may contain wildcards:
- "*" matches any characters including hierarchy delimiter
- "%" matches any characters except hierarchy delimiter
- Specified by:
listMailboxesin interfaceMailboxStore- Parameters:
reference- the reference name (prefix)pattern- the mailbox name pattern with optional wildcards- Returns:
- list of matching mailbox names
- Throws:
IOException- if the list cannot be retrieved
-
listSubscribed
Description copied from interface:MailboxStoreReturns subscription status for mailboxes matching the pattern. For IMAP LSUB command support.- Specified by:
listSubscribedin interfaceMailboxStore- Parameters:
reference- the reference name (prefix)pattern- the mailbox name pattern with optional wildcards- Returns:
- list of subscribed mailbox names matching the pattern
- Throws:
IOException- if the list cannot be retrieved
-
subscribe
Description copied from interface:MailboxStoreSubscribes to a mailbox.- Specified by:
subscribein interfaceMailboxStore- Parameters:
mailboxName- the name of the mailbox to subscribe to- Throws:
IOException- if the subscription fails
-
unsubscribe
Description copied from interface:MailboxStoreUnsubscribes from a mailbox.- Specified by:
unsubscribein interfaceMailboxStore- Parameters:
mailboxName- the name of the mailbox to unsubscribe from- Throws:
IOException- if the unsubscription fails
-
openMailbox
Description copied from interface:MailboxStoreOpens a mailbox by name. For POP3 compatibility, "INBOX" should always be available.- Specified by:
openMailboxin interfaceMailboxStore- Parameters:
mailboxName- the name of the mailbox to openreadOnly- true to open in read-only mode- Returns:
- the opened mailbox
- Throws:
IOException- if the mailbox cannot be opened
-
createMailbox
Description copied from interface:MailboxStoreCreates a new mailbox.- Specified by:
createMailboxin interfaceMailboxStore- Parameters:
mailboxName- the name of the mailbox to create- Throws:
IOException- if the mailbox cannot be created
-
deleteMailbox
Description copied from interface:MailboxStoreDeletes a mailbox. The mailbox must be empty and not currently selected.- Specified by:
deleteMailboxin interfaceMailboxStore- Parameters:
mailboxName- the name of the mailbox to delete- Throws:
IOException- if the mailbox cannot be deleted
-
renameMailbox
Description copied from interface:MailboxStoreRenames a mailbox.- Specified by:
renameMailboxin interfaceMailboxStore- Parameters:
oldName- the current mailbox namenewName- the new mailbox name- Throws:
IOException- if the mailbox cannot be renamed
-
getMailboxAttributes
Description copied from interface:MailboxStoreReturns the mailbox attributes for the specified mailbox. These are IMAP mailbox attributes like \Noselect, \Noinferiors, etc.- Specified by:
getMailboxAttributesin interfaceMailboxStore- Parameters:
mailboxName- the mailbox name- Returns:
- set of mailbox attributes
- Throws:
IOException- if attributes cannot be retrieved
-
getQuotaRoot
Description copied from interface:MailboxStoreReturns the quota root for the specified mailbox. For IMAP QUOTA extension support.- Specified by:
getQuotaRootin interfaceMailboxStore- Parameters:
mailboxName- the mailbox name- Returns:
- the quota root name, or null if quotas are not supported
- Throws:
IOException- if the quota root cannot be determined
-
getQuota
Description copied from interface:MailboxStoreReturns the quota information for the specified quota root. For IMAP QUOTA extension support.- Specified by:
getQuotain interfaceMailboxStore- Parameters:
quotaRoot- the quota root name- Returns:
- the quota information, or null if not available
- Throws:
IOException- if quota information cannot be retrieved
-