001    package de.deepamehta.plugins.mail.service;
002    
003    import java.io.IOException;
004    import java.io.UnsupportedEncodingException;
005    import java.util.Collection;
006    import java.util.List;
007    
008    import org.apache.commons.mail.EmailException;
009    
010    import de.deepamehta.core.Association;
011    import de.deepamehta.core.Topic;
012    import de.deepamehta.core.service.ClientState;
013    import de.deepamehta.core.service.PluginService;
014    import de.deepamehta.plugins.mail.Mail;
015    import de.deepamehta.plugins.mail.RecipientType;
016    import de.deepamehta.plugins.mail.StatusReport;
017    
018    public interface MailService extends PluginService {
019    
020        /**
021         * Returns parent of each search type.
022         * 
023         * Parent types must include at least one email address.
024         * 
025         * @return parent search types.
026         */
027        Collection<Topic> getSearchParentTypes();
028    
029        /**
030         * Update or create a mail recipient association.
031         * 
032         * @param mailId
033         *            ID of a mail topic.
034         * @param addressId
035         *            Email address of recipient.
036         * @param type
037         *            Recipient type URI or null to choose the configured default.
038         * @param clientState
039         *            Optional cookie or null.
040         * @return Recipient association with email address and recipient type.
041         */
042        Association associateRecipient(long mailId, long addressId,//
043                RecipientType type, ClientState clientState);
044    
045        /**
046         * Update or create a mail sender association.
047         * 
048         * @param topicId
049         *            ID of a mail or configuration topic.
050         * @param addressId
051         *            Email address of sender.
052         * @param clientState
053         *            Optional cookie or null.
054         * @return Sender association with email address.
055         */
056        Association associateSender(long topicId, long addressId, ClientState clientState);
057    
058        /**
059         * Associate all valid email addresses of each recipient.
060         * 
061         * @param mailId
062         * @param recipients
063         * @param clientState
064         */
065        void associateValidatedRecipients(long mailId, List<Topic> recipients, ClientState clientState);
066    
067        /**
068         * Sends a HTML mail.
069         * 
070         * @param mail
071         *            Mail topic.
072         * @return Sent mail topic.
073         */
074        StatusReport send(Mail mail) throws UnsupportedEncodingException, EmailException, IOException;
075    }