|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rakeshv.mail.WriteFormParser
public class WriteFormParser
This class parses the HttpServletRequest generated by
the write.jsp HTML form encoded as
multipart/form-data. Any attachments included in the
form that was POSTed are converted to
BodyPart objects, and stored in a List
(attachments).
Copyright 2003 Rakesh Vidyadharan
| Field Summary | |
|---|---|
private java.util.List |
attachments
The List in which extracted attachments will be
stored. |
private java.lang.String |
bcc
A String object that holds the email address(es) to
which the new message being sent is to be blind carbon
copied (bcc). |
private java.lang.String |
body
A String object that holds the text body for the
new message being composed. |
private java.lang.String |
cc
A String object that holds the email address(es) to
which the new message being sent is to be copied (cc). |
private java.lang.String |
command
A String object that holds the hidden form variable
that specifies the type of action being performed
(send). |
private java.lang.String |
forward
The message number in the IMAP store
which is to be forwarded along with any additional text and
attachments. |
private java.lang.String |
from
A String object that holds the email address of the
person who is composing the message. |
private java.util.List |
groups
A List to hold groups from the addressbook that
were selected in the groups select list in the
write form. |
private int |
pageNumber
An integer that holds the value of the pageNumber URL query
string. |
private java.util.List |
persons
A List to hold people from the addressbook that
were selected in the persons select list in the
write form. |
private java.lang.String |
reply
The message number in the IMAP store to
which the current message being composed is a reply to. |
private javax.servlet.http.HttpServletRequest |
request
A reference to the HttpServletRequest object from
which the attachments are to be extracted. |
private java.lang.String |
subject
A String object that holds the subject line for the
new message being composed. |
private java.lang.String |
to
A String object that holds the email address(es) to
which the new message is to be sent. |
| Constructor Summary | |
|---|---|
protected |
WriteFormParser()
Default constructor. |
|
WriteFormParser(javax.servlet.http.HttpServletRequest request)
The only constructor supported. |
| Method Summary | |
|---|---|
private void |
extractAttachment(javax.servlet.ServletInputStream in,
java.lang.String boundary,
java.lang.String fileName,
java.lang.String contentType)
Extracts the contents of the file encoded in the multipart/
form-data request. |
private java.lang.String |
extractBoundary()
Extracts and returns the boundary token from the HTTP request header ( request). |
private java.lang.String[] |
extractContentDisposition(java.lang.String line)
Extract the contents of the Content-Disposition
headers that succeed a boundary delimiter in the
request stream. |
private java.lang.String |
extractContentType(java.lang.String line)
Extract the Content-Type header that succeeds the
Content-Disposition header separating a part in
the multipart HTTP request. |
java.util.List |
getAttachments()
Returns attachments. |
java.lang.String |
getBcc()
Returns bcc. |
java.lang.String |
getBody()
Returns body. |
java.lang.String |
getCc()
Returns cc. |
java.lang.String |
getCommand()
Returns command. |
java.lang.String |
getForward()
Returns forward. |
java.lang.String |
getFrom()
Returns from. |
java.util.List |
getGroups()
Returns groups. |
int |
getPageNumber()
Returns pageNumber. |
java.util.List |
getPersons()
Returns persons. |
java.lang.String |
getReply()
Returns reply. |
java.lang.String |
getSubject()
Returns subject. |
java.lang.String |
getTo()
Returns to. |
private void |
parseFormData()
Processes the parts included in the multipart/form-data
request. |
private java.lang.String |
readLine(javax.servlet.ServletInputStream in)
Reads a line from the ServletInputStream using the
ServletInputStream.readLine method. |
java.lang.String |
toString()
Over-ridden form of the toString method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private java.util.List attachments
List in which extracted attachments will be
stored. The attachments in the List will be objects
of type javax.mail.internet.MimeBodyPart.
private java.util.List persons
List to hold people from the addressbook that
were selected in the persons select list in the
write form.
private java.util.List groups
List to hold groups from the addressbook that
were selected in the groups select list in the
write form.
private java.lang.String from
String object that holds the email address of the
person who is composing the message. This field holds the contents
of the from form element.
private java.lang.String to
String object that holds the email address(es) to
which the new message is to be sent. This field holds the
contents of the to form element.
private java.lang.String cc
String object that holds the email address(es) to
which the new message being sent is to be copied (cc).
This field holds the contents of the cc form element.
private java.lang.String bcc
String object that holds the email address(es) to
which the new message being sent is to be blind carbon
copied (bcc). This field holds the contents of the
bcc form element.
private java.lang.String subject
String object that holds the subject line for the
new message being composed. This field holds the contents of the
subject form element.
private java.lang.String body
String object that holds the text body for the
new message being composed. This field holds the contents of the
body form element.
private java.lang.String reply
message number in the IMAP store to
which the current message being composed is a reply to. This
field holds the contents of the reply hidden form
element.
private java.lang.String forward
message number in the IMAP store
which is to be forwarded along with any additional text and
attachments. This field holds the contents of the
forward hidden form element.
private java.lang.String command
String object that holds the hidden form variable
that specifies the type of action being performed
(send). This field holds the contents of the
command hidden form element.
private int pageNumber
pageNumber URL query
string.
private javax.servlet.http.HttpServletRequest request
HttpServletRequest object from
which the attachments are to be extracted.
| Constructor Detail |
|---|
protected WriteFormParser()
public WriteFormParser(javax.servlet.http.HttpServletRequest request)
throws java.io.IOException,
javax.mail.MessagingException
HttpServletRequest
object.
request - - The HttpServletRequest from
which to extract attachments.
java.io.IOException - - If errors are encountered while parsing
the form elements out of the request.
javax.mail.MessagingException - - If errors are encountered while
converting the form attachments into BodyPart
objects.parseFormData()| Method Detail |
|---|
private void parseFormData()
throws java.io.IOException,
javax.mail.MessagingException
multipart/form-data
request. Parses the ServletInputStream associated
with the request and extracts all the form elements included in
the write.jsp form. Use the accessor methods to
fetch the parsed out parts and attributes of the email message
being composed.
java.io.IOException - - If errors are encountered while parsing
the form elements out of the request.
javax.mail.MessagingException - - If errors are encountered while
converting the form attachments into BodyPart
objects.private java.lang.String extractBoundary()
request). Look for the header
Content-Type or content-type. Java
Application Servers seem to convert Content-Type
to content-type.
private java.lang.String readLine(javax.servlet.ServletInputStream in)
throws java.io.IOException
ServletInputStream using the
ServletInputStream.readLine method. Fills a
temporary byte buffer with the results of the call
to ServletInputStream.readLine, converts it into a
String, and adds that to a StringBuffer.
The contents of the StringBuffer are returned.
Note: - This method strips out the trailing new line
characters which the ServletInputStream.readLine
method returns at the end of the line. Calling classes will
need to add new line characters as appropriate.
in - - The ServletInputStream from which
to extact a line of text.
java.io.IOException - - If errors are encountered while reading
from the input stream.private java.lang.String[] extractContentDisposition(java.lang.String line)
Content-Disposition
headers that succeed a boundary delimiter in the
request stream. The header contains information about the
name of the form element, any filename associated if a file
was being uploaded etc.
line - - The line of text that was read from the
SerlvetInputStream.
private java.lang.String extractContentType(java.lang.String line)
Content-Type header that succeeds the
Content-Disposition header separating a part in
the multipart HTTP request.
line - - The line of text read from the
ServletInputStream from which the content type is to be
extracted.
private void extractAttachment(javax.servlet.ServletInputStream in,
java.lang.String boundary,
java.lang.String fileName,
java.lang.String contentType)
throws java.io.IOException,
javax.mail.MessagingException
multipart/
form-data request. This method extracts the attachment
contents and creates BodyPart objects
with them. The extracted BodyPart objects are added
to the attachments List.
in - - The InputStream from which the
contents of the file being uploaded is to be extracted.boundary - - The boundary token with which the
various parts of the form data are delimited.fileName - - The filename that was used by the
client making the file upload.contentType - - The content-type indicated by the
client/browser making the file upload.
java.io.IOException - - Any errors encountered while reading the
contents from the ServletInputStream.
javax.mail.MessagingException - - If any errors are encountered while
creating the BodyPart.public java.lang.String toString()
multipart request.
toString in class java.lang.Objectpublic final java.util.List getAttachments()
attachments.
public final java.util.List getPersons()
persons.
public final java.util.List getGroups()
groups.
public final java.lang.String getFrom()
from.
public final java.lang.String getTo()
to.
public final java.lang.String getCc()
cc.
public final java.lang.String getBcc()
bcc.
public final java.lang.String getSubject()
subject.
public final java.lang.String getBody()
body.
public final java.lang.String getReply()
reply.
public final java.lang.String getForward()
forward.
public final java.lang.String getCommand()
command.
public final int getPageNumber()
pageNumber.
|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||