de.deepamehta.plugins.mail
Class MailPlugin

Show UML class diagram
java.lang.Object
  extended by de.deepamehta.core.osgi.PluginActivator
      extended by de.deepamehta.plugins.mail.MailPlugin
All Implemented Interfaces:
PluginContext, PostCreateTopicListener, Listener, PluginService, MailService, org.osgi.framework.BundleActivator

public class MailPlugin
extends PluginActivator
implements MailService, PostCreateTopicListener


Field Summary
private  AccessControlService acService
           
static String AGGREGATION
           
static String ATTACHMENTS
           
(package private)  Autocomplete autocomplete
           
static String BODY
           
static String CHILD
           
static String CHILD_TYPE
           
(package private)  ImageCidEmbedment cidEmbedment
           
static String COMPOSITION
           
(package private)  MailConfigurationCache config
           
static String DATE
           
static String EMAIL_ADDRESS
           
static String FILE
           
private  FilesService fileService
           
static String FROM
           
(package private)  boolean isInitialized
           
private static Logger log
           
static String MAIL
           
static String MESSAGE_ID
           
static String PARENT
           
static String PARENT_TYPE
           
static String RECIPIENT
           
static String RECIPIENT_TYPE
           
static String SENDER
           
static String SIGNATURE
           
static String SUBJECT
           
static String TOPIC_TYPE
           
static String USER_ACCOUNT
           
 
Fields inherited from class de.deepamehta.core.osgi.PluginActivator
bundle, dms
 
Constructor Summary
MailPlugin()
           
 
Method Summary
private  void associateDefaultSender(Topic mail, ClientState clientState)
           
 Association associateRecipient(long mailId, long addressId, ClientState cookie)
           
 Association associateRecipient(long mailId, long addressId, RecipientType type, ClientState clientState)
          Update or create a mail recipient association.
private  Association associateRecipient(long topicId, Topic recipient, CompositeValueModel value, ClientState clientState)
           
 Association associateSender(long mailId, long addressId, ClientState clientState)
          Update or create a mail sender association.
private  Association associateSender(long topicId, Topic sender, CompositeValueModel value, ClientState clientState)
           
 void associateValidatedRecipients(long mailId, List<Topic> recipients, ClientState cookie)
          Associate all valid email addresses of each recipient.
private  void checkACLsOfMigration()
           
private  void configureIfReady()
           
 Topic copyMail(long mailId, boolean includeRecipients, ClientState cookie)
          Creates a copy of the mail.
private  void createAttachmentDirectory()
           
private  RelatedTopic getContactOfEmail(long addressId)
           
private  RelatedTopic getContactSignature(Topic topic, long addressId)
           
 String getDefaultRecipientType()
           
private  Association getRecipientAssociation(long topicId, long addressId, long recipientId)
           
 ResultSet<RelatedTopic> getRecipientTypes()
           
 Collection<Topic> getSearchParentTypes()
          Returns parent of each search type.
private  RelatedTopic getSender(long topicId, boolean fetchRelatingComposite)
           
private  RelatedTopic getSender(Topic topic, boolean fetchRelatingComposite)
           
private  Association getSenderAssociation(long topicId, long senderId)
           
 void init()
          Initialize.
 ResultSet<Topic> listSearchParentTypes()
           
 Topic loadConfiguration()
          Load the configuration.
 Association mailSender(long mailId, long addressId, ClientState cookie)
           
private  void mapRecipients(org.apache.commons.mail.HtmlEmail email, Map<RecipientType,List<javax.mail.internet.InternetAddress>> recipients)
           
 void postCreateTopic(Topic topic, ClientState clientState, Directives directives)
          Sets the default sender and signature of a mail topic after creation.
private  void reportException(StatusReport report, Level level, MailError error, Exception e)
           
 List<TopicModel> search(String term, ClientState cookie)
          Returns the parent of each search type substring match.
 StatusReport send(long mailId)
           
 StatusReport send(Mail mail)
          Sends a HTML mail.
 void serviceArrived(PluginService service)
          Reference file service and create the attachment directory if not exists.
 void serviceGone(PluginService service)
           
 Topic writeTo(long recipientId, ClientState cookie)
          Creates a new mail to all email addresses of the contact topic.
 
Methods inherited from class de.deepamehta.core.osgi.PluginActivator
getBundleContext, postInstall, publishDirectory, setCoreService, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

log

private static Logger log

AGGREGATION

public static final String AGGREGATION
See Also:
Constant Field Values

COMPOSITION

public static final String COMPOSITION
See Also:
Constant Field Values

CHILD

public static final String CHILD
See Also:
Constant Field Values

CHILD_TYPE

public static final String CHILD_TYPE
See Also:
Constant Field Values

TOPIC_TYPE

public static final String TOPIC_TYPE
See Also:
Constant Field Values

PARENT

public static final String PARENT
See Also:
Constant Field Values

PARENT_TYPE

public static final String PARENT_TYPE
See Also:
Constant Field Values

FILE

public static final String FILE
See Also:
Constant Field Values

ATTACHMENTS

public static final String ATTACHMENTS
See Also:
Constant Field Values

BODY

public static final String BODY
See Also:
Constant Field Values

EMAIL_ADDRESS

public static final String EMAIL_ADDRESS
See Also:
Constant Field Values

DATE

public static final String DATE
See Also:
Constant Field Values

FROM

public static final String FROM
See Also:
Constant Field Values

MAIL

public static final String MAIL
See Also:
Constant Field Values

MESSAGE_ID

public static final String MESSAGE_ID
See Also:
Constant Field Values

RECIPIENT

public static final String RECIPIENT
See Also:
Constant Field Values

RECIPIENT_TYPE

public static final String RECIPIENT_TYPE
See Also:
Constant Field Values

SENDER

public static final String SENDER
See Also:
Constant Field Values

SIGNATURE

public static final String SIGNATURE
See Also:
Constant Field Values

SUBJECT

public static final String SUBJECT
See Also:
Constant Field Values

USER_ACCOUNT

public static final String USER_ACCOUNT
See Also:
Constant Field Values

acService

private AccessControlService acService

fileService

private FilesService fileService

config

MailConfigurationCache config

cidEmbedment

ImageCidEmbedment cidEmbedment

autocomplete

Autocomplete autocomplete

isInitialized

boolean isInitialized
Constructor Detail

MailPlugin

public MailPlugin()
Method Detail

associateRecipient

public Association associateRecipient(long mailId,
                                      long addressId,
                                      @HeaderParam(value="Cookie")
                                      ClientState cookie)
See Also:
associateRecipient(long, long, RecipientType, de.deepamehta.core.service.ClientState)

associateRecipient

public Association associateRecipient(long mailId,
                                      long addressId,
                                      RecipientType type,
                                      ClientState clientState)
Description copied from interface: MailService
Update or create a mail recipient association.

Specified by:
associateRecipient in interface MailService
Parameters:
mailId - ID of a mail topic.
addressId - Email address of recipient.
type - Recipient type URI or null to choose the configured default.
clientState - Optional cookie or null.
Returns:
Recipient association with email address and recipient type.

associateValidatedRecipients

public void associateValidatedRecipients(long mailId,
                                         List<Topic> recipients,
                                         ClientState cookie)
Description copied from interface: MailService
Associate all valid email addresses of each recipient.

Specified by:
associateValidatedRecipients in interface MailService

mailSender

public Association mailSender(long mailId,
                              long addressId,
                              @HeaderParam(value="Cookie")
                              ClientState cookie)
See Also:
associateSender(long, long, de.deepamehta.core.service.ClientState)

associateSender

public Association associateSender(long mailId,
                                   long addressId,
                                   ClientState clientState)
Description copied from interface: MailService
Update or create a mail sender association.

Specified by:
associateSender in interface MailService
Parameters:
mailId - ID of a mail or configuration topic.
addressId - Email address of sender.
clientState - Optional cookie or null.
Returns:
Sender association with email address.

search

public List<TopicModel> search(String term,
                               @HeaderParam(value="Cookie")
                               ClientState cookie)
Returns the parent of each search type substring match.

Parameters:
term - String to search.
cookie - Actual cookie.
Returns:
Parent model of each result topic.

copyMail

public Topic copyMail(long mailId,
                      boolean includeRecipients,
                      @HeaderParam(value="Cookie")
                      ClientState cookie)
Creates a copy of the mail.

Parameters:
mailId - ID of the mail topic to clone.
includeRecipients - Copy recipients of the origin?
cookie - Actual cookie.
Returns:
Cloned mail topic with associated sender and recipients.

writeTo

public Topic writeTo(long recipientId,
                     @HeaderParam(value="Cookie")
                     ClientState cookie)
Creates a new mail to all email addresses of the contact topic.

Parameters:
recipientId - ID of a recipient contact topic.
cookie - Actual cookie.
Returns:
Mail topic with associated recipient.

getDefaultRecipientType

public String getDefaultRecipientType()
Returns:
Default recipient type.

getRecipientTypes

public ResultSet<RelatedTopic> getRecipientTypes()
Returns:
Recipient types.

listSearchParentTypes

public ResultSet<Topic> listSearchParentTypes()
See Also:
getSearchParentTypes()

getSearchParentTypes

public Collection<Topic> getSearchParentTypes()
Description copied from interface: MailService
Returns parent of each search type. Parent types must include at least one email address.

Specified by:
getSearchParentTypes in interface MailService
Returns:
parent search types.

loadConfiguration

public Topic loadConfiguration()
Load the configuration. Useful after type and configuration changes with the web-client.


postCreateTopic

public void postCreateTopic(Topic topic,
                            ClientState clientState,
                            Directives directives)
Sets the default sender and signature of a mail topic after creation.

Specified by:
postCreateTopic in interface PostCreateTopicListener

send

public StatusReport send(long mailId)
See Also:
send(Mail)

send

public StatusReport send(Mail mail)
Description copied from interface: MailService
Sends a HTML mail.

Specified by:
send in interface MailService
Parameters:
mail - Mail topic.
Returns:
Sent mail topic.

init

public void init()
Initialize.

Specified by:
init in interface PluginContext
Overrides:
init in class PluginActivator

serviceArrived

public void serviceArrived(PluginService service)
Reference file service and create the attachment directory if not exists.

Specified by:
serviceArrived in interface PluginContext
Overrides:
serviceArrived in class PluginActivator

configureIfReady

private void configureIfReady()

serviceGone

public void serviceGone(PluginService service)
Specified by:
serviceGone in interface PluginContext
Overrides:
serviceGone in class PluginActivator

checkACLsOfMigration

private void checkACLsOfMigration()

createAttachmentDirectory

private void createAttachmentDirectory()

associateDefaultSender

private void associateDefaultSender(Topic mail,
                                    ClientState clientState)
Parameters:
mail -
clientState -
See Also:
postCreateTopic(Topic, ClientState, Directives)

associateRecipient

private Association associateRecipient(long topicId,
                                       Topic recipient,
                                       CompositeValueModel value,
                                       ClientState clientState)

associateSender

private Association associateSender(long topicId,
                                    Topic sender,
                                    CompositeValueModel value,
                                    ClientState clientState)

getContactOfEmail

private RelatedTopic getContactOfEmail(long addressId)

getContactSignature

private RelatedTopic getContactSignature(Topic topic,
                                         long addressId)

getRecipientAssociation

private Association getRecipientAssociation(long topicId,
                                            long addressId,
                                            long recipientId)

getSender

private RelatedTopic getSender(long topicId,
                               boolean fetchRelatingComposite)

getSender

private RelatedTopic getSender(Topic topic,
                               boolean fetchRelatingComposite)

getSenderAssociation

private Association getSenderAssociation(long topicId,
                                         long senderId)

mapRecipients

private void mapRecipients(org.apache.commons.mail.HtmlEmail email,
                           Map<RecipientType,List<javax.mail.internet.InternetAddress>> recipients)
                    throws org.apache.commons.mail.EmailException
Throws:
org.apache.commons.mail.EmailException

reportException

private void reportException(StatusReport report,
                             Level level,
                             MailError error,
                             Exception e)


Copyright © 2013. All Rights Reserved.