BrightSide Workbench Full Report + Source Code
org.turro.newsletter.NewsletterTemplate Class Reference
Inheritance diagram for org.turro.newsletter.NewsletterTemplate:
Collaboration diagram for org.turro.newsletter.NewsletterTemplate:

Public Member Functions

 NewsletterTemplate (Newsletter newsletter)
 
MailMessageTemplate getMailMessage (MailMessagePool pool, IContact contact)
 
String getTemplate (IContact contact)
 
void releaseTemplate ()
 
void close () throws IOException
 

Detailed Description

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

Definition at line 44 of file NewsletterTemplate.java.

Constructor & Destructor Documentation

◆ NewsletterTemplate()

org.turro.newsletter.NewsletterTemplate.NewsletterTemplate ( Newsletter  newsletter)

Definition at line 49 of file NewsletterTemplate.java.

49  {
50  this.newsletter = newsletter;
51  newsletter.resetSections();
52  }
Here is the call graph for this function:

Member Function Documentation

◆ close()

void org.turro.newsletter.NewsletterTemplate.close ( ) throws IOException

Definition at line 132 of file NewsletterTemplate.java.

Here is the call graph for this function:

◆ getMailMessage()

MailMessageTemplate org.turro.newsletter.NewsletterTemplate.getMailMessage ( MailMessagePool  pool,
IContact  contact 
)

Definition at line 54 of file NewsletterTemplate.java.

54  {
55  try {
56  if(pool == null) pool = MailProviders.instance().getGeneric();
57  MailMessageTemplate mmt = MailMessageTemplate.of(pool.getProvider());
58  mmt.setProcessLiveLinks(true);
59  mmt.setSubject(getTitle());
60  mmt.addTo(contact.getEmail(), contact.getName());
61  ElephantMarker em = new ElephantMarker(Application.getApplication().getConstructor(), true);
62  em.put("newsletter", newsletter);
63  for(NewsSection ns : newsletter.getNewsSections()) {
64  em.put("newsSection" + ns.getNewsOrder(), ns);
65  }
66  em.put("contact", contact);
67  em.put("email", contact.getEmail());
68  mmt.setRoot("/newsletter/tmp");
69  mmt.setMessage(em, getTemplate(contact), contact);
70  return mmt;
71  } catch (EmailException ex) {
72  Logger.getLogger(NewsletterTemplate.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
73  return null;
74  }
75  }
Here is the call graph for this function:

◆ getTemplate()

String org.turro.newsletter.NewsletterTemplate.getTemplate ( IContact  contact)

Definition at line 77 of file NewsletterTemplate.java.

77  {
78  try {
79  if(template == null) {
80  File rootTmp = new File(ElephantContext.getRealPath("/WEB-INF/elephant/templates-mail/content/newsletter/tmp"));
81  rootTmp.mkdirs();
82  template = File.createTempFile("news", "Template.html", rootTmp);
83  try (PrintWriter fw = new PrintWriter(template, ElephantContext.getEncoding())) {
84  newsletter.generateNewsletter(contact, fw);
85  }
86  }
87  return extractName(template);
88  } catch (IOException ex) {
89  Logger.getLogger(NewsletterTemplate.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
90  return null;
91  }
92  }
void generateNewsletter(IContact contact, Writer writer)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ releaseTemplate()

void org.turro.newsletter.NewsletterTemplate.releaseTemplate ( )

Definition at line 94 of file NewsletterTemplate.java.

94  {
95  if(template != null) {
96  template.delete();
97  }
98  }
Here is the caller graph for this function:

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