com.knowgate.hipermail
Class DBFolder

java.lang.Object
  extended byjavax.mail.Folder
      extended bycom.knowgate.hipermail.DBFolder

public class DBFolder
extends javax.mail.Folder

A subclass of javax.mail.Folder providing storage for MimeMessages at database LONGVARBINARY columns and MBOX files.

Folders are also a subclass of com.knowgate.hipergate.Category
Category behaviour is obtained by delegation to a private Category instance.
For each DBFolder there is a corresponding row at k_categories database table.

Version:
3.0

Field Summary
static short ClassId
           
static int MODE_BLOB
           
static int MODE_MBOX
           
 
Fields inherited from class javax.mail.Folder
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store
 
Constructor Summary
protected DBFolder(javax.mail.Store oStor, java.lang.String sName)
           
 
Method Summary
 java.lang.String appendMessage(javax.mail.internet.MimeMessage oMsg)
           
 void appendMessages(javax.mail.Message[] msgs)
          Append messages to this DBFolder
 void close(boolean expunge)
          Close this folder
 java.lang.String copyMessage(DBMimeMessage oSrcMsg)
          Copy a DBMimeMessage from another DBFolder to this DBFolder
 boolean create(int type)
          This method is not implemented and will always raise UnsupportedOperationException
 boolean create(java.lang.String sFolderName)
          Create DBFolder with given name under current user mailroot Category
 boolean delete(boolean recurse)
          Wipe all messages and delete this folder
 boolean exists()
           
 javax.mail.Message[] expunge()
          Expunge deleted messages
 Category getCategory()
          Get instance of com.knowgate.hipergate.Category object
 java.lang.String getCategoryGuid()
          Get Category GUID
protected  JDCConnection getConnection()
           
 java.lang.String getDirectoryPath()
          Get path to directory containing files belonging to this folder
 java.io.File getFile()
          Get MBOX file that holds messages for this DBFolder
 java.lang.String getFilePath()
          Get full path to MBOX file containing mime messages
 javax.mail.Folder getFolder(java.lang.String name)
          Get folder by name or GUID
 java.lang.String getFullName()
          Get category subpath to directory holding MBOX files for this folder
 javax.mail.Message getMessage(int msgnum)
           
protected  javax.mail.Message getMessage(java.lang.String sMsgId, int IdType)
           
 DBMimeMessage getMessageByGuid(java.lang.String sMsgGuid)
           
 DBMimeMessage getMessageByID(java.lang.String sMsgGuid)
           
 int getMessageCount()
           
 java.util.Properties getMessageHeaders(java.lang.String sMsgId)
          Get message GUID, Id, Number, Subject, From and Reply-To from k_mime_msgs table
 java.lang.String getName()
          Get column nm_category from table k_categories for this folder
 javax.mail.Folder getParent()
           
 javax.mail.Flags getPermanentFlags()
           
 char getSeparator()
           
 int getType()
           
 javax.mail.URLName getURLName()
           
 boolean hasNewMessages()
          This method is not implemented and will always raise UnsupportedOperationException
 int importMbox(java.lang.String sMboxFilePath)
           
 boolean isOpen()
           
 DBKeySet keySet()
          Get set of identifiers for messages at this folder
 javax.mail.Folder[] list(java.lang.String pattern)
           
 void moveMessage(DBMimeMessage oSrcMsg)
          Move a DBMimeMessage from another DBFolder to this DBFolder
 void open(int mode)
          Open this DBFolder
 void reindexMbox()
          Delete very message from th eindex and rebuild it by reading the default MBOX file for this folder
 void reindexMbox(java.lang.String sMboxFilePath)
          Delete every message from the index and rebuild it by re-reading the specified MBOX file
 boolean renameTo(javax.mail.Folder f)
           
 void wipe()
          Delete all messages from this folder and clear MBOX file
 
Methods inherited from class javax.mail.Folder
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, fetch, finalize, getMessages, getMessages, getMessages, getMode, getNewMessageCount, getStore, getUnreadMessageCount, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MODE_MBOX

public static final int MODE_MBOX
See Also:
Constant Field Values

MODE_BLOB

public static final int MODE_BLOB
See Also:
Constant Field Values

ClassId

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

DBFolder

protected DBFolder(javax.mail.Store oStor,
                   java.lang.String sName)
Method Detail

getConnection

protected JDCConnection getConnection()

getCategory

public Category getCategory()
Get instance of com.knowgate.hipergate.Category object


getCategoryGuid

public java.lang.String getCategoryGuid()

Get Category GUID

Each folder has a Global Unique Identifier which is stored at column gu_category of table k_categories

Returns:
String Category GUID or null if category is not set

keySet

public DBKeySet keySet()
                throws java.sql.SQLException

Get set of identifiers for messages at this folder

Set entries are the mime identifiers for each message

Returns:
DBKeySet
Throws:
java.sql.SQLException

appendMessages

public void appendMessages(javax.mail.Message[] msgs)
                    throws javax.mail.MessagingException,
                           java.lang.ArrayIndexOutOfBoundsException
Append messages to this DBFolder

Parameters:
msgs - Array of mime messages to be appended
Throws:
javax.mail.MessagingException
java.lang.ArrayIndexOutOfBoundsException

copyMessage

public java.lang.String copyMessage(DBMimeMessage oSrcMsg)
                             throws javax.mail.MessagingException
Copy a DBMimeMessage from another DBFolder to this DBFolder

Parameters:
oSrcMsg - Source message.
Returns:
GUID of new message
Throws:
javax.mail.MessagingException

moveMessage

public void moveMessage(DBMimeMessage oSrcMsg)
                 throws javax.mail.MessagingException
Move a DBMimeMessage from another DBFolder to this DBFolder

Parameters:
oSrcMsg - Source message
Throws:
javax.mail.MessagingException

create

public boolean create(int type)
               throws javax.mail.MessagingException
This method is not implemented and will always raise UnsupportedOperationException

Throws:
java.lang.UnsupportedOperationException
javax.mail.MessagingException

create

public boolean create(java.lang.String sFolderName)
               throws javax.mail.MessagingException
Create DBFolder with given name under current user mailroot Category

Parameters:
sFolderName - Folder Name
Returns:
true
Throws:
javax.mail.MessagingException

open

public void open(int mode)
          throws javax.mail.MessagingException
Open this DBFolder

Parameters:
mode - {READ_ONLY|READ_WRITE}
Throws:
javax.mail.MessagingException

close

public void close(boolean expunge)
           throws javax.mail.MessagingException
Close this folder

Parameters:
expunge -
Throws:
javax.mail.MessagingException

delete

public boolean delete(boolean recurse)
               throws javax.mail.MessagingException
Wipe all messages and delete this folder

Parameters:
recurse - boolean
Returns:
boolean
Throws:
javax.mail.MessagingException

getFolder

public javax.mail.Folder getFolder(java.lang.String name)
                            throws javax.mail.MessagingException
Get folder by name or GUID

Parameters:
name - String Folder name or GUID
Returns:
Folder
Throws:
javax.mail.MessagingException

hasNewMessages

public boolean hasNewMessages()
                       throws javax.mail.MessagingException
This method is not implemented and will always raise UnsupportedOperationException

Throws:
java.lang.UnsupportedOperationException
javax.mail.MessagingException

renameTo

public boolean renameTo(javax.mail.Folder f)
                 throws javax.mail.MessagingException,
                        javax.mail.StoreClosedException,
                        java.lang.NullPointerException
Throws:
javax.mail.MessagingException
javax.mail.StoreClosedException
java.lang.NullPointerException

exists

public boolean exists()
               throws javax.mail.MessagingException,
                      javax.mail.StoreClosedException
Throws:
javax.mail.MessagingException
javax.mail.StoreClosedException

expunge

public javax.mail.Message[] expunge()
                             throws javax.mail.MessagingException

Expunge deleted messages

This method removes from the database and the MBOX file those messages flagged as deleted at k_mime_msgs table

Returns:
null
Throws:
javax.mail.MessagingException

wipe

public void wipe()
          throws javax.mail.MessagingException
Delete all messages from this folder and clear MBOX file

Throws:
javax.mail.MessagingException

getFullName

public java.lang.String getFullName()

Get category subpath to directory holding MBOX files for this folder

The category path is composed by concatenating the names of all the parent folders separated by a slash. The name of a folder is stored at column nm_category of table k_categories

Returns:
String

getDirectoryPath

public java.lang.String getDirectoryPath()
Get path to directory containing files belonging to this folder

Returns:
String

getFilePath

public java.lang.String getFilePath()
Get full path to MBOX file containing mime messages

Returns:
String

getFile

public java.io.File getFile()
Get MBOX file that holds messages for this DBFolder

Returns:
java.io.File object representing MBOX file.

getName

public java.lang.String getName()
Get column nm_category from table k_categories for this folder

Returns:
String

getURLName

public javax.mail.URLName getURLName()
                              throws javax.mail.MessagingException,
                                     javax.mail.StoreClosedException
Throws:
javax.mail.MessagingException
javax.mail.StoreClosedException

getMessage

protected javax.mail.Message getMessage(java.lang.String sMsgId,
                                        int IdType)
                                 throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

appendMessage

public java.lang.String appendMessage(javax.mail.internet.MimeMessage oMsg)
                               throws javax.mail.FolderClosedException,
                                      javax.mail.StoreClosedException,
                                      javax.mail.MessagingException,
                                      java.lang.ArrayIndexOutOfBoundsException,
                                      java.lang.NullPointerException
Parameters:
oMsg - MimeMessage
Returns:
String
Throws:
javax.mail.FolderClosedException
javax.mail.StoreClosedException
javax.mail.MessagingException
java.lang.ArrayIndexOutOfBoundsException
java.lang.NullPointerException - if oMsg is null

getMessage

public javax.mail.Message getMessage(int msgnum)
                              throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getMessageByGuid

public DBMimeMessage getMessageByGuid(java.lang.String sMsgGuid)
                               throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getMessageByID

public DBMimeMessage getMessageByID(java.lang.String sMsgGuid)
                             throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getMessageCount

public int getMessageCount()
                    throws javax.mail.FolderClosedException,
                           javax.mail.MessagingException
Throws:
javax.mail.FolderClosedException
javax.mail.MessagingException

getParent

public javax.mail.Folder getParent()
                            throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getPermanentFlags

public javax.mail.Flags getPermanentFlags()

getSeparator

public char getSeparator()
                  throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

list

public javax.mail.Folder[] list(java.lang.String pattern)
                         throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

getType

public int getType()
            throws javax.mail.MessagingException
Throws:
javax.mail.MessagingException

isOpen

public boolean isOpen()

getMessageHeaders

public java.util.Properties getMessageHeaders(java.lang.String sMsgId)
                                       throws javax.mail.FolderClosedException,
                                              java.sql.SQLException

Get message GUID, Id, Number, Subject, From and Reply-To from k_mime_msgs table

This method is mainly used for testing whether or not a message is already present at current folder.

Parameters:
sMsgId - String GUID or Id of message to be rerieved
Returns:
Properties {gu_mimemsg, id_message, pg_message, tx_subject, tx_email_from, tx_email_reply, nm_from } or null if no message with such sMsgId was found referenced at k_mime_msgs for current folder
Throws:
javax.mail.FolderClosedException
java.sql.SQLException

importMbox

public int importMbox(java.lang.String sMboxFilePath)
               throws java.io.FileNotFoundException,
                      java.io.IOException,
                      javax.mail.MessagingException
Throws:
java.io.FileNotFoundException
java.io.IOException
javax.mail.MessagingException

reindexMbox

public void reindexMbox(java.lang.String sMboxFilePath)
                 throws java.io.FileNotFoundException,
                        java.io.IOException,
                        javax.mail.MessagingException,
                        java.sql.SQLException
Delete every message from the index and rebuild it by re-reading the specified MBOX file

Parameters:
sMboxFilePath - String Full path to MBOX file
Throws:
java.io.FileNotFoundException
java.io.IOException
javax.mail.MessagingException
java.sql.SQLException

reindexMbox

public void reindexMbox()
                 throws java.io.FileNotFoundException,
                        java.io.IOException,
                        javax.mail.MessagingException,
                        java.sql.SQLException
Delete very message from th eindex and rebuild it by reading the default MBOX file for this folder

Throws:
java.io.FileNotFoundException
java.io.IOException
javax.mail.MessagingException
java.sql.SQLException