19 package org.turro.entities;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import org.apache.commons.mail.EmailException;
27 import org.turro.action.MailAttachment;
28 import org.turro.assistant.Assistant;
29 import org.turro.assistant.AssistantSet;
30 import org.turro.elephant.context.ElephantContext;
31 import org.turro.elephant.context.IConstructor;
32 import org.turro.elephant.entities.db.Sendable;
33 import org.turro.elephant.impl.repository.Repository;
34 import org.turro.file.util.FileAttach;
35 import org.turro.jpa.entity.EntityWebUrls;
36 import org.turro.mail.message.MailMessageTemplate;
37 import org.turro.mail.pool.MailMessagePool;
38 import org.turro.mail.provider.MailProviders;
39 import org.turro.marker.ElephantMarker;
40 import org.turro.publication.db.PublicationPU;
41 import org.turro.publication.entity.Publication;
42 import org.turro.sendable.AbstractSendable;
43 import org.turro.sendable.Sendables;
63 this.constructor = constructor;
67 List<MailAttachment> attached = getAttached(entity);
73 mmt.
addTo(assistant.email, assistant.name);
75 ArrayList<Publication> pubs =
new ArrayList<>();
78 em.
put(
"contact", assistant.contact);
79 em.
put(
"email", assistant.email);
80 em.
put(
"notifier",
this);
81 mmt.
setMessage(em,
"sendable", assistant.contact);
83 mmt.
attach(ma.getPath(), ma.getName(), ma.getName());
88 }
catch (EmailException | NullPointerException ex) {
106 if(ewu !=
null && entityUrl !=
null) {
107 redir = entityUrl + ewu;
114 public String
createRef(String redir)
throws Exception {
115 return "{liveref:" + redir +
"}";
122 private List<MailAttachment> getAttached(
Publication pub) {
123 List<MailAttachment> list =
new ArrayList<>();
126 if(attached !=
null) {
127 for(File file : attached) {
128 list.add(
new MailAttachment(file.getAbsolutePath(), file.getName(), file));
static String getSiteName()
static String logMsg(String msg)
static String getEntityWebContext(String path)
File[] getFiles(String pattern)
RepositoryFile getRoot(String root)
PublicationSendable(String entityPath)
String createRef(String redir)
Repository repository(Publication pub)
boolean doSend(Sendable sendable, Publication entity, IConstructor constructor, AssistantSet assistants, boolean checkSent)
void addAssistants(AssistantSet as, Publication entity)
PublicationSendable(Publication entity)
String createRef(Publication publication)
Repository getPublishableRepository(IConstructor constructor)
static String getUrlFromEntity(Object entity)
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)
static boolean existsTemplate(IConstructor constructor, boolean mail, String root, String name)
Object put(Object key, Object value)
static String getObjectPath(Object object)
static void delivered(String entityPath, String contactId)