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.FolderStatus
Policy.Arg
QNAME
QNAME
QNAME
ARG_0, ARG_1, ARG_2, QNAME
QNAME
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,
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() |
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,
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,
Flags.Flag flag,
boolean value)
Set flags to the specified message.
|
void |
setFlags(FileInfo messageInfo,
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 ImapService
public void setDefaultFromAddress(String defaultFromAddress)
public String getDefaultToAddress()
getDefaultToAddress
in interface ImapService
public void setDefaultToAddress(String defaultToAddress)
public String getWebApplicationContextUrl()
getWebApplicationContextUrl
in interface ImapService
public String getShareApplicationContextUrl()
getShareApplicationContextUrl
in interface ImapService
public String getRepositoryTemplatePath()
getRepositoryTemplatePath
in interface ImapService
public 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()
ImapService
getImapServerEnabled
in interface ImapService
public 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 MessagingException
ImapService
getMessage
in interface ImapService
mesInfo
- imap file info.MessagingException
public com.icegreen.greenmail.store.SimpleStoredMessage createImapMessage(FileInfo fileInfo, boolean generateBody) throws MessagingException
ImapService
createImapMessage
in interface ImapService
fileInfo
- imap file info.generateBody
- Should the message body be generated?MessagingException
public void expungeMessage(FileInfo fileInfo)
ImapService
expungeMessage
in interface ImapService
fileInfo
- imap file info.public AlfrescoImapFolder getOrCreateMailbox(AlfrescoImapUser user, String mailboxName, boolean mayExist, boolean mayCreate)
ImapService
mailbox
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 ImapService
user
- 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 existAlfrescoImapRuntimeException
public void deleteMailbox(AlfrescoImapUser user, String mailboxName)
ImapService
deleteMailbox
in interface ImapService
user
- User making the request.mailboxName
- String name of the target,public void renameMailbox(AlfrescoImapUser user, String oldMailboxName, String newMailboxName)
ImapService
renameMailbox
in interface ImapService
user
- 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 ImapService
contextNodeRef
- context folder for searchviewMode
- context folder view modeuserName
- user namepublic void subscribe(AlfrescoImapUser user, String mailbox)
ImapService
subscribe
in interface ImapService
user
- User making the requestmailbox
- String representation of a mailbox name.public void unsubscribe(AlfrescoImapUser user, String mailbox)
ImapService
unsubscribe
in interface ImapService
user
- User making the requestmailbox
- String representation of a mailbox name.public Flags getFlags(FileInfo messageInfo)
getFlags
in interface ImapService
messageInfo
- imap folder info.public void setFlags(FileInfo messageInfo, Flags flags, boolean value)
setFlags
in interface ImapService
messageInfo
- FileInfo of imap Folder.flags
- flags to set.value
- value to set.public void setFlag(FileInfo messageInfo, Flags.Flag flag, boolean value)
setFlag
in interface ImapService
messageInfo
- 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 ImapService
user
- 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 ImapService
userName
- 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 ImapService
type
- 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.OnCreateChildAssociationPolicy
onCreateChildAssociation
in interface NodeServicePolicies.OnCreateChildAssociationPolicy
childAssocRef
- 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.OnDeleteChildAssociationPolicy
onDeleteChildAssociation
in interface NodeServicePolicies.OnDeleteChildAssociationPolicy
childAssocRef
- 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.OnUpdatePropertiesPolicy
onUpdateProperties
in interface NodeServicePolicies.OnUpdatePropertiesPolicy
nodeRef
- 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.OnRestoreNodePolicy
onRestoreNode
in interface NodeServicePolicies.OnRestoreNodePolicy
childAssocRef
- the newly created child association referencepublic void beforeDeleteNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
NodeServicePolicies.BeforeDeleteNodePolicy
beforeDeleteNode
in interface NodeServicePolicies.BeforeDeleteNodePolicy
nodeRef
- the node referencepublic org.alfresco.service.cmr.repository.NodeRef getNodeSiteContainer(org.alfresco.service.cmr.repository.NodeRef inputNodeRef)
ImapService
getNodeSiteContainer
in interface ImapService
inputNodeRef
- nodeRefpublic String getContentFolderUrl(org.alfresco.service.cmr.repository.NodeRef contentNodeRef)
ImapService
getContentFolderUrl
in interface ImapService
contentNodeRef
- 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, MimeMessage originalMessage) throws IOException, MessagingException
ImapService
extractAttachments
in interface ImapService
messageRef
- nodeRef that represents message in Alfresco.originalMessage
- original message in eml format.IOException
MessagingException
public String generateUniqueFilename(org.alfresco.service.cmr.repository.NodeRef destFolderNodeRef, String fileName)
generateUniqueFilename
in interface ImapService
public void persistMessageHeaders(org.alfresco.service.cmr.repository.NodeRef messageRef, MimeMessage message)
persistMessageHeaders
in interface ImapService
public String getPathFromSites(org.alfresco.service.cmr.repository.NodeRef ref)
getPathFromSites
in interface ImapService
ref
- NodeRefpublic String getPathFromRepo(org.alfresco.service.cmr.repository.ChildAssociationRef assocRef)
getPathFromRepo
in interface ImapService
assocRef
- an association between the node and it's parentCopyright © 2005–2017 Alfresco Software. All rights reserved.