Fixed bug when notifications involved groups and email buffer was not cleared

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/application-support-layer/applicationSupportLayerSocial@97429 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-06-13 16:37:30 +00:00
parent 819ba9ab58
commit bd058420b8
3 changed files with 19 additions and 9 deletions

View File

@ -39,4 +39,7 @@
<Change>Updated email sending with single smtp session</Change>
<Change>Personalized notifications in email subjects</Change>
</Changeset>
<Changeset component="org.gcube.applicationsupportlayer.aslsocial.0-10-1" date="2014-06-13">
<Change>Fixed bug when notifications involved groups and email buffer was not cleared</Change>
</Changeset>
</ReleaseNotes>

View File

@ -58,10 +58,15 @@ public class EmailNotificationsConsumer extends Thread {
synchronized(EmailPlugin.BUFFER_EMAILS){
for (NotificationMail mail : EmailPlugin.BUFFER_EMAILS) {
Message m = EmailPlugin.getMessageNotification(session, mail.getNotification2Send(), mail.getVreName(), mail.getPortalName(), mail.getSenderEmail());
if (m != null) {
m.saveChanges();
Address[] addresses = m.getAllRecipients();
t.sendMessage(m, addresses);
_log.debug("Message sent to " + addresses.toString());
_log.debug("Message sent to " + mail.getSenderEmail());
}
else {
_log.warn("Message not sent to " + mail.getNotification2Send().getUserid());
}
}
//close session and empty the buffer
_log.info("Emails sent emptying the buffer");

View File

@ -150,6 +150,8 @@ public class EmailPlugin {
portalUrl = PortalUtil.getPortalURL(OrganizationsUtil.getCompany().getVirtualHost(), PortalUtil.getPortalPort(), true);
} catch (Exception e1) {
e1.printStackTrace();
_log.warn("While trying to get email for user/group: " + notification2Save.getUserid());
return null;
}
String email = user.getEmailAddress();