com.knowgate.hipermail
Class DBMimeMessage

java.lang.Object
  extended by MimeMessage
      extended by com.knowgate.hipermail.DBMimeMessage

public class DBMimeMessage
extends MimeMessage

MIME messages stored at database BLOB columns or MBOX files


Field Summary
static short ClassId
           
 
Constructor Summary
DBMimeMessage(Folder oFldr, DBMimeMessage oMsg)
          Create DBMimeMessage from another DBMimeMessage GUID of this message is set to be the same as that of oMsg
DBMimeMessage(Folder oFldr, java.io.InputStream oInStrm)
          Create DBMimeMessage from an InputStream, set folder and assign a new GUID
DBMimeMessage(Folder oFldr, MimeMessage oMsg)
          Create DBMimeMessage from a MimeMessage, set folder and assign a new GUID
DBMimeMessage(Folder oFldr, java.lang.String sMsgGuid)
          Create empty message at the given folder
DBMimeMessage(MimeMessage oMsg)
          Create DBMimeMessage from a MimeMessage and assign a new GUID
DBMimeMessage(Session oMailSession)
          Create an empty message
DBMimeMessage(Session oMailSession, java.io.InputStream oInStrm)
          Create DBMimeMessage from an InputStream and assign a new GUID
 
Method Summary
 SMTPMessage composeFinalMessage(Session oMailSession, java.lang.String sSubject, java.lang.String sBody, java.lang.String sId, java.lang.String sContentType)
          Create an SMTPMessage object from given components using UTF-8 for text encoding Depending on what is inside, message structure is as follows :
Format/AttachmentsNoYes plaintext/plainmultipart/mixed [text/plain, {attachment}] html without imagesmultipart/alternative [text/plain, text/html]multipart/mixed [multipart/alternative [text/plain, text/html], {attachment}] html with imagesmultipart/alternative [text/plain, multipart/related[text/html, {image}]]multipart/mixed [multipart/alternative [text/plain, multipart/related[text/html, {image}]], {attachment}]
 SMTPMessage composeFinalMessage(Session oMailSession, java.lang.String sSubject, java.lang.String sBody, java.lang.String sId, java.lang.String sContentType, java.lang.String sEncoding)
          Create an SMTPMessage object from given components Depending on what is inside, message structure is as follows :
Format/AttachmentsNoYes plaintext/plainmultipart/mixed [text/plain, {attachment}] html without imagesmultipart/alternative [text/plain, text/html]multipart/mixed [multipart/alternative [text/plain, text/html], {attachment}] html with imagesmultipart/alternative [text/plain, multipart/related[text/html, {image}]]multipart/mixed [multipart/alternative [text/plain, multipart/related[text/html, {image}]], {attachment}]
 SMTPMessage composeFinalMessage(Session oMailSession, java.lang.String sSubject, java.lang.String sBody, java.lang.String sId, java.lang.String sContentType, java.lang.String sEncoding, boolean bAttachInlineImages)
          Create an SMTPMessage object from given components Depending on what is inside, message structure is as follows :
Format/AttachmentsNoYes plaintext/plainmultipart/mixed [text/plain, {attachment}] html without imagesmultipart/alternative [text/plain, text/html]multipart/mixed [multipart/alternative [text/plain, text/html], {attachment}] html with imagesmultipart/alternative [text/plain, multipart/related[text/html, {image}]]multipart/mixed [multipart/alternative [text/plain, multipart/related[text/html, {image}]], {attachment}]
static void delete(JDCConnection oConn, java.lang.String sFolderId, java.lang.String sMimeMsgId)
          Delete message from database This method calls stored procedure k_sp_del_mime_msg
 Address[] getAllRecipients()
          Get message recipients This method read recipients from a message stored at k_inet_addrs table or if message is not already stored at k_inet_addrs then it delegates behaviour to parent class MimMessage.getAllRecipients()
 MimePart getBody()
           
 java.lang.String getContentType()
           
 Flags getFlags()
          Get message flags Message flags are readed from k_mime_msgs table at the database
 Folder getFolder()
          Get message folder
 DBInetAddr getFromRecipient()
           
static java.lang.String getGuidFromId(JDCConnection oConn, java.lang.String sMsgId)
           
 MimePart getMessageBody()
           
 java.lang.String getMessageGuid()
          Get message GUID If message had no previous GUID then a new one is assigned
 Multipart getParts()
          Get message parts as an array of DBMimePart objects
 Address[] getRecipients(Message.RecipientType cTpRecipient)
          Get recipients of a particular type This method first calls getAllRecipients() and then filters retrieved recipients by their type.
 java.util.Date getSentDate()
           
 java.lang.String getSubject()
           
 java.lang.String getText()
           
 void getText(java.lang.StringBuffer oBuffer)
          Get message body text into a StringBuffer
 void getTextPlain(java.lang.StringBuffer oBuffer)
           
 void saveChanges()
           
 void setFlag(Flags.Flag oFlg, boolean bFlg)
           
 void setFolder(Folder oFldr)
          Set message folder
 void setMessageGuid(java.lang.String sId)
          Set message GUID
static java.lang.String source(MimeMessage oMsg, java.lang.String sEncoding)
           
 java.lang.String tagBodyHtml()
           
 java.lang.String tagBodyPlain()
           
 void writeTo(java.io.OutputStream oOutStrm)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ClassId

public static final short ClassId
See Also:
Constant Field Values
Constructor Detail

DBMimeMessage

public DBMimeMessage(Session oMailSession)
Create an empty message

Parameters:
oMailSession -

DBMimeMessage

public DBMimeMessage(MimeMessage oMsg)
              throws MessagingException
Create DBMimeMessage from a MimeMessage and assign a new GUID

Parameters:
oMsg - MimeMessage
Throws:
MessagingException

DBMimeMessage

public DBMimeMessage(Session oMailSession,
                     java.io.InputStream oInStrm)
              throws MessagingException
Create DBMimeMessage from an InputStream and assign a new GUID

Parameters:
oMailSession - Session
oInStrm - InputStream
Throws:
MessagingException

DBMimeMessage

public DBMimeMessage(Folder oFldr,
                     java.io.InputStream oInStrm)
              throws MessagingException,
                     java.lang.ClassCastException
Create DBMimeMessage from an InputStream, set folder and assign a new GUID

Parameters:
Folder - oFldr
oInStrm - InputStream
Throws:
MessagingException
java.lang.ClassCastException

DBMimeMessage

public DBMimeMessage(Folder oFldr,
                     MimeMessage oMsg)
              throws MessagingException
Create DBMimeMessage from a MimeMessage, set folder and assign a new GUID

Parameters:
oFldr - Folder
MimeMessage - oMsg
Throws:
MessagingException

DBMimeMessage

public DBMimeMessage(Folder oFldr,
                     DBMimeMessage oMsg)
              throws MessagingException

Create DBMimeMessage from another DBMimeMessage

GUID of this message is set to be the same as that of oMsg

Parameters:
oFldr - Folder
MimeMessage - oMsg
Throws:
MessagingException

DBMimeMessage

public DBMimeMessage(Folder oFldr,
                     java.lang.String sMsgGuid)
              throws MessagingException
Create empty message at the given folder

Parameters:
oFldr - Folder
sMsgGuid - String Message GUID
Throws:
MessagingException
Method Detail

getFolder

public Folder getFolder()
Get message folder

Returns:
Folder

setFolder

public void setFolder(Folder oFldr)
Set message folder

Parameters:
oFldr - Folder

getMessageGuid

public java.lang.String getMessageGuid()

Get message GUID

If message had no previous GUID then a new one is assigned

Returns:
String

setMessageGuid

public void setMessageGuid(java.lang.String sId)
Set message GUID

Parameters:
sId - String

getFlags

public Flags getFlags()
               throws MessagingException

Get message flags

Message flags are readed from k_mime_msgs table at the database

Returns:
Flags
Throws:
MessagingException

getAllRecipients

public Address[] getAllRecipients()
                           throws MessagingException,
                                  java.lang.NullPointerException,
                                  java.lang.IllegalArgumentException

Get message recipients

This method read recipients from a message stored at k_inet_addrs table or if message is not already stored at k_inet_addrs then it delegates behaviour to parent class MimMessage.getAllRecipients()

Returns:
If this message is stored at the database then this method returns an array of DBInetAddr objects. If this message has not been stored yet then this method returns an array of javax.mail.internet.InternetAddress objects
Throws:
java.sql.SQLException
MessagingException
java.lang.NullPointerException
java.lang.IllegalArgumentException

getRecipients

public Address[] getRecipients(Message.RecipientType cTpRecipient)
                        throws MessagingException

Get recipients of a particular type

This method first calls getAllRecipients() and then filters retrieved recipients by their type.

Parameters:
cTpRecipient - javax.mail.Message.RecipientType
Returns:
Address[]
Throws:
MessagingException

getFromRecipient

public DBInetAddr getFromRecipient()
                            throws MessagingException
Throws:
MessagingException

getContentType

public java.lang.String getContentType()
                                throws MessagingException
Throws:
MessagingException

getSentDate

public java.util.Date getSentDate()
                           throws MessagingException
Throws:
MessagingException

getSubject

public java.lang.String getSubject()
                            throws MessagingException
Throws:
MessagingException

getMessageBody

public MimePart getMessageBody()
                        throws ParseException,
                               MessagingException,
                               java.io.IOException
Throws:
ParseException
MessagingException
java.io.IOException

setFlag

public void setFlag(Flags.Flag oFlg,
                    boolean bFlg)
             throws MessagingException
Throws:
MessagingException

saveChanges

public void saveChanges()
                 throws MessagingException
Throws:
MessagingException

getParts

public Multipart getParts()
                   throws MessagingException,
                          java.io.IOException,
                          java.lang.NullPointerException
Get message parts as an array of DBMimePart objects

Returns:
DBMimeMultiPart if this message folder is of type DBFolder or another type of Object if this message folder is another subclass of javax.mail.Folder such as POP3Folder.
Throws:
MessagingException
java.io.IOException
java.lang.NullPointerException - If this message Folder is null

getBody

public MimePart getBody()
                 throws ParseException,
                        MessagingException,
                        java.io.IOException
Throws:
ParseException
MessagingException
java.io.IOException

getText

public void getText(java.lang.StringBuffer oBuffer)
             throws MessagingException,
                    java.io.IOException,
                    java.lang.ClassCastException
Get message body text into a StringBuffer

Parameters:
oBuffer - StringBuffer
Throws:
MessagingException
java.io.IOException
java.lang.ClassCastException

getText

public java.lang.String getText()
                         throws MessagingException,
                                java.io.IOException
Throws:
MessagingException
java.io.IOException

getTextPlain

public void getTextPlain(java.lang.StringBuffer oBuffer)
                  throws MessagingException,
                         java.io.IOException
Throws:
MessagingException
java.io.IOException

writeTo

public void writeTo(java.io.OutputStream oOutStrm)
             throws java.io.IOException,
                    FolderClosedException,
                    MessagingException
Throws:
java.io.IOException
FolderClosedException
MessagingException

tagBodyHtml

public java.lang.String tagBodyHtml()
                             throws java.io.IOException,
                                    javax.mail.MessagingException
Throws:
java.io.IOException
javax.mail.MessagingException

tagBodyPlain

public java.lang.String tagBodyPlain()
                              throws java.io.IOException,
                                     javax.mail.MessagingException
Throws:
java.io.IOException
javax.mail.MessagingException

composeFinalMessage

public SMTPMessage composeFinalMessage(Session oMailSession,
                                       java.lang.String sSubject,
                                       java.lang.String sBody,
                                       java.lang.String sId,
                                       java.lang.String sContentType,
                                       java.lang.String sEncoding,
                                       boolean bAttachInlineImages)
                                throws java.io.IOException,
                                       MessagingException,
                                       java.lang.IllegalArgumentException,
                                       java.lang.ArrayIndexOutOfBoundsException,
                                       java.lang.SecurityException

Create an SMTPMessage object from given components

Depending on what is inside, message structure is as follows :
Format/AttachmentsNoYes
plaintext/plainmultipart/mixed [text/plain, {attachment}]
html without imagesmultipart/alternative [text/plain, text/html]multipart/mixed [multipart/alternative [text/plain, text/html], {attachment}]
html with imagesmultipart/alternative [text/plain, multipart/related[text/html, {image}]]multipart/mixed [multipart/alternative [text/plain, multipart/related[text/html, {image}]], {attachment}]

Parameters:
oMailSession - Session
sSubject - String Message subject or null
sBody - String Message text body or null
sId - String Contend-ID for message or null
sContentType - String should be either "plain" or "html"
sEncoding - Character encoding for text
Returns:
SMTPMessage
Throws:
java.io.IOException
MessagingException
java.lang.SecurityException
java.lang.ArrayIndexOutOfBoundsException
java.lang.IllegalArgumentException - if sContentType is not "plain" or "html"

composeFinalMessage

public SMTPMessage composeFinalMessage(Session oMailSession,
                                       java.lang.String sSubject,
                                       java.lang.String sBody,
                                       java.lang.String sId,
                                       java.lang.String sContentType,
                                       java.lang.String sEncoding)
                                throws java.io.IOException,
                                       MessagingException,
                                       java.lang.IllegalArgumentException,
                                       java.lang.SecurityException

Create an SMTPMessage object from given components

Depending on what is inside, message structure is as follows :
Format/AttachmentsNoYes
plaintext/plainmultipart/mixed [text/plain, {attachment}]
html without imagesmultipart/alternative [text/plain, text/html]multipart/mixed [multipart/alternative [text/plain, text/html], {attachment}]
html with imagesmultipart/alternative [text/plain, multipart/related[text/html, {image}]]multipart/mixed [multipart/alternative [text/plain, multipart/related[text/html, {image}]], {attachment}]

Parameters:
oMailSession - Session
sSubject - String Message subject or null
sBody - String Message text body or null
sId - String Contend-ID for message or null
sContentType - String should be either "plain" or "html"
sEncoding - Character encoding for text
Returns:
SMTPMessage
Throws:
java.io.IOException
MessagingException
java.lang.SecurityException
java.lang.IllegalArgumentException - if sContentType is not "plain" or "html"

composeFinalMessage

public SMTPMessage composeFinalMessage(Session oMailSession,
                                       java.lang.String sSubject,
                                       java.lang.String sBody,
                                       java.lang.String sId,
                                       java.lang.String sContentType)
                                throws java.io.IOException,
                                       MessagingException,
                                       java.lang.IllegalArgumentException,
                                       java.lang.SecurityException

Create an SMTPMessage object from given components using UTF-8 for text encoding

Depending on what is inside, message structure is as follows :
Format/AttachmentsNoYes
plaintext/plainmultipart/mixed [text/plain, {attachment}]
html without imagesmultipart/alternative [text/plain, text/html]multipart/mixed [multipart/alternative [text/plain, text/html], {attachment}]
html with imagesmultipart/alternative [text/plain, multipart/related[text/html, {image}]]multipart/mixed [multipart/alternative [text/plain, multipart/related[text/html, {image}]], {attachment}]

Parameters:
oMailSession - Session
sSubject - String Message subject or null
sBody - String Message text body or null
sId - String Contend-ID for message or null
sContentType - String should be either "plain" or "html"
Returns:
SMTPMessage
Throws:
java.io.IOException
MessagingException
java.lang.SecurityException
java.lang.IllegalArgumentException - if sContentType is not "plain" or "html"

delete

public static void delete(JDCConnection oConn,
                          java.lang.String sFolderId,
                          java.lang.String sMimeMsgId)
                   throws java.sql.SQLException,
                          java.io.IOException

Delete message from database

This method calls stored procedure k_sp_del_mime_msg

Parameters:
oConn - JDBC database connection
sFolderId - Folder GUID (k_mime_msgs.gu_category)
sMimeMsgId - Message GUID (k_mime_msgs.gu_mimemsg)
Throws:
java.sql.SQLException
java.io.IOException

source

public static java.lang.String source(MimeMessage oMsg,
                                      java.lang.String sEncoding)
                               throws MessagingException,
                                      java.io.UnsupportedEncodingException,
                                      java.io.IOException
Throws:
MessagingException
java.io.UnsupportedEncodingException
java.io.IOException

getGuidFromId

public static java.lang.String getGuidFromId(JDCConnection oConn,
                                             java.lang.String sMsgId)
                                      throws java.sql.SQLException
Throws:
java.sql.SQLException