|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.mail.Service
javax.mail.Store
org.abstracthorizon.mercury.maildir.MaildirStore
public class MaildirStore
This is simple maildir implementation store. It reads files from the cur and
new subdirectories of the store or subdirectories of store's folders. When new
message is created tmp subdirectory is used for RFC-822 mail to be written
in it and then it is renamed to new directory. This implementation doesn't
write/read to/from any special index files and it is not implementing UIDFolder
interface from javax.mail
API. Messages are ordered in folders in the
way java.io.File.list
method is returning files.
It takes a path of the store an input parameter (path in URLName). Also it uses following session properties:
property | default value if not present | description |
---|---|---|
maildir.leadingDot |
true |
If this property has value of true then folders' directories are
with the leading dot. This is standard used by most implementations of maildir. If value
is set to false then folders' directories are stored without leading dot.
Note: If directories are without leading dot then tmp, cur and new
are invalid names of folders.
|
maildir.infoSeparator |
System.getProperty("path.separator") is ":" then
":". Othewise "." |
If value is set then it will be used as separator of info part in maildir's filename. |
maildir.httpSyntax |
false is ":" then
":". Othewise "." |
If set to true then URLName's syntax for maildir should be:
maildir://user:password@host:port/foldername?base=base_directory_of_maildir_store .
Otherwise it is maildir://user:password@host:port/base_directory_of_maildir_store#foldername .
Note: foldername is not used when store is being obtained.
|
maildir.home |
If maildir store's base directory is not set in URL this session property will be queried and its value used if present. |
Maildir store's base directory is searched in following order:
maildir.httpSyntax
for more details). If not present thenmaildir.home
from session. If not present thenuser.home
from system properties with .mail
appended to the path. If that directory is not present thenuser.home
from system properties with Mail
appended to the path.If all fails it obtaining the store will fail as well.
This implementation also does substitutions in supplied path based on url name parameters:
{user}
in the path is substituted by username from url name{protocol}
in the path is substituted by protocol from url name{port}
in the path is substituted by port from url name{host}
in the path is substituted by host from url nameThis class implements centralised cached directory of all currently open folder.
Folder data actually contains messages while folders have only wrappers with references to folder data's messages. Each folder uses wrappers to maintain message number. All open folders are registered with folder data and changes one folder, through folder data, are immediately propagated to other folder over the same folder data (same virtually folder). Folder data here serves as central repository of messages over one directory.
If new messages are discovered in directory or one folder over folder data has new messages added by append method, all other folders over the same folder data will be notified of new messages and then will immediately appear in their lists
Similarily if one folder expunges messages or messages are detected as deleted from the underlaying directory, all folder's will be notified of the change and all messages will be marked as expunged.
Field Summary | |
---|---|
protected File |
base
Store's base directory file |
protected Map<File,Reference<MaildirFolderData>> |
directories
Cache |
static String |
HOME
Store's home directory session attribute name |
static String |
HTTP_SYNTAX
Http syntax session attribute name |
protected boolean |
httpSyntax
Cached http syntax property |
static String |
INFO_SEPARATOR
Info separator session attribute name |
protected char |
infoSeparator
Cached info separator property |
static String |
LEADING_DOT
Leading dot session attribute name |
protected boolean |
leadingDot
Cached leading dot property |
static long |
MAX_FOLDER_DATA_LIFE
Amount of time folder is going to be kept in list of folders |
Fields inherited from class javax.mail.Service |
---|
debug, session, url |
Constructor Summary | |
---|---|
MaildirStore(javax.mail.Session session,
javax.mail.URLName urlname)
Constructor |
Method Summary | |
---|---|
protected File |
createBaseFile(javax.mail.URLName urlName,
String baseName)
Creates base file and substitues {user} , {port} ,
{host} and {protocol} |
protected MaildirFolder |
createFolder(MaildirFolderData folderData)
Creates new folder instance with given folder data. |
protected MaildirFolderData |
createFolderData(File file)
This implementation creates MaildirFolderData from supplied file. |
File |
getBaseFile()
Retuns base file (store's base directory) |
javax.mail.Folder |
getDefaultFolder()
Returns default folder |
javax.mail.Folder |
getFolder(String name)
Returns new folder from full folder's name |
javax.mail.Folder |
getFolder(javax.mail.URLName urlName)
Returns new folder from URLName. |
protected MaildirFolderData |
getFolderData(File file)
This method returns folder data needed for folder to operate on. |
protected MaildirFolderData |
getFolderData(String name)
Returns folder data for given folder. |
char |
getInfoSeparator()
Returns info separator |
javax.mail.Folder |
getParentFolder(MaildirFolderData folderData)
Returns folder with given folder data |
boolean |
isHttpSyntax()
Returns http syntax |
boolean |
isLeadingDot()
Returns leading dot |
protected void |
parseURLName(javax.mail.URLName urlname)
Parses url name |
protected void |
processParam(javax.mail.URLName urlName,
String param)
Processes singe parameter from url name |
protected boolean |
protocolConnect(String host,
int port,
String user,
String password)
This method returns true always. |
protected String |
replace(String s,
String what,
String with)
Replaces substring |
Methods inherited from class javax.mail.Store |
---|
addFolderListener, addStoreListener, getPersonalNamespaces, getSharedNamespaces, getUserNamespaces, notifyFolderListeners, notifyFolderRenamedListeners, notifyStoreListeners, removeFolderListener, removeStoreListener |
Methods inherited from class javax.mail.Service |
---|
addConnectionListener, close, connect, connect, connect, connect, finalize, getURLName, isConnected, notifyConnectionListeners, queueEvent, removeConnectionListener, setConnected, setURLName, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String LEADING_DOT
public static final String HOME
public static final String INFO_SEPARATOR
public static final String HTTP_SYNTAX
public static final long MAX_FOLDER_DATA_LIFE
protected File base
protected boolean leadingDot
protected boolean httpSyntax
protected char infoSeparator
protected Map<File,Reference<MaildirFolderData>> directories
Constructor Detail |
---|
public MaildirStore(javax.mail.Session session, javax.mail.URLName urlname)
session
- mail sessionurlname
- url nameMethod Detail |
---|
protected void parseURLName(javax.mail.URLName urlname)
urlname
- url nameprotected void processParam(javax.mail.URLName urlName, String param)
urlName
- url nameparam
- parameterprotected File createBaseFile(javax.mail.URLName urlName, String baseName)
{user}
, {port}
,
{host}
and {protocol}
urlName
- url namebaseName
- directory path
protected String replace(String s, String what, String with)
s
- string on which operation is donewhat
- what to be replacedwith
- new value to be placed instead
public char getInfoSeparator()
public boolean isLeadingDot()
public boolean isHttpSyntax()
public File getBaseFile()
public javax.mail.Folder getDefaultFolder() throws javax.mail.MessagingException
getDefaultFolder
in class javax.mail.Store
javax.mail.MessagingException
protected MaildirFolderData getFolderData(String name)
getFolderData(File)
method.
name
- full folder's name
protected MaildirFolderData getFolderData(File file)
file
- directory
protected MaildirFolderData createFolderData(File file)
MaildirFolderData
from supplied file.
file
- file
public javax.mail.Folder getParentFolder(MaildirFolderData folderData) throws javax.mail.MessagingException
folderData
- folder data
javax.mail.MessagingException
public javax.mail.Folder getFolder(String name) throws javax.mail.MessagingException
getFolder
in class javax.mail.Store
name
- full folder's name
javax.mail.MessagingException
public javax.mail.Folder getFolder(javax.mail.URLName urlName) throws javax.mail.MessagingException
maildir.httpSyntax
attribute
has value of true
then url name's file is used, otherwise
url name's ref is used.
getFolder
in class javax.mail.Store
urlName
- url name
javax.mail.MessagingException
protected MaildirFolder createFolder(MaildirFolderData folderData)
folderData
- folder data
protected boolean protocolConnect(String host, int port, String user, String password) throws javax.mail.MessagingException
true
always.
protocolConnect
in class javax.mail.Service
host
- ignoredport
- ignoreduser
- ignoredpassword
- ignored
true
javax.mail.MessagingException
- never
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |