org.alfresco.repo.imap
Interface ImapService

All Known Implementing Classes:
ImapServiceImpl

public interface ImapService

Since:
3.2

Nested Class Summary
static class ImapService.EmailBodyFormat
          Helper enumeration to handle email body format text/html and text/plain for Alfresco/Share webapp
 
Method Summary
 AlfrescoImapFolder createMailbox(AlfrescoImapUser user, java.lang.String mailboxName)
          Returns a reference to a newly created mailbox.
 void deleteMailbox(AlfrescoImapUser user, java.lang.String mailboxName)
          Deletes an existing MailBox.
 org.alfresco.service.cmr.repository.NodeRef extractAttachments(org.alfresco.service.cmr.repository.NodeRef parentFolder, org.alfresco.service.cmr.repository.NodeRef messageFile, javax.mail.internet.MimeMessage originalMessage)
          Extract Attachments
 java.lang.String getDefaultEmailBodyTemplate(ImapService.EmailBodyFormat type)
          Returns a template for email body.
 java.lang.String getDefaultFromAddress()
           
 java.lang.String getDefaultToAddress()
           
 javax.mail.Flags getFlags(FileInfo messageFileInfo)
          Return flags that belong to the specified imap folder.
 AlfrescoImapFolder getFolder(AlfrescoImapUser user, java.lang.String mailboxName)
          Returns a reference to an existing Mailbox.
 boolean getImapServerEnabled()
          Determines whether the IMAP server is enabled.
 org.alfresco.service.cmr.repository.NodeRef getMailboxRootRef(java.lang.String mailboxName, java.lang.String userName)
          Get root reference for the specified mailbox
 java.lang.String getRepositoryTemplatePath()
           
 java.lang.String getShareApplicationContextUrl()
           
 java.lang.String getWebApplicationContextUrl()
           
 boolean isNodeInSitesLibrary(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Determine if provided node belongs to Sites.
 java.util.List listMailboxes(AlfrescoImapUser user, java.lang.String mailboxPattern)
          Returns an collection of mailboxes.
 java.util.List listSubscribedMailboxes(AlfrescoImapUser user, java.lang.String mailboxPattern)
          Returns an collection of subscribed mailboxes.
 void renameMailbox(AlfrescoImapUser user, java.lang.String oldMailboxName, java.lang.String newMailboxName)
          Renames an existing mailbox.
 java.util.List searchMails(org.alfresco.service.cmr.repository.NodeRef contextNodeRef, AlfrescoImapConst.ImapViewMode viewMode)
          Search for emails in specified folder depend on view mode.
 void setFlag(FileInfo messageFileInfo, javax.mail.Flags.Flag flag, boolean value)
          Set flag to the specified imapFolder.
 void setFlags(FileInfo messageFileInfo, javax.mail.Flags flags, boolean value)
          Set flags to the specified imapFolder.
 void subscribe(AlfrescoImapUser user, java.lang.String mailbox)
          Subscribes a user to a mailbox.
 void unsubscribe(AlfrescoImapUser user, java.lang.String mailbox)
          Unsubscribes from a given mailbox.
 

Method Detail

listMailboxes

java.util.List listMailboxes(AlfrescoImapUser user,
                             java.lang.String mailboxPattern)
Returns an collection of mailboxes. This method serves LIST command of the IMAP protocol.

Parameters:
user - User making the request
mailboxPattern - String name of a mailbox encoded in MUTF-7, possible including a wildcard.
Returns:
Collection of mailboxes matching the pattern.

listSubscribedMailboxes

java.util.List listSubscribedMailboxes(AlfrescoImapUser user,
                                       java.lang.String mailboxPattern)
Returns an collection of subscribed mailboxes. This method serves LSUB command of the IMAP protocol.

Parameters:
user - User making the request
mailboxPattern - String name of a mailbox encoded in MUTF-7, possible including a wildcard.
Returns:
Collection of mailboxes matching the pattern.

createMailbox

AlfrescoImapFolder createMailbox(AlfrescoImapUser user,
                                 java.lang.String mailboxName)
Returns a reference to a newly created mailbox. The request should specify a mailbox that does not already exist on this server, that could exist on this server and that the user has rights to create. This method serves CREATE command of the IMAP protocol.

Parameters:
user - User making the request.
mailboxName - String name of the target encoded in MUTF-7,
Returns:
an Mailbox reference.

deleteMailbox

void deleteMailbox(AlfrescoImapUser user,
                   java.lang.String mailboxName)
Deletes an existing MailBox. Specified mailbox must already exist on this server, and the user must have rights to delete it. This method serves DELETE command of the IMAP protocol.

Parameters:
user - User making the request.
mailboxName - String name of the target encoded in MUTF-7,
Throws:
com.icegreen.greenmail.store.FolderException - if mailbox has a non-selectable store with children

renameMailbox

void renameMailbox(AlfrescoImapUser user,
                   java.lang.String oldMailboxName,
                   java.lang.String newMailboxName)
Renames an existing mailbox. The specified mailbox must already exist, the requested name must not exist already but must be able to be created and the user must have rights to delete the existing mailbox and create a mailbox with the new name. Any inferior hierarchical names must also be renamed. If INBOX is renamed, the contents of INBOX are transferred to a new mailbox with the new name, but INBOX is not deleted. If INBOX has inferior mailbox these are not renamed. This method serves RENAME command of the IMAP protocol.

Parameters:
user - User making the request.
oldMailboxName - String name of the existing folder encoded in MUTF-7,
newMailboxName - String target new name encoded in MUTF-7,

getFolder

AlfrescoImapFolder getFolder(AlfrescoImapUser user,
                             java.lang.String mailboxName)
Returns a reference to an existing Mailbox. The requested mailbox must already exists on this server and the requesting user must have at least lookup rights.

It is also can be used by to obtain hierarchy delimiter by the LIST command:

C: 2 list "" ""

S: * LIST () "." ""

S: 2 OK LIST completed.

Parameters:
user - User making the request.
mailboxName - String name of the target encoded in MUTF-7,.
Returns:
an Mailbox reference.

getMailboxRootRef

org.alfresco.service.cmr.repository.NodeRef getMailboxRootRef(java.lang.String mailboxName,
                                                              java.lang.String userName)
Get root reference for the specified mailbox

Parameters:
mailboxName - mailbox name in IMAP client.
userName -
Returns:
NodeRef of root reference for the specified mailbox

subscribe

void subscribe(AlfrescoImapUser user,
               java.lang.String mailbox)
Subscribes a user to a mailbox. The mailbox must exist locally and the user must have rights to modify it.

This method serves SUBSCRIBE command of the IMAP protocol.

Parameters:
user - User making the request
mailbox - String representation of a mailbox name encoded in MUTF-7,.

unsubscribe

void unsubscribe(AlfrescoImapUser user,
                 java.lang.String mailbox)
Unsubscribes from a given mailbox.

This method serves UNSUBSCRIBE command of the IMAP protocol.

Parameters:
user - User making the request
mailbox - String representation of a mailbox name encoded in MUTF-7,.

searchMails

java.util.List searchMails(org.alfresco.service.cmr.repository.NodeRef contextNodeRef,
                           AlfrescoImapConst.ImapViewMode viewMode)
Search for emails in specified folder depend on view mode.

Parameters:
contextNodeRef - context folder for search
namePattern - name pattern for search
viewMode - (ARCHIVE, MIXED or VIRTUAL)
includeSubFolders - includeSubFolders
Returns:
list of emails that context folder contains.

getFlags

javax.mail.Flags getFlags(FileInfo messageFileInfo)
Return flags that belong to the specified imap folder.

Parameters:
messageInfo - imap folder info.
Returns:
flags.

setFlags

void setFlags(FileInfo messageFileInfo,
              javax.mail.Flags flags,
              boolean value)
Set flags to the specified imapFolder.

Parameters:
messageInfo - FileInfo of imap Folder.
flags - flags to set.
value - value to set.

setFlag

void setFlag(FileInfo messageFileInfo,
             javax.mail.Flags.Flag flag,
             boolean value)
Set flag to the specified imapFolder.

Parameters:
messageInfo - FileInfo of imap Folder
flag - flag to set.
value - value value to set.

getDefaultFromAddress

java.lang.String getDefaultFromAddress()
Returns:
Default From addreses

getDefaultToAddress

java.lang.String getDefaultToAddress()
Returns:
Default To addreses

getRepositoryTemplatePath

java.lang.String getRepositoryTemplatePath()
Returns:
Path to the folder containing templates, that will be used for generating body of message in VIRTUAL and MIXED views.

getWebApplicationContextUrl

java.lang.String getWebApplicationContextUrl()
Returns:
Web application context url (e.g. http://localhost:8080/alfresco)

getShareApplicationContextUrl

java.lang.String getShareApplicationContextUrl()
Returns:
Web application context url for share (e.g. http://localhost:8080/share)

getDefaultEmailBodyTemplate

java.lang.String getDefaultEmailBodyTemplate(ImapService.EmailBodyFormat type)
Returns a template for email body. It is either classpath path or NodeRef.toString(). This method trying to find a template on the path in the repository first e.g. "Data Dictionary > IMAP Templates >". This path should be set as the property of the "imapHelper" bean. In this case it returns NodeRef.toString() of the template. If there are no template in the repository it returns a default template on the classpath.

Parameters:
Type - one of the possible body types text/html and text/plain
Returns:

isNodeInSitesLibrary

boolean isNodeInSitesLibrary(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Determine if provided node belongs to Sites.

Parameters:
nodeRef - nodeRef
Returns:
true if provided node belongs to sites.

extractAttachments

org.alfresco.service.cmr.repository.NodeRef extractAttachments(org.alfresco.service.cmr.repository.NodeRef parentFolder,
                                                               org.alfresco.service.cmr.repository.NodeRef messageFile,
                                                               javax.mail.internet.MimeMessage originalMessage)
                                                               throws java.io.IOException,
                                                                      javax.mail.MessagingException
Extract Attachments

Parameters:
parentFolder -
messageFile - the node ref of the message.
originalMessage -
Throws:
java.io.IOException
javax.mail.MessagingException

getImapServerEnabled

boolean getImapServerEnabled()
Determines whether the IMAP server is enabled.

Returns:
true if enabled


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.