Keel 2.1RC2

org.keel.services.mail.javamail
Class DefaultReader

java.lang.Object
  extended byorg.keel.core.container.AbstractKeelServiceable
      extended byorg.keel.services.mail.javamail.DefaultReader
All Implemented Interfaces:
Configurable, LogEnabled, Reader, Serviceable

public class DefaultReader
extends AbstractKeelServiceable
implements Reader, Configurable, LogEnabled

This service implements the Keel Reader service. It provides the capability to retrieve and parse email from a POP3 or IMAP server. This implementation of the Reader interface is meant to be used with a server for which this is the only client that consumes messages. In other words, don't use this on an POP3/IMAP account where other clients will concurrently modify the state of read/deleted messages. In particular, the "msgIndex" parameter used throughout the API is guranteed to work after a read() only if messages are not deleted on the server until this client itself does it. This implementation over JavaMail does not use message listeners. Therefore when messgaes are added/deleted on the server by other clients and MUAs, this client is completely unaware. To read the new set of messages a new read() call must be issued. To consume a message, users of this service must use the setSeen(msgIndex, true) method call. To delete, setDelete(msgIndex, true) must be called, but messages will be deleted only when disconnect() is called. However, for deletion to work, the folder must have been opened in read-write mode, and the folderExpunge flag must be set to true. POP3 functionality is a bit different, since POP3 is a "read-only" service. If the content of a POP3 message is retrieved (using getFile, getFileName, etc.), then the server will automatically mark the message as "read". Also, POP3 servers typically do not support the "SEEN" flag but use the "Status:" header instead. This implementation supports a workaround, activated by the "useStatusHeader" config. parameter, which will use the Status header to determine is a message has been read or not.

Version:
$Revision: 1.8 $ $Date: 2003/10/10 23:12:58 $
Author:
Shash Chatterjee Created on Jan 4, 2003

Field Summary
private  java.lang.String attachDir
          Folder where attachments will be placed
private  java.lang.String attachExt
          Attachment extension when filename/content-type is not provided
private  java.lang.String attachName
          Attachment name when fileName is not provided
private  Configuration configuration
          The configuraton for this service - from mailer-system.xconf
private  Folder folder
          The folder on the POP3/IMAP store that mail is retrieved from
private  boolean folderExpunge
          Folder close mode - expunge deleted messages on close
private  boolean folderReadWrite
          Folder open mode - read-only, or, read-write
private  Logger logger
          The logger for info/debug messages
private  boolean mailAuth
          SMTP server requires authentication
private  boolean mailDebug
          Turn on JavaMail session debug
private  java.lang.String mailFolder
          Folder name where mail is stored
private  java.lang.String mailHost
          The POP3/IMAP host
private  java.lang.String mailPassword
          Password for account
private  java.lang.String mailProtocol
          The server protocol - POP3 or IMAP
private  java.lang.String mailUser
          Username for account
private  Message[] messages
          The messages retrieved from the folder
private  boolean nullAllowed
          If set, this config value will chgeck for null returns on String and array returns.
private  Session session
          The session context of the mail-server
private  Store store
          The POP3/IMAP store
private  boolean useStatusHeader
          Some POP3 servers will not send the "SEEN" status, so the seen/read state has to be inferred from the "Status" header
 
Fields inherited from class org.keel.core.container.AbstractKeelServiceable
 
Fields inherited from interface org.keel.services.mail.Reader
ROLE
 
Constructor Summary
DefaultReader()
           
 
Method Summary
private  java.lang.String[] addrToString(Address[] addr)
          Method to convert an array of javax.mail.Address to an array of Strings
private  void checkMsgIndex(int msgIndex)
          Convenience method to bounds-check the emssage index.
 void configure(Configuration configuration)
          This method reads the container-provided configuration
 void connect()
          Get the client in a state connected to the server so that it is ready to retrieve messages.
 void connect(java.lang.String host, java.lang.String user, java.lang.String password)
          Connect while overriding the user and password supplied by configuration Saying "connect(null, null, null)" is the same as "connect()"
 int count()
          Return a count of messages retrieved from the server.
private  java.io.File createFile(Part p)
          Take the content of a message-part and put it in a file.
 void disconnect()
          Close the client-server connection.
 void enableLogging(Logger logger)
          This method associates this service with a logger
 java.lang.String[] getBcc(int msgIndex)
          Get the contents of the Bcc: header
private  Part getBodyPart(int msgIndex)
          Method to extract the body of a single-part message
 java.lang.String[] getCc(int msgIndex)
          Get the contents of the Cc: header
 java.lang.String getContentType(int msgIndex)
          Get the content of the ContentType header of a single-part message
 java.lang.String getContentType(int msgIndex, int partIndex)
          Get the content of the ContentType header of a part of a multi-part message
 java.lang.String getDisposition(int msgIndex)
          Get the content of the disposition header of a single-part message
 java.lang.String getDisposition(int msgIndex, int partIndex)
          Get the content of the disposition header of a part of a multi-part message
 java.io.File getFile(int msgIndex)
          Get the contents of a single-part message
 java.io.File getFile(int msgIndex, int partIndex)
          Get the contents of a particular part of a multi-part message
 java.lang.String getFileName(int msgIndex)
          Get the file name in the header of a single-part message
 java.lang.String getFileName(int msgIndex, int partIndex)
          Get the file name in the header of a part in the multi-part message
 java.lang.String[] getFrom(int msgIndex)
          Get the contents of the From: header
private  java.util.Enumeration getHeader(int msgIndex, java.lang.String str)
          Convenience method to take the string arg and make an array out of it before calling the JavaMail method
 java.util.Enumeration getHeaders(int msgIndex)
          Get all headers for a message
 java.lang.String getInline(int msgIndex)
          Get the content of an inline message
 int getLineCount(int msgIndex)
          Get the number of lines in a message (meaningless for multi-part messages)
 int getMultiPartCount(int msgIndex)
          Get the number of parts in a multi-part message
private  Part getOneBodyPart(int msgIndex, int partIndex)
          Method to get a particular part of a multi-part message
 java.lang.String[] getReplyTo(int msgIndex)
          Get the contents of the ReplyTo: header
 java.util.Date getSentDate(int msgIndex)
          Get the date a message was sent (Date header)
 int getSize(int msgIndex)
          Get the size of a message
 java.lang.String getSubject(int msgIndex)
          Get the subject header from a message
 java.lang.String[] getTo(int msgIndex)
          Get the contents of the To: header
 boolean isAnswered(int msgIndex)
          Check if this message has been marked as "answered" by a client
 boolean isDeleted(int msgIndex)
          Check if this message has been marked by a client as "deleted" or not
 boolean isDraft(int msgIndex)
          Check if this message has been marked by some client as "draft" or not
 boolean isFlagged(int msgIndex)
          Check if this message has been marked by a client as "flagged"
 boolean isInline(int msgIndex)
          Check if the message content is inline
 boolean isMultiPart(int msgIndex)
          Check if the message content is formatted as MIME multi-part
 boolean isRecent(int msgIndex)
          Check if this message is amrked by the server as "recent" or not
 boolean isSeen(int msgIndex)
          Check if this message has already been read or not
 boolean isSinglePart(int msgIndex)
          Check if the message content is formatted as MIME single-part
private  boolean matchFlag(int msgIndex, Flags.Flag flag)
          Convenience method to retrieve flags from a particular message and then to check if a particular flag is set.
 void read()
          Retrieve all messages from the server
 void send()
           
 void setAnswered(int msgIndex, boolean state)
          Mark a message as "answered"
 void setDeleted(int msgIndex, boolean state)
          Mark a message as "deleted"
 void setDraft(int msgIndex, boolean state)
          Mark a message as "draft
private  void setFlag(int msgIndex, Flags.Flag flag, boolean state)
          Convenience method to set a flasg in a message NOTE: The connection must have been opened in READ/WRITE mode.
 void setFlagged(int msgIndex, boolean state)
          Mark a message as "flagged
 void setSeen(int msgIndex, boolean state)
          Mark a message as "read"
 
Methods inherited from class org.keel.core.container.AbstractKeelServiceable
getService, getService, getService, getService, getServiceManager, getServiceSelector, releaseService, releaseServices, service
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private Logger logger
The logger for info/debug messages


configuration

private Configuration configuration
The configuraton for this service - from mailer-system.xconf


mailHost

private java.lang.String mailHost
The POP3/IMAP host


mailProtocol

private java.lang.String mailProtocol
The server protocol - POP3 or IMAP


mailDebug

private boolean mailDebug
Turn on JavaMail session debug


mailAuth

private boolean mailAuth
SMTP server requires authentication


mailUser

private java.lang.String mailUser
Username for account


mailPassword

private java.lang.String mailPassword
Password for account


mailFolder

private java.lang.String mailFolder
Folder name where mail is stored


folderReadWrite

private boolean folderReadWrite
Folder open mode - read-only, or, read-write


folderExpunge

private boolean folderExpunge
Folder close mode - expunge deleted messages on close


useStatusHeader

private boolean useStatusHeader
Some POP3 servers will not send the "SEEN" status, so the seen/read state has to be inferred from the "Status" header


nullAllowed

private boolean nullAllowed
If set, this config value will chgeck for null returns on String and array returns. Instead of a null, it will create at least one element in an array, and put an empty string in there. For lazy programmers.


attachDir

private java.lang.String attachDir
Folder where attachments will be placed


attachName

private java.lang.String attachName
Attachment name when fileName is not provided


attachExt

private java.lang.String attachExt
Attachment extension when filename/content-type is not provided


session

private Session session
The session context of the mail-server


store

private Store store
The POP3/IMAP store


folder

private Folder folder
The folder on the POP3/IMAP store that mail is retrieved from


messages

private Message[] messages
The messages retrieved from the folder

Constructor Detail

DefaultReader

public DefaultReader()
Method Detail

send

public void send()
          throws NestedException
Throws:
NestedException
See Also:
Mailer.send()

configure

public void configure(Configuration configuration)
               throws ConfigurationException
This method reads the container-provided configuration

Specified by:
configure in interface Configurable
Parameters:
configuration - the class configurations. Must not be null.
Throws:
ConfigurationException - if an error occurs
See Also:
Configurable.configure(org.apache.avalon.framework.configuration.Configuration)

enableLogging

public void enableLogging(Logger logger)
This method associates this service with a logger

Specified by:
enableLogging in interface LogEnabled
Parameters:
logger - the logger. Must not be null.
See Also:
LogEnabled.enableLogging(org.apache.avalon.framework.logger.Logger)

connect

public void connect()
             throws NestedException
Description copied from interface: Reader
Get the client in a state connected to the server so that it is ready to retrieve messages. The next thing to do would be to call read, repeatedly if necessary.

Specified by:
connect in interface Reader
Throws:
NestedException
See Also:
Reader.connect()

connect

public void connect(java.lang.String host,
                    java.lang.String user,
                    java.lang.String password)
             throws NestedException
Description copied from interface: Reader
Connect while overriding the user and password supplied by configuration Saying "connect(null, null, null)" is the same as "connect()"

Specified by:
connect in interface Reader
Parameters:
user - Username to use for connect - leave null to use configuration defaults
password - Password to use to authenticate user - leave null to use configuration default
Throws:
NestedException - If the connect does not succeed
See Also:
Reader.connect()

disconnect

public void disconnect()
                throws NestedException
Description copied from interface: Reader
Close the client-server connection. Messages can no longer be accessed.

Specified by:
disconnect in interface Reader
Throws:
NestedException
See Also:
Reader.disconnect()

read

public void read()
          throws NestedException
Description copied from interface: Reader
Retrieve all messages from the server

Specified by:
read in interface Reader
Throws:
NestedException
See Also:
Reader.read()

count

public int count()
Description copied from interface: Reader
Return a count of messages retrieved from the server. Can only be called after a read().

Specified by:
count in interface Reader
Returns:
int
See Also:
Reader.count()

getBcc

public java.lang.String[] getBcc(int msgIndex)
                          throws NestedException
Description copied from interface: Reader
Get the contents of the Bcc: header

Specified by:
getBcc in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String[] A string array of addresses, can be null
Throws:
NestedException
See Also:
Reader.getBcc(int)

getCc

public java.lang.String[] getCc(int msgIndex)
                         throws NestedException
Description copied from interface: Reader
Get the contents of the Cc: header

Specified by:
getCc in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String[] A string array of addresses, can be null
Throws:
NestedException
See Also:
Reader.getCc(int)

getFrom

public java.lang.String[] getFrom(int msgIndex)
                           throws NestedException
Description copied from interface: Reader
Get the contents of the From: header

Specified by:
getFrom in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String[] A string array of addresses, can be null
Throws:
NestedException
See Also:
Reader.getFrom(int)

getHeaders

public java.util.Enumeration getHeaders(int msgIndex)
                                 throws NestedException
Description copied from interface: Reader
Get all headers for a message

Specified by:
getHeaders in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
Enumeration An enumeration of javax.mail.Header containing name/value pairs
Throws:
NestedException
See Also:
Reader.getHeaders(int)

getLineCount

public int getLineCount(int msgIndex)
                 throws NestedException
Description copied from interface: Reader
Get the number of lines in a message (meaningless for multi-part messages)

Specified by:
getLineCount in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
int The number of lines in the message (can return -1)
Throws:
NestedException
See Also:
Reader.getLineCount(int)

getReplyTo

public java.lang.String[] getReplyTo(int msgIndex)
                              throws NestedException
Description copied from interface: Reader
Get the contents of the ReplyTo: header

Specified by:
getReplyTo in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String[] A string array of addresses, can be null
Throws:
NestedException
See Also:
Reader.getReplyTo(int)

getSentDate

public java.util.Date getSentDate(int msgIndex)
                           throws NestedException
Description copied from interface: Reader
Get the date a message was sent (Date header)

Specified by:
getSentDate in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
Date The date the message was sent
Throws:
NestedException
See Also:
Reader.getSentDate(int)

getSize

public int getSize(int msgIndex)
            throws NestedException
Description copied from interface: Reader
Get the size of a message

Specified by:
getSize in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
int The size of the message in bytes
Throws:
NestedException
See Also:
Reader.getSize(int)

getSubject

public java.lang.String getSubject(int msgIndex)
                            throws NestedException
Description copied from interface: Reader
Get the subject header from a message

Specified by:
getSubject in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String The value of the subject header
Throws:
NestedException
See Also:
Reader.getSubject(int)

getTo

public java.lang.String[] getTo(int msgIndex)
                         throws NestedException
Description copied from interface: Reader
Get the contents of the To: header

Specified by:
getTo in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String[] A string array of addresses, can be null
Throws:
NestedException
See Also:
Reader.getTo(int)

getContentType

public java.lang.String getContentType(int msgIndex,
                                       int partIndex)
                                throws NestedException
Description copied from interface: Reader
Get the content of the ContentType header of a part of a multi-part message

Specified by:
getContentType in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
partIndex - A number from 0 to getMultiPartCount()-1
Returns:
String
Throws:
NestedException
See Also:
Reader.getContentType(int, int)

getContentType

public java.lang.String getContentType(int msgIndex)
                                throws NestedException
Description copied from interface: Reader
Get the content of the ContentType header of a single-part message

Specified by:
getContentType in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String
Throws:
NestedException
See Also:
Reader.getContentType(int)

getDisposition

public java.lang.String getDisposition(int msgIndex,
                                       int partIndex)
                                throws NestedException
Description copied from interface: Reader
Get the content of the disposition header of a part of a multi-part message

Specified by:
getDisposition in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
partIndex - A number from 0 to getMultiPartCount()-1
Returns:
String
Throws:
NestedException
See Also:
Reader.getDisposition(int, int)

getDisposition

public java.lang.String getDisposition(int msgIndex)
                                throws NestedException
Description copied from interface: Reader
Get the content of the disposition header of a single-part message

Specified by:
getDisposition in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String
Throws:
NestedException
See Also:
Reader.getDisposition(int)

getFile

public java.io.File getFile(int msgIndex,
                            int partIndex)
                     throws NestedException
Description copied from interface: Reader
Get the contents of a particular part of a multi-part message

Specified by:
getFile in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
partIndex - A number from 0 to getMultiPartCount()-1
Returns:
File
Throws:
NestedException
See Also:
Reader.getFile(int, int)

getFile

public java.io.File getFile(int msgIndex)
                     throws NestedException
Description copied from interface: Reader
Get the contents of a single-part message

Specified by:
getFile in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
File
Throws:
NestedException
See Also:
Reader.getFile(int)

getFileName

public java.lang.String getFileName(int msgIndex,
                                    int partIndex)
                             throws NestedException
Description copied from interface: Reader
Get the file name in the header of a part in the multi-part message

Specified by:
getFileName in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
partIndex - A number from 0 to getMultiPartCount()-1
Returns:
String
Throws:
NestedException
See Also:
Reader.getFileName(int, int)

getFileName

public java.lang.String getFileName(int msgIndex)
                             throws NestedException
Description copied from interface: Reader
Get the file name in the header of a single-part message

Specified by:
getFileName in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String
Throws:
NestedException
See Also:
Reader.getFileName(int)

getMultiPartCount

public int getMultiPartCount(int msgIndex)
                      throws NestedException
Description copied from interface: Reader
Get the number of parts in a multi-part message

Specified by:
getMultiPartCount in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
int The number of parts in the message
Throws:
NestedException
See Also:
Reader.getMultiPartCount(int)

isMultiPart

public boolean isMultiPart(int msgIndex)
                    throws NestedException
Description copied from interface: Reader
Check if the message content is formatted as MIME multi-part

Specified by:
isMultiPart in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if multipart
Throws:
NestedException
See Also:
Reader.isMultiPart(int)

isSinglePart

public boolean isSinglePart(int msgIndex)
                     throws NestedException
Description copied from interface: Reader
Check if the message content is formatted as MIME single-part

Specified by:
isSinglePart in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if single-part
Throws:
NestedException
See Also:
Reader.isSinglePart(int)

isInline

public boolean isInline(int msgIndex)
                 throws NestedException
Description copied from interface: Reader
Check if the message content is inline

Specified by:
isInline in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if inline
Throws:
NestedException
See Also:
Reader.isInline(int)

getInline

public java.lang.String getInline(int msgIndex)
                           throws NestedException
Description copied from interface: Reader
Get the content of an inline message

Specified by:
getInline in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
String
Throws:
NestedException
See Also:
Reader.getInline(int)

isAnswered

public boolean isAnswered(int msgIndex)
                   throws NestedException
Description copied from interface: Reader
Check if this message has been marked as "answered" by a client

Specified by:
isAnswered in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if answered
Throws:
NestedException
See Also:
Reader.isAnswered(int)

isDeleted

public boolean isDeleted(int msgIndex)
                  throws NestedException
Description copied from interface: Reader
Check if this message has been marked by a client as "deleted" or not

Specified by:
isDeleted in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if deleted
Throws:
NestedException
See Also:
Reader.isDeleted(int)

isDraft

public boolean isDraft(int msgIndex)
                throws NestedException
Description copied from interface: Reader
Check if this message has been marked by some client as "draft" or not

Specified by:
isDraft in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if draft
Throws:
NestedException
See Also:
Reader.isDraft(int)

isFlagged

public boolean isFlagged(int msgIndex)
                  throws NestedException
Description copied from interface: Reader
Check if this message has been marked by a client as "flagged"

Specified by:
isFlagged in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if flagged
Throws:
NestedException
See Also:
Reader.isFlagged(int)

isRecent

public boolean isRecent(int msgIndex)
                 throws NestedException
Description copied from interface: Reader
Check if this message is amrked by the server as "recent" or not

Specified by:
isRecent in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if recent
Throws:
NestedException
See Also:
Reader.isRecent(int)

isSeen

public boolean isSeen(int msgIndex)
               throws NestedException
Description copied from interface: Reader
Check if this message has already been read or not

Specified by:
isSeen in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
Returns:
boolean true if already read
Throws:
NestedException
See Also:
Reader.isSeen(int)

setAnswered

public void setAnswered(int msgIndex,
                        boolean state)
                 throws NestedException
Description copied from interface: Reader
Mark a message as "answered"

Specified by:
setAnswered in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
state - true=set, false=clear
Throws:
NestedException
See Also:
org.keel.services.mail.Reader#setAnswered(int)

setDeleted

public void setDeleted(int msgIndex,
                       boolean state)
                throws NestedException
Description copied from interface: Reader
Mark a message as "deleted"

Specified by:
setDeleted in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
state - true=set, false=clear
Throws:
NestedException
See Also:
org.keel.services.mail.Reader#setDeleted(int)

setDraft

public void setDraft(int msgIndex,
                     boolean state)
              throws NestedException
Description copied from interface: Reader
Mark a message as "draft

Specified by:
setDraft in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
state - true=set, false=clear
Throws:
NestedException
See Also:
org.keel.services.mail.Reader#setDraft(int)

setFlagged

public void setFlagged(int msgIndex,
                       boolean state)
                throws NestedException
Description copied from interface: Reader
Mark a message as "flagged

Specified by:
setFlagged in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
state - true=set, false=clear
Throws:
NestedException
See Also:
org.keel.services.mail.Reader#setFlagged(int)

setSeen

public void setSeen(int msgIndex,
                    boolean state)
             throws NestedException
Description copied from interface: Reader
Mark a message as "read"

Specified by:
setSeen in interface Reader
Parameters:
msgIndex - A number from 0 to count()-1
state - true=set, false=clear
Throws:
NestedException
See Also:
org.keel.services.mail.Reader#setSeen(int)

matchFlag

private boolean matchFlag(int msgIndex,
                          Flags.Flag flag)
                   throws NestedException
Convenience method to retrieve flags from a particular message and then to check if a particular flag is set.

Parameters:
msgIndex - The message number from 0 to count()-1
flag - The particular flag to check
Returns:
boolean true=set or false=clear
Throws:
NestedException

setFlag

private void setFlag(int msgIndex,
                     Flags.Flag flag,
                     boolean state)
              throws NestedException
Convenience method to set a flasg in a message NOTE: The connection must have been opened in READ/WRITE mode. NOTE: If the "deleted" flag is set, the messages aren't actually deleted until the folder is closed with the folderExpunge configuration parameter set to true.

Parameters:
msgIndex -
flag -
state -
Throws:
NestedException

getHeader

private java.util.Enumeration getHeader(int msgIndex,
                                        java.lang.String str)
                                 throws NestedException
Convenience method to take the string arg and make an array out of it before calling the JavaMail method

Parameters:
msgIndex -
Returns:
String
Throws:
NestedException

checkMsgIndex

private void checkMsgIndex(int msgIndex)
                    throws NestedException
Convenience method to bounds-check the emssage index.

Parameters:
msgIndex -
Throws:
NestedException

getBodyPart

private Part getBodyPart(int msgIndex)
                  throws NestedException
Method to extract the body of a single-part message

Parameters:
msgIndex -
Returns:
Part
Throws:
NestedException

getOneBodyPart

private Part getOneBodyPart(int msgIndex,
                            int partIndex)
                     throws NestedException
Method to get a particular part of a multi-part message

Parameters:
msgIndex -
partIndex -
Returns:
Part
Throws:
NestedException

addrToString

private java.lang.String[] addrToString(Address[] addr)
Method to convert an array of javax.mail.Address to an array of Strings

Parameters:
addr -
Returns:
String[]

createFile

private java.io.File createFile(Part p)
                         throws NestedException
Take the content of a message-part and put it in a file.

Parameters:
p -
Returns:
File
Throws:
NestedException

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.