From 14840af2abd9976b8f5634af8e77f4a7126dfac1 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Wed, 27 Jun 2018 15:55:19 +0500 Subject: - Rename NotificationException to MessageException - Simplify Notificator instantiation - Make sms configuration more clear - Move some defaults in code - Some cleanup --- src/org/traccar/notification/NotificationSms.java | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/org/traccar/notification/NotificationSms.java') diff --git a/src/org/traccar/notification/NotificationSms.java b/src/org/traccar/notification/NotificationSms.java index dd3304d85..ed651ac11 100644 --- a/src/org/traccar/notification/NotificationSms.java +++ b/src/org/traccar/notification/NotificationSms.java @@ -20,41 +20,37 @@ import org.traccar.Context; import org.traccar.model.Event; import org.traccar.model.Position; import org.traccar.model.User; -import org.traccar.sms.SMSManager; -import org.traccar.sms.SMSException; +import org.traccar.sms.SmsManager; public final class NotificationSms extends Notificator { - private final SMSManager sms; + private final SmsManager smsManager; - public NotificationSms(String methodId) throws ClassNotFoundException, - InstantiationException, IllegalAccessException { - final String smsClass = Context.getConfig().getString("notificator." + methodId + ".sms.class", ""); + public NotificationSms() throws ClassNotFoundException, InstantiationException, IllegalAccessException { + final String smsClass = Context.getConfig().getString("notificator.sms.manager.class", ""); if (smsClass.length() > 0) { - sms = (SMSManager) Class.forName(smsClass).newInstance(); + smsManager = (SmsManager) Class.forName(smsClass).newInstance(); } else { - sms = Context.getSmsManager(); + smsManager = Context.getSmsManager(); } } - @Override public void sendAsync(long userId, Event event, Position position) { final User user = Context.getPermissionsManager().getUser(userId); if (user.getPhone() != null) { Context.getStatisticsManager().registerSms(); - sms.sendMessageAsync(user.getPhone(), + smsManager.sendMessageAsync(user.getPhone(), NotificationFormatter.formatShortMessage(userId, event, position), false); } } @Override - public void sendSync(long userId, Event event, Position position) throws SMSException, - InterruptedException { + public void sendSync(long userId, Event event, Position position) throws MessageException, InterruptedException { final User user = Context.getPermissionsManager().getUser(userId); if (user.getPhone() != null) { Context.getStatisticsManager().registerSms(); - sms.sendMessageSync(user.getPhone(), + smsManager.sendMessageSync(user.getPhone(), NotificationFormatter.formatShortMessage(userId, event, position), false); } } -- cgit v1.2.3