BrightSide Workbench Full Report + Source Code
IMailSender.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2018 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.action;
19 
20 import java.io.File;
21 import java.util.Collection;
22 import java.util.Map;
23 import java.util.function.Consumer;
24 import java.util.function.Supplier;
25 import org.apache.commons.mail.EmailException;
26 import org.turro.action.queue.NotificationCategory;
27 import org.turro.plugin.contacts.IContact;
28 
33 public interface IMailSender extends IContactSender<IMailSender> {
34 
35  public IMailSender addAttachment(File file);
36  public IMailSender addAttachments(Collection<File> files);
37  public IMailSender addMailAttachments(Collection<MailAttachment> files);
38  public IMailSender onStart(Consumer command);
39  public IMailSender onCancel(Consumer command);
40  public IMailSender onBuild(Consumer command);
41  public IMailSender onFinish(Consumer command);
42 
43  public IMailSender setCategory(String idCategory);
44  public IMailSender setPool(String pool);
45  public IMailSender setReason(String reason);
46 
47  /* Not for queue or authenticated accounts */
48  public IMailSender setFrom(IContact contact);
49 
50  /* Attributes */
51  public IMailSender putIf(Object key, Supplier<Boolean> condition, Supplier value);
52  public IMailSender put(Object key, Object value);
53  public IMailSender putAll(Map attributes);
54 
61  public IMailSender setRoot(String root);
62 
63  public void removeAttachments();
64 
65  /* Direct sending */
66  public void send(String subject, String message);
67  public void send(NotificationCategory category, String subject, String message);
68 
69  /* Template sending */
70  public void sendTemplate(String template, String subject) throws EmailException;
71  public void sendTemplate(Object entity, String template, String subject) throws EmailException;
72  public void sendTemplate(NotificationCategory category, Object entity, String template, String subject) throws EmailException;
73 
74  public void silentSendTemplate(String template, String subject);
75  public void silentSendTemplate(Object entity, String template, String subject);
76  public void silentSendTemplate(NotificationCategory category, Object entity, String template, String subject);
77 
78  /* Utils */
79 
80  public String processMacros(IContact contact, String text, boolean web);
81 
82 }
void silentSendTemplate(Object entity, String template, String subject)
void sendTemplate(NotificationCategory category, Object entity, String template, String subject)
IMailSender addMailAttachments(Collection< MailAttachment > files)
IMailSender onFinish(Consumer command)
IMailSender setFrom(IContact contact)
IMailSender put(Object key, Object value)
IMailSender setReason(String reason)
String processMacros(IContact contact, String text, boolean web)
void sendTemplate(Object entity, String template, String subject)
void sendTemplate(String template, String subject)
IMailSender addAttachment(File file)
IMailSender setCategory(String idCategory)
void silentSendTemplate(String template, String subject)
void send(String subject, String message)
IMailSender onStart(Consumer command)
IMailSender putIf(Object key, Supplier< Boolean > condition, Supplier value)
IMailSender onCancel(Consumer command)
IMailSender onBuild(Consumer command)
IMailSender setPool(String pool)
IMailSender putAll(Map attributes)
void silentSendTemplate(NotificationCategory category, Object entity, String template, String subject)
IMailSender setRoot(String root)
void send(NotificationCategory category, String subject, String message)
IMailSender addAttachments(Collection< File > files)