From 21bf1014e55ab8049e18ee991c6ee80b23d1789c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 23 Aug 2016 14:48:01 +0500 Subject: Implement cache for users objects --- src/org/traccar/notification/NotificationMail.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/org/traccar/notification/NotificationMail.java') diff --git a/src/org/traccar/notification/NotificationMail.java b/src/org/traccar/notification/NotificationMail.java index f9d42968f..f8449e7d2 100644 --- a/src/org/traccar/notification/NotificationMail.java +++ b/src/org/traccar/notification/NotificationMail.java @@ -15,7 +15,6 @@ */ package org.traccar.notification; -import java.sql.SQLException; import java.util.Properties; import javax.mail.Message; @@ -27,7 +26,6 @@ import javax.mail.internet.MimeMessage; import org.traccar.Config; import org.traccar.Context; -import org.traccar.database.DataManager; import org.traccar.helper.Log; import org.traccar.model.Event; import org.traccar.model.Extensible; @@ -106,14 +104,13 @@ public final class NotificationMail { } public static void sendMailSync(long userId, Event event, Position position) { - DataManager dataManager = Context.getDataManager(); Properties mailServerProperties; Session mailSession; MimeMessage mailMessage; try { - User user = dataManager.getUser(userId); + User user = Context.getPermissionsManager().getUser(userId); mailServerProperties = getConfigProperies(); if (!mailServerProperties.containsKey("mail.smtp.host")) { @@ -130,8 +127,7 @@ public final class NotificationMail { mailMessage.setFrom(new InternetAddress(mailServerProperties.getProperty("mail.smtp.from"))); } - mailMessage.addRecipient(Message.RecipientType.TO, new InternetAddress( - Context.getDataManager().getUser(userId).getEmail())); + mailMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(user.getEmail())); mailMessage.setSubject(NotificationFormatter.formatTitle(userId, event, position)); mailMessage.setText(NotificationFormatter.formatMessage(userId, event, position)); @@ -142,7 +138,7 @@ public final class NotificationMail { transport.sendMessage(mailMessage, mailMessage.getAllRecipients()); transport.close(); - } catch (MessagingException | SQLException error) { + } catch (MessagingException error) { Log.warning(error); } } -- cgit v1.2.3