2013-01-31 01:31:07 +01:00
|
|
|
package org.gcube.applicationsupportlayer.social.mailing;
|
|
|
|
|
2014-05-19 19:07:18 +02:00
|
|
|
import java.util.ArrayList;
|
2013-01-31 01:31:07 +01:00
|
|
|
|
|
|
|
import org.gcube.portal.databook.shared.Notification;
|
2013-09-30 15:43:29 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2013-01-31 01:31:07 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @author Massimiliano Assante
|
2016-04-26 15:47:53 +02:00
|
|
|
* @author Costantino Perciante
|
2013-01-31 01:31:07 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
public class EmailPlugin {
|
2013-09-30 15:43:29 +02:00
|
|
|
|
|
|
|
private static final Logger _log = LoggerFactory.getLogger(EmailPlugin.class);
|
2014-07-01 17:15:20 +02:00
|
|
|
protected static final int SECONDS2WAIT = 60;
|
2014-05-19 19:07:18 +02:00
|
|
|
private static EmailPlugin singleton;
|
2016-04-13 18:10:22 +02:00
|
|
|
|
2016-05-16 19:18:23 +02:00
|
|
|
|
|
|
|
public static EmailPlugin getInstance() {
|
2014-05-19 19:07:18 +02:00
|
|
|
if (singleton == null)
|
2016-05-16 19:18:23 +02:00
|
|
|
singleton = new EmailPlugin();
|
2014-05-19 19:07:18 +02:00
|
|
|
return singleton;
|
|
|
|
}
|
2014-11-03 19:31:09 +01:00
|
|
|
|
2016-05-16 19:18:23 +02:00
|
|
|
private EmailPlugin() {
|
2014-05-19 19:07:18 +02:00
|
|
|
new EmailNotificationsConsumer().start();
|
|
|
|
}
|
2014-11-03 19:31:09 +01:00
|
|
|
|
2014-05-19 19:07:18 +02:00
|
|
|
protected static ArrayList<NotificationMail> BUFFER_EMAILS = new ArrayList<NotificationMail>();
|
|
|
|
/**
|
|
|
|
* enqueue the message to send
|
|
|
|
* @param notification2Save
|
|
|
|
* @param vreName
|
|
|
|
* @param portalName
|
|
|
|
* @param senderEmail
|
|
|
|
*/
|
2016-05-16 19:18:23 +02:00
|
|
|
public void sendNotification(String portalURL, String siteLandingPagePath, Notification notification2Save, String vreName, String portalName, String senderEmail, String ... hashtags) {
|
|
|
|
EmailNotificationProducer thread = new EmailNotificationProducer(new NotificationMail(portalURL, siteLandingPagePath, notification2Save, vreName, portalName, senderEmail, hashtags));
|
2014-05-19 19:07:18 +02:00
|
|
|
thread.start();
|
2016-05-16 19:18:23 +02:00
|
|
|
_log.trace("Thread notification Mail started OK");
|
2014-05-19 19:07:18 +02:00
|
|
|
}
|
2013-01-31 01:31:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|