public class ImapServiceImpl extends Object implements ImapService, NodeServicePolicies.OnRestoreNodePolicy, NodeServicePolicies.OnCreateChildAssociationPolicy, NodeServicePolicies.OnDeleteChildAssociationPolicy, NodeServicePolicies.OnUpdatePropertiesPolicy, NodeServicePolicies.BeforeDeleteNodePolicy
| Modifier and Type | Class and Description |
|---|---|
static class |
ImapServiceImpl.ImapServiceBootstrap
Bootstrap initialization bean for the service implementation.
|
ImapService.EmailBodyFormat, ImapService.FolderStatusPolicy.ArgQNAMEQNAMEQNAMEARG_0, ARG_1, ARG_2, QNAMEQNAME| Constructor and Description |
|---|
ImapServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Called before a node is deleted.
|
protected void |
bindBehaviour() |
com.icegreen.greenmail.store.SimpleStoredMessage |
createImapMessage(FileInfo fileInfo,
boolean generateBody)
Creates a MIME message for the given file
|
void |
deleteMailbox(AlfrescoImapUser user,
String mailboxName)
Deletes an existing MailBox.
|
void |
expungeMessage(FileInfo fileInfo)
Expunges (deletes) an IMAP message if its flags indicates
|
void |
extractAttachments(org.alfresco.service.cmr.repository.NodeRef messageRef,
javax.mail.internet.MimeMessage originalMessage)
Extract attachments from message.
|
String |
generateUniqueFilename(org.alfresco.service.cmr.repository.NodeRef destFolderNodeRef,
String fileName) |
String |
getAlfrescoServerUID()
This method should returns a unique identifier of Alfresco server.
|
String |
getContentFolderUrl(org.alfresco.service.cmr.repository.NodeRef contentNodeRef)
Get the web URL for the document's parent folder
|
String |
getDefaultEmailBodyTemplate(ImapService.EmailBodyFormat type)
Returns a template for email body.
|
String |
getDefaultFromAddress() |
String |
getDefaultToAddress() |
javax.mail.Flags |
getFlags(FileInfo messageInfo)
Return flags that belong to the specified imap folder.
|
ImapService.FolderStatus |
getFolderStatus(String userName,
org.alfresco.service.cmr.repository.NodeRef contextNodeRef,
AlfrescoImapConst.ImapViewMode viewMode)
Search for emails in specified folder depending on view mode.
|
boolean |
getImapServerEnabled()
Determines whether the IMAP server is enabled.
|
com.icegreen.greenmail.store.SimpleStoredMessage |
getMessage(FileInfo mesInfo)
Gets a cached MIME message for the given file, complete with message body.
|
org.alfresco.service.namespace.NamespaceService |
getNamespaceService() |
org.alfresco.service.cmr.repository.NodeRef |
getNodeSiteContainer(org.alfresco.service.cmr.repository.NodeRef inputNodeRef)
Get the node's site container if it belongs to Sites.
|
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.
mailbox parameter may specify absolute or relative path to a folder. |
String |
getPathFromRepo(org.alfresco.service.cmr.repository.ChildAssociationRef assocRef) |
String |
getPathFromSites(org.alfresco.service.cmr.repository.NodeRef ref) |
String |
getRepositoryTemplatePath() |
org.alfresco.service.cmr.search.SearchService |
getSearchService() |
String |
getShareApplicationContextUrl() |
org.alfresco.service.cmr.repository.NodeRef |
getUserImapHomeRef(String userName)
Get the node ref of the user's imap home.
|
String |
getWebApplicationContextUrl() |
void |
init() |
List<AlfrescoImapFolder> |
listMailboxes(AlfrescoImapUser user,
String mailboxPattern,
boolean listSubscribed)
Depend on listSubscribed param, list Mailboxes or list subscribed Mailboxes
|
void |
onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef,
boolean isNewNode)
Called after a node child association has been created.
|
void |
onDeleteChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
Called after a node child association has been deleted.
|
void |
onRestoreNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
Called after an archived node is restored.
|
void |
onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<org.alfresco.service.namespace.QName,Serializable> before,
Map<org.alfresco.service.namespace.QName,Serializable> after)
Called after a node's properties have been changed.
|
void |
persistMessageHeaders(org.alfresco.service.cmr.repository.NodeRef messageRef,
javax.mail.internet.MimeMessage message) |
void |
renameMailbox(AlfrescoImapUser user,
String oldMailboxName,
String newMailboxName)
Renames an existing mailbox.
|
void |
setAttachmentsExtractor(AttachmentsExtractor attachmentsExtractor) |
void |
setDefaultFromAddress(String defaultFromAddress) |
void |
setDefaultToAddress(String defaultToAddress) |
void |
setExtractAttachmentsEnabled(boolean extractAttachmentsEnabled) |
void |
setFileFolderService(FileFolderService fileFolderService) |
void |
setFlag(FileInfo messageInfo,
javax.mail.Flags.Flag flag,
boolean value)
Set flags to the specified message.
|
void |
setFlags(FileInfo messageInfo,
javax.mail.Flags flags,
boolean value)
Set flags to the specified imapFolder.
|
void |
setFolderCacheSize(int folderCacheSize) |
void |
setIgnoreExtractionFolders(RepositoryFolderConfigBean[] ignoreExtractionFolders) |
void |
setImapConfigMountPoints(ImapConfigMountPointsBean[] imapConfigMountPointsBeans) |
void |
setImapHome(RepositoryFolderConfigBean imapHomeConfigBean) |
void |
setImapServerEnabled(boolean enabled) |
void |
setImapServerShuffleMoveDeleteDelay(long imapServerShuffleMoveDeleteDelay) |
void |
setMessageCache(org.alfresco.repo.cache.SimpleCache<org.alfresco.service.cmr.repository.NodeRef,org.alfresco.repo.imap.ImapServiceImpl.CacheItem> messageCache) |
void |
setMessageHeadersToPersist(List<String> headers) |
void |
setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService) |
void |
setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService) |
void |
setPermissionService(org.alfresco.service.cmr.security.PermissionService permissionService) |
void |
setPolicyFilter(BehaviourFilter policyFilter) |
void |
setRepositoryTemplatePath(String repositoryTemplatePath) |
void |
setSearchService(org.alfresco.service.cmr.search.SearchService searchService) |
void |
setServiceRegistry(ServiceRegistry serviceRegistry) |
void |
setSysAdminParams(SysAdminParams sysAdminParams) |
void |
shutdown() |
void |
startup()
This method is run as System within a single transaction on startup.
|
protected void |
startupInTxn(boolean force) |
void |
subscribe(AlfrescoImapUser user,
String mailbox)
Subscribes a user to a mailbox.
|
void |
unsubscribe(AlfrescoImapUser user,
String mailbox)
Unsubscribes from a given mailbox.
|
public void setSysAdminParams(SysAdminParams sysAdminParams)
public void setMessageCache(org.alfresco.repo.cache.SimpleCache<org.alfresco.service.cmr.repository.NodeRef,org.alfresco.repo.imap.ImapServiceImpl.CacheItem> messageCache)
public void setFileFolderService(FileFolderService fileFolderService)
public void setNodeService(org.alfresco.service.cmr.repository.NodeService nodeService)
public void setPermissionService(org.alfresco.service.cmr.security.PermissionService permissionService)
public void setServiceRegistry(ServiceRegistry serviceRegistry)
public void setPolicyFilter(BehaviourFilter policyFilter)
public void setAttachmentsExtractor(AttachmentsExtractor attachmentsExtractor)
public void setImapHome(RepositoryFolderConfigBean imapHomeConfigBean)
public void setFolderCacheSize(int folderCacheSize)
public String getDefaultFromAddress()
getDefaultFromAddress in interface ImapServicepublic void setDefaultFromAddress(String defaultFromAddress)
public String getDefaultToAddress()
getDefaultToAddress in interface ImapServicepublic void setDefaultToAddress(String defaultToAddress)
public String getWebApplicationContextUrl()
getWebApplicationContextUrl in interface ImapServicepublic String getShareApplicationContextUrl()
getShareApplicationContextUrl in interface ImapServicepublic String getRepositoryTemplatePath()
getRepositoryTemplatePath in interface ImapServicepublic void setRepositoryTemplatePath(String repositoryTemplatePath)
public void setImapConfigMountPoints(ImapConfigMountPointsBean[] imapConfigMountPointsBeans)
public void setIgnoreExtractionFolders(RepositoryFolderConfigBean[] ignoreExtractionFolders)
public void setExtractAttachmentsEnabled(boolean extractAttachmentsEnabled)
public void setImapServerEnabled(boolean enabled)
public void setImapServerShuffleMoveDeleteDelay(long imapServerShuffleMoveDeleteDelay)
public boolean getImapServerEnabled()
ImapServicegetImapServerEnabled in interface ImapServicepublic void init()
public void startup()
public void shutdown()
protected void startupInTxn(boolean force)
protected void bindBehaviour()
public com.icegreen.greenmail.store.SimpleStoredMessage getMessage(FileInfo mesInfo) throws javax.mail.MessagingException
ImapServicegetMessage in interface ImapServicemesInfo - imap file info.javax.mail.MessagingExceptionpublic com.icegreen.greenmail.store.SimpleStoredMessage createImapMessage(FileInfo fileInfo, boolean generateBody) throws javax.mail.MessagingException
ImapServicecreateImapMessage in interface ImapServicefileInfo - imap file info.generateBody - Should the message body be generated?javax.mail.MessagingExceptionpublic void expungeMessage(FileInfo fileInfo)
ImapServiceexpungeMessage in interface ImapServicefileInfo - imap file info.public AlfrescoImapFolder getOrCreateMailbox(AlfrescoImapUser user, String mailboxName, boolean mayExist, boolean mayCreate)
ImapServicemailbox parameter may specify absolute or relative path to a folder. Absolute path uniquely identifies some directory, whereas relative path implies that root
folder should be IMAP home directory for the specified user rather than IMAP root (i.e. IMAP mount point). Mailbox will
be found or created (mayCreate=true, mayExist=false or ) in user's IMAP home directory if relative path is specified.mayExist and 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.getOrCreateMailbox in interface ImapServiceuser - User making the request.mailboxName - String name of the target.mayExist - Is the mailbox allowed to exist already? If false and the mailbox already exists, an error will be thrownmayCreate - If the mailbox does not exist, can one be created? If false then an error is thrown if the folder does not existAlfrescoImapRuntimeExceptionpublic void deleteMailbox(AlfrescoImapUser user, String mailboxName)
ImapServicedeleteMailbox in interface ImapServiceuser - User making the request.mailboxName - String name of the target,public void renameMailbox(AlfrescoImapUser user, String oldMailboxName, String newMailboxName)
ImapServicerenameMailbox in interface ImapServiceuser - User making the request.oldMailboxName - String name of the existing foldernewMailboxName - String target new namepublic ImapService.FolderStatus getFolderStatus(String userName, org.alfresco.service.cmr.repository.NodeRef contextNodeRef, AlfrescoImapConst.ImapViewMode viewMode)
getFolderStatus in interface ImapServicecontextNodeRef - context folder for searchviewMode - context folder view modeuserName - user namepublic void subscribe(AlfrescoImapUser user, String mailbox)
ImapServicesubscribe in interface ImapServiceuser - User making the requestmailbox - String representation of a mailbox name.public void unsubscribe(AlfrescoImapUser user, String mailbox)
ImapServiceunsubscribe in interface ImapServiceuser - User making the requestmailbox - String representation of a mailbox name.public javax.mail.Flags getFlags(FileInfo messageInfo)
getFlags in interface ImapServicemessageInfo - imap folder info.public void setFlags(FileInfo messageInfo, javax.mail.Flags flags, boolean value)
setFlags in interface ImapServicemessageInfo - FileInfo of imap Folder.flags - flags to set.value - value to set.public void setFlag(FileInfo messageInfo, javax.mail.Flags.Flag flag, boolean value)
setFlag in interface ImapServicemessageInfo - FileInfo of imap Folderflag - flag to set.value - value value to set.public List<AlfrescoImapFolder> listMailboxes(AlfrescoImapUser user, String mailboxPattern, boolean listSubscribed)
listMailboxes in interface ImapServiceuser - User making the requestmailboxPattern - String name of a mailbox, possible including a wildcard.listSubscribed - list only subscribed folders?public org.alfresco.service.cmr.repository.NodeRef getUserImapHomeRef(String userName)
getUserImapHomeRef in interface ImapServiceuserName - user namepublic String getDefaultEmailBodyTemplate(ImapService.EmailBodyFormat type)
ImapService"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.getDefaultEmailBodyTemplate in interface ImapServicetype - one of the possible body types text/html and text/plainpublic String getAlfrescoServerUID()
public void onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef,
boolean isNewNode)
NodeServicePolicies.OnCreateChildAssociationPolicyonCreateChildAssociation in interface NodeServicePolicies.OnCreateChildAssociationPolicychildAssocRef - the child association that has been createdisNewNode - true if the node is new or false if the node is being linked inpublic void onDeleteChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
NodeServicePolicies.OnDeleteChildAssociationPolicyonDeleteChildAssociation in interface NodeServicePolicies.OnDeleteChildAssociationPolicychildAssocRef - the child association that has been deletedpublic void onUpdateProperties(org.alfresco.service.cmr.repository.NodeRef nodeRef,
Map<org.alfresco.service.namespace.QName,Serializable> before,
Map<org.alfresco.service.namespace.QName,Serializable> after)
NodeServicePolicies.OnUpdatePropertiesPolicyonUpdateProperties in interface NodeServicePolicies.OnUpdatePropertiesPolicynodeRef - reference to the updated nodebefore - the node's properties before the changeafter - the node's properties after the changepublic void onRestoreNode(org.alfresco.service.cmr.repository.ChildAssociationRef childAssocRef)
NodeServicePolicies.OnRestoreNodePolicyonRestoreNode in interface NodeServicePolicies.OnRestoreNodePolicychildAssocRef - the newly created child association referencepublic void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
NodeServicePolicies.BeforeDeleteNodePolicybeforeDeleteNode in interface NodeServicePolicies.BeforeDeleteNodePolicynodeRef - the node referencepublic org.alfresco.service.cmr.repository.NodeRef getNodeSiteContainer(org.alfresco.service.cmr.repository.NodeRef inputNodeRef)
ImapServicegetNodeSiteContainer in interface ImapServiceinputNodeRef - nodeRefpublic String getContentFolderUrl(org.alfresco.service.cmr.repository.NodeRef contentNodeRef)
ImapServicegetContentFolderUrl in interface ImapServicecontentNodeRef - or null if the document is not from sitepublic void setNamespaceService(org.alfresco.service.namespace.NamespaceService namespaceService)
public org.alfresco.service.namespace.NamespaceService getNamespaceService()
public void setSearchService(org.alfresco.service.cmr.search.SearchService searchService)
public org.alfresco.service.cmr.search.SearchService getSearchService()
public void extractAttachments(org.alfresco.service.cmr.repository.NodeRef messageRef,
javax.mail.internet.MimeMessage originalMessage)
throws IOException,
javax.mail.MessagingException
ImapServiceextractAttachments in interface ImapServicemessageRef - nodeRef that represents message in Alfresco.originalMessage - original message in eml format.IOExceptionjavax.mail.MessagingExceptionpublic String generateUniqueFilename(org.alfresco.service.cmr.repository.NodeRef destFolderNodeRef, String fileName)
generateUniqueFilename in interface ImapServicepublic void persistMessageHeaders(org.alfresco.service.cmr.repository.NodeRef messageRef,
javax.mail.internet.MimeMessage message)
persistMessageHeaders in interface ImapServicepublic String getPathFromSites(org.alfresco.service.cmr.repository.NodeRef ref)
getPathFromSites in interface ImapServiceref - NodeRefpublic String getPathFromRepo(org.alfresco.service.cmr.repository.ChildAssociationRef assocRef)
getPathFromRepo in interface ImapServiceassocRef - an association between the node and it's parentCopyright © 2005–2018 Alfresco Software. All rights reserved.