BrightSide Workbench Full Report + Source Code
org.turro.publication.util.PublicationNotification Class Reference
Inheritance diagram for org.turro.publication.util.PublicationNotification:
Collaboration diagram for org.turro.publication.util.PublicationNotification:

Public Member Functions

 PublicationNotification (IConstructor constructor, String path, List< Publication > pubs, PublicationCategory category)
 
String create (Publication publication) throws Exception
 
String create (Publication publication, IContact contact) throws Exception
 
String create (String redir, IContact contact) throws Exception
 
String createRef (Publication publication) throws Exception
 
String createRef (String redir) throws Exception
 
Repository repository (Publication pub)
 
void addToQueue ()
 
void sendMail ()
 
- Public Member Functions inherited from org.turro.mail.queue.QueuedSender
 QueuedSender ()
 
void send ()
 
void pause ()
 
void run ()
 

Protected Member Functions

void doSend ()
 

Additional Inherited Members

- Static Public Member Functions inherited from org.turro.mail.queue.QueuedSender
static AtomicCounter getCounter ()
 

Detailed Description

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

Definition at line 62 of file PublicationNotification.java.

Constructor & Destructor Documentation

◆ PublicationNotification()

org.turro.publication.util.PublicationNotification.PublicationNotification ( IConstructor  constructor,
String  path,
List< Publication pubs,
PublicationCategory  category 
)

Definition at line 69 of file PublicationNotification.java.

70  {
71  this.constructor = constructor;
72  this.path = path;
73  this.pubs = pubs;
74  this.category = category;
75  }

Member Function Documentation

◆ addToQueue()

void org.turro.publication.util.PublicationNotification.addToQueue ( )

Definition at line 125 of file PublicationNotification.java.

125  {
126  QueueManager qm = new QueueManager();
127  for(IContact contact : getPlayers()) {
128  List<Publication> publications = filterLangs(contact);
129  try {
130  MailMessageTemplate mmt = MailMessageTemplate.of(MailProviders.instance().getProvider("Publication"));
131  mmt.setRoot("/publications");
132  mmt.setProcessLiveLinks(false);
133  mmt.setSubject(getSubject(null));
134  mmt.addTo(contact.getConnector(IUser.CONNECTOR_EMAIL), contact.getName());
135  ElephantMarker em = new ElephantMarker(constructor, true);
136  em.put("pubs", publications);
137  em.put("contact", contact);
138  em.put("email", contact.getConnector(IUser.CONNECTOR_EMAIL));
139  em.put("notifier", this);
140  mmt.setMessage(em, "publication", contact);
141  qm.addToQueue(new PublicationElephantNotification().getCategory(PublicationElephantNotification.convertId(category)),
142  contact, mmt, null, "Publication");
143  } catch (EmailException | NullPointerException ex) {
144  Logger.getLogger(PublicationNotification.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
145  }
146  }
147  }
PublicationNotification(IConstructor constructor, String path, List< Publication > pubs, PublicationCategory category)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create() [1/3]

String org.turro.publication.util.PublicationNotification.create ( Publication  publication) throws Exception

Definition at line 86 of file PublicationNotification.java.

86  {
87  String redir = path + "?pubid=" + publication.getId() + "&item=" + publication.getId();
88  HashMap<String, String> values = new HashMap<>();
89  values.put(Actions.REDIR_PAR, URLEncoder.encode(redir, "UTF-8"));
90  return Actions.createAction(values, false);
91  }
Here is the caller graph for this function:

◆ create() [2/3]

String org.turro.publication.util.PublicationNotification.create ( Publication  publication,
IContact  contact 
) throws Exception

Definition at line 93 of file PublicationNotification.java.

93  {
94  String redir = path + "?pubid=" + publication.getId() + "&item=" + publication.getId();
95  return create(redir, contact);
96  }
Here is the call graph for this function:

◆ create() [3/3]

String org.turro.publication.util.PublicationNotification.create ( String  redir,
IContact  contact 
) throws Exception

Definition at line 98 of file PublicationNotification.java.

98  {
99  HashMap<String, String> values = new HashMap<>();
100  values.put(Actions.USER_PAR, contact.getConnector(IUser.CONNECTOR_EMAIL));
101  values.put(Actions.REDIR_PAR, URLEncoder.encode(redir, "UTF-8"));
102  return Actions.createAction(values, 7, false);
103  }

◆ createRef() [1/2]

String org.turro.publication.util.PublicationNotification.createRef ( Publication  publication) throws Exception

Definition at line 105 of file PublicationNotification.java.

105  {
106  String redir;
107  String entityUrl = ElephantContext.getEntityWebContext("/publication");
108  String ewu = EntityWebUrls.getUrlFromEntity(publication);
109  if(ewu != null && entityUrl != null) {
110  redir = entityUrl + ewu;
111  } else {
112  redir = path + "?pubid=" + publication.getId() + "&item=" + publication.getId();
113  }
114  return createRef(redir);
115  }
Here is the call graph for this function:

◆ createRef() [2/2]

String org.turro.publication.util.PublicationNotification.createRef ( String  redir) throws Exception

Definition at line 117 of file PublicationNotification.java.

117  {
118  return "{liveref:" + redir + "}";
119  }

◆ doSend()

void org.turro.publication.util.PublicationNotification.doSend ( )
protected

Reimplemented from org.turro.mail.queue.QueuedSender.

Definition at line 78 of file PublicationNotification.java.

Here is the call graph for this function:

◆ repository()

Repository org.turro.publication.util.PublicationNotification.repository ( Publication  pub)

Definition at line 121 of file PublicationNotification.java.

121  {
122  return new FileAttach(PublicationPU.getObjectPath(pub)).getPublishableRepository(constructor);
123  }
Here is the call graph for this function:

◆ sendMail()

void org.turro.publication.util.PublicationNotification.sendMail ( )

Definition at line 149 of file PublicationNotification.java.

149  {
150  MailMessagePool pool = MailProviders.instance().getPool(constructor, "Publication");
151  if(pool != null) {
152  IAgreements agreements = Plugins.loadImplementation(IAgreements.class, "agreements");
153  List<MailAttachment> attached = getAttached(pubs);
154  for(IContact contact : getPlayers()) {
155  List<Publication> publications = filterLangs(contact);
156  NotificationCategory nc = Notifications.getCategory(PublicationElephantNotification.convertId(category));
157  agreements.setContact(contact);
158  if(agreements.canSendEmails(nc)) {
159  try {
160  MailMessageTemplate mmt = MailMessageTemplate.of(pool.getProvider());
161  mmt.setRoot("/publications");
162  mmt.setSubject(getSubject(publications));
163  mmt.addTo(contact.getConnector(IUser.CONNECTOR_EMAIL), contact.getName());
164  ElephantMarker em = new ElephantMarker(constructor, true);
165  em.put("pubs", publications);
166  em.put("contact", contact);
167  em.put("email", contact.getConnector(IUser.CONNECTOR_EMAIL));
168  em.put("notifier", this);
169  mmt.setMessage(em, "sendable", contact);
170  for(MailAttachment ma : attached) {
171  mmt.attach(ma.getPath(), ma.getName(), ma.getName());
172  }
173  pool.addToPool(mmt);
174  pool.sendPool();
175  pause();
176  } catch (EmailException | NullPointerException ex) {
177  Logger.getLogger(PublicationNotification.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
178  }
179  }
180  }
181  }
182  }
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: