BrightSide Workbench Full Report + Source Code
org.turro.mail.recipients.SendAttachments Class Referenceabstract

Public Member Functions

 SendAttachments (String title)
 
void addAttachment (Object entity, String path, String name)
 
void sendAttachments (Collection< IContact > contacts) throws IOException
 

Protected Member Functions

abstract void fillAttachment (File attachment, Object entity)
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 48 of file SendAttachments.java.

Constructor & Destructor Documentation

◆ SendAttachments()

org.turro.mail.recipients.SendAttachments.SendAttachments ( String  title)

Definition at line 54 of file SendAttachments.java.

54  {
55  this.title = title;
56  }

Member Function Documentation

◆ addAttachment()

void org.turro.mail.recipients.SendAttachments.addAttachment ( Object  entity,
String  path,
String  name 
)

Definition at line 58 of file SendAttachments.java.

58  {
59  attachments.add(new MailAttachment(path, name, entity));
60  }
Here is the caller graph for this function:

◆ fillAttachment()

abstract void org.turro.mail.recipients.SendAttachments.fillAttachment ( File  attachment,
Object  entity 
)
abstractprotected
Here is the caller graph for this function:

◆ sendAttachments()

void org.turro.mail.recipients.SendAttachments.sendAttachments ( Collection< IContact contacts) throws IOException

Definition at line 62 of file SendAttachments.java.

62  {
63  if(attachments.isEmpty()) {
64  return;
65  }
66  IMailRecipients.selectRecipients(contacts, new Command() {
67  @Override
68  public Object execute(Context context) {
69  IMailRecipients mr = (IMailRecipients) context.get("component");
70  Collection<IContact> contacts = mr.getRecipients();
71  if(contacts != null) {
72  String mailString = getMailString(contacts);
73  if(!Strings.isBlank(mailString)) {
74  for(MailAttachment ma : attachments) {
75  try {
76  ma.attachment = File.createTempFile("attach_", "_mail");
77  fillAttachment(ma.attachment, ma.entity);
78  } catch (IOException ex) {
79  Logger.getLogger(SendAttachments.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(mailString), ex);
80  }
81  }
82  sendAttachments(contacts, attachments, IMailRecipients.getComment(), mailString, (m) -> {
83  for(MailAttachment ma : attachments) {
84  ma.attachment.delete();
85  SystemLogger.getInstance().doLog(SystemLogType.LOG_INFO, ma.path, "sent", mailString);
86  }
87  });
88  }
89  }
90  return null;
91  }
92  });
93  }
abstract void fillAttachment(File attachment, Object entity)
void sendAttachments(Collection< IContact > contacts)
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: