18 package org.turro.dossier.issue;
20 import java.net.URLEncoder;
21 import java.util.HashMap;
22 import java.util.List;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.apache.commons.mail.EmailException;
26 import org.turro.action.Actions;
27 import org.turro.action.Contacts;
28 import org.turro.action.LinkType;
29 import org.turro.action.MailAttachment;
30 import org.turro.attach.search.AttachCollection;
31 import org.turro.auth.Authentication;
32 import org.turro.dossier.command.DossierEntityInfo;
33 import org.turro.dossier.db.DossierPU;
34 import org.turro.dossier.entity.IDossierParticipant;
35 import org.turro.dossier.entity.Issue;
36 import org.turro.dossier.entity.IssueParticipant;
37 import org.turro.elephant.context.Application;
38 import org.turro.elephant.context.ElephantContext;
39 import org.turro.elephant.context.IConstructor;
40 import org.turro.elephant.security.IUser;
41 import org.turro.i18n.I_;
42 import org.turro.mail.message.MailMessageTemplate;
43 import org.turro.mail.pool.MailMessagePool;
44 import org.turro.mail.provider.MailProviders;
45 import org.turro.marker.ElephantMarker;
46 import org.turro.path.Path;
47 import org.turro.plugin.contacts.ContactList;
48 import org.turro.plugin.contacts.IContact;
49 import org.turro.registry.Changes;
50 import org.turro.util.Chars;
58 private final Changes changes;
59 private final Issue issue;
60 private final double expenses, hours, price;
62 public IssueMail(Changes changes,
Issue issue,
double expenses,
double hours,
double price) {
63 this.changes = changes;
65 this.expenses = expenses;
81 HashMap<String, String> values =
new HashMap<>();
83 values.put(
Actions.REDIR_PAR, URLEncoder.encode(redir,
"UTF-8"));
87 private void sendMailTemplate() {
95 for(
IContact contact : getPlayers()) {
103 em.
put(
"issue", issue);
105 em.
put(
"contact", contact);
106 em.
put(
"realContact", realContact);
108 em.
put(
"notifier",
this);
109 mmt.
setMessage(em,
"issue-notification", contact);
111 mmt.
attach(ma.attachment.getAbsolutePath(), ma.name, ma.name);
114 }
catch (EmailException ex) {
115 Logger.getLogger(
IssueMail.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(
null), ex);
126 private String getSubject(IContact realContact) {
127 return "[" + I_.get(
"Issue") +
" #" + issue.
getId() +
" " +
132 private List<IContact> getPlayers() {
133 ContactList list =
new ContactList();
135 IContact ic = Contacts.getContactById(ip.getIdContact());
136 if(ic.isValid() && ic.isWebUser()) {
137 ic.setAttribute(
"showParticipants", Boolean.TRUE);
143 if(p.isReceiveAllEmails()) {
144 IContact ic = Contacts.getContactById(p.getIdContact());
145 if(ic.isValid() && ic.isWebUser()) {
146 ic.setAttribute(
"showParticipants", p.isShowParticipants());
static String createAction(String email, String redir)
static final String USER_PAR
void loadAttachments(String path, boolean publicOnly)
Collection< MailAttachment > getAttachments()
static IContact getIContact()
static String linkForPath(Path path, IContact contact, LinkType type)
static String getObjectPath(Object object)
String getFullDescription()
ParticipantSet< IDossierParticipant > getFullParticipants()
Set< IssueParticipant > getParticipants()
IssueComment getLastComment()
String create(IConstructor constructor, String redir, String email)
IssueMail(Changes changes, Issue issue, double expenses, double hours, double price)
String create(IConstructor constructor, Issue issue, IContact contact)
IConstructor getConstructor()
static Application getApplication()
void setMessage(ElephantMarker marker, IContact contact)
static MailMessageTemplate of(MailProvider provider)
void setRoot(String root)
void attach(String path, String description, String name)
Email addTo(String email, String name)
void setSubject(String subject)
MailMessage addToPool(String from, String to, String cc, String subject, String message)
MailProvider getProvider()
static MailProviders instance()
MailMessagePool getPool(IConstructor constructor, String name)
Object put(Object key, Object value)
static final String CONNECTOR_EMAIL