Package org.alfresco.repo.imap
Interface ImapService
- All Known Implementing Classes:
ImapServiceImpl
public interface ImapService
- Since:
- 3.2
- Author:
- Arseny Kovalchuk
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumHelper enumeration to handle email body format text/html and text/plain for Alfresco/Share webappstatic class -
Method Summary
Modifier and TypeMethodDescriptioncom.icegreen.greenmail.store.SimpleStoredMessagecreateImapMessage(FileInfo messageFileInfo, boolean generateBody) Creates a MIME message for the given filevoiddeleteMailbox(AlfrescoImapUser user, String mailboxName) Deletes an existing MailBox.voidexpungeMessage(FileInfo messageFileInfo) Expunges (deletes) an IMAP message if its flags indicatesvoidextractAttachments(NodeRef messageRef, jakarta.mail.internet.MimeMessage originalMessage) Extract attachments from message.generateUniqueFilename(NodeRef destFolderNodeRef, String fileName) getContentFolderUrl(NodeRef siteContainerNodeRef) Get the web URL for the document's parent folderReturns a template for email body.jakarta.mail.FlagsReturn flags that belong to the specified imap folder.getFolderStatus(String userName, NodeRef contextNodeRef, AlfrescoImapConst.ImapViewMode viewMode) Search for emails in specified folder depend on view mode.booleanDetermines whether the IMAP server is enabled.com.icegreen.greenmail.store.SimpleStoredMessagegetMessage(FileInfo messageFileInfo) Gets a cached MIME message for the given file, complete with message body.getNodeSiteContainer(NodeRef nodeRef) Get the node's site container if it belongs to Sites.getOrCreateMailbox(AlfrescoImapUser user, String mailboxName, boolean mayExist, boolean mayCreate) Returns a reference to a mailbox, either creating a new one or retrieving an existing one.
mailboxparameter may specify absolute or relative path to a folder.getPathFromRepo(ChildAssociationRef assocRef) getPathFromSites(NodeRef nodeRef) getUserImapHomeRef(String userName) Get the node ref of the user's imap home.listMailboxes(AlfrescoImapUser user, String mailboxPattern, boolean listSubscribed) Returns an collection of mailboxes.voidpersistMessageHeaders(NodeRef nodeRef, jakarta.mail.internet.MimeMessage message) voidrenameMailbox(AlfrescoImapUser user, String oldMailboxName, String newMailboxName) Renames an existing mailbox.voidSet flag to the specified imapFolder.voidSet flags to the specified imapFolder.voidsubscribe(AlfrescoImapUser user, String mailbox) Subscribes a user to a mailbox.voidunsubscribe(AlfrescoImapUser user, String mailbox) Unsubscribes from a given mailbox.
-
Method Details
-
listMailboxes
List<AlfrescoImapFolder> listMailboxes(AlfrescoImapUser user, String mailboxPattern, boolean listSubscribed) Returns an collection of mailboxes. This method serves LIST command of the IMAP protocol.- Parameters:
user- User making the requestmailboxPattern- String name of a mailbox, possible including a wildcard.listSubscribed- list only subscribed folders?- Returns:
- Collection of mailboxes matching the pattern.
-
deleteMailbox
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,
-
renameMailbox
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 foldernewMailboxName- String target new name
-
getOrCreateMailbox
AlfrescoImapFolder getOrCreateMailbox(AlfrescoImapUser user, String mailboxName, boolean mayExist, boolean mayCreate) Returns a reference to a mailbox, either creating a new one or retrieving an existing one.
mailboxparameter may specify absolute or relative path to a folder. Absolute path uniquely identifies some directory, whereas relative path implies that root folder should beIMAP homedirectory for the specifieduserrather thanIMAP root(i.e.IMAP mount point). Mailbox will be found or created (mayCreate=true,mayExist=falseor ) inuser'sIMAP homedirectory if relative path is specified.
mayExistand mayCreate parameters' combinations and results:mayCreate=false,mayExist=true- mailbox is found and not created if it doesn't exist. Error is thrown if mailbox doesn't not exist;mayCreate=true,mayExist=true- mailbox is created if it doesn't exist or it is just found in other case. No error is thrown;mayCreate=true,mayExist=false- mailbox is created if it doesn't exist. Error is thrown if it is already created;mayCreate=false,mayExist=false- error is thrown that mailbox cannot be created if doesn't exist. Error is thrown that mailbox should not exist in other case.
It's a very shady combination!
- Parameters:
user- User making the request.mailboxName- String name of the target.mayExist- Is the mailbox allowed to exist already? Iffalseand the mailbox already exists, an error will be thrownmayCreate- If the mailbox does not exist, can one be created? Iffalsethen an error is thrown if the folder does not exist- Returns:
- a Mailbox reference
-
getUserImapHomeRef
Get the node ref of the user's imap home. Will create it on demand if it does not already exist.- Parameters:
userName- user name- Returns:
- user IMAP home reference and create it if it doesn't exist.
-
subscribe
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 requestmailbox- String representation of a mailbox name.
-
unsubscribe
Unsubscribes from a given mailbox. This method serves UNSUBSCRIBE command of the IMAP protocol.- Parameters:
user- User making the requestmailbox- String representation of a mailbox name.
-
getFolderStatus
ImapService.FolderStatus getFolderStatus(String userName, NodeRef contextNodeRef, AlfrescoImapConst.ImapViewMode viewMode) Search for emails in specified folder depend on view mode.- Parameters:
userName- user namecontextNodeRef- context NodeRefviewMode- (ARCHIVE, MIXED or VIRTUAL)- Returns:
- list of emails that context folder contains.
-
getMessage
com.icegreen.greenmail.store.SimpleStoredMessage getMessage(FileInfo messageFileInfo) throws jakarta.mail.MessagingException Gets a cached MIME message for the given file, complete with message body.- Parameters:
messageFileInfo- imap file info.- Returns:
- a message.
- Throws:
jakarta.mail.MessagingException
-
createImapMessage
com.icegreen.greenmail.store.SimpleStoredMessage createImapMessage(FileInfo messageFileInfo, boolean generateBody) throws jakarta.mail.MessagingException Creates a MIME message for the given file- Parameters:
messageFileInfo- imap file info.generateBody- Should the message body be generated?- Returns:
- a message.
- Throws:
jakarta.mail.MessagingException
-
expungeMessage
Expunges (deletes) an IMAP message if its flags indicates- Parameters:
messageFileInfo- imap file info.
-
getFlags
Return flags that belong to the specified imap folder.- Parameters:
messageFileInfo- imap folder info.- Returns:
- flags.
-
setFlags
Set flags to the specified imapFolder.- Parameters:
messageFileInfo- FileInfo of imap Folder.flags- flags to set.value- value to set.
-
setFlag
Set flag to the specified imapFolder.- Parameters:
messageFileInfo- FileInfo of imap Folderflag- flag to set.value- value value to set.
-
getDefaultFromAddress
String getDefaultFromAddress()- Returns:
- Default From addreses
-
getDefaultToAddress
String getDefaultToAddress()- Returns:
- Default To addreses
-
getRepositoryTemplatePath
String getRepositoryTemplatePath()- Returns:
- Path to the folder containing templates, that will be used for generating body of message in VIRTUAL and MIXED views.
-
getWebApplicationContextUrl
String getWebApplicationContextUrl()- Returns:
- Web application context url (e.g. http://localhost:8080/alfresco)
-
getDefaultEmailBodyTemplate
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 returnsNodeRef.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:
- String
-
getNodeSiteContainer
Get the node's site container if it belongs to Sites.- Parameters:
nodeRef- nodeRef- Returns:
- nodeRef of the node's site container or null if provided node does not belong to sites.
-
getContentFolderUrl
Get the web URL for the document's parent folder- Parameters:
siteContainerNodeRef- or null if the document is not from site- Returns:
- url for the content folder
-
getImapServerEnabled
boolean getImapServerEnabled()Determines whether the IMAP server is enabled.- Returns:
- true if enabled
-
extractAttachments
void extractAttachments(NodeRef messageRef, jakarta.mail.internet.MimeMessage originalMessage) throws IOException, jakarta.mail.MessagingException Extract attachments from message.- Parameters:
messageRef- nodeRef that represents message in Alfresco.originalMessage- original message in eml format.- Throws:
IOExceptionjakarta.mail.MessagingException
-
generateUniqueFilename
-
persistMessageHeaders
-
getPathFromSites
- Parameters:
nodeRef- NodeRef- Returns:
- path for node relatively to site root
-
getPathFromRepo
- Parameters:
assocRef- an association between the node and it's parent- Returns:
- path for node relatively to repository
-