From 0daa91ca51ecbb23a7f962fd64bfe5817f8eaa29 Mon Sep 17 00:00:00 2001 From: Srk Date: Mon, 20 Nov 2017 19:55:11 +0100 Subject: Minor refactoring --- src/org/traccar/Context.java | 10 +++++----- src/org/traccar/notification/EventForwarder.java | 10 +++++----- src/org/traccar/notification/JsonTypeEventForwarder.java | 1 - src/org/traccar/notification/NotificationFormatter.java | 6 +++--- 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/org/traccar/Context.java b/src/org/traccar/Context.java index a03b14b1b..d77b6878f 100644 --- a/src/org/traccar/Context.java +++ b/src/org/traccar/Context.java @@ -325,7 +325,7 @@ public final class Context { objectMapper = new ObjectMapper(); objectMapper.setConfig( objectMapper.getSerializationConfig().without(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)); - if (Context.getConfig().getBoolean("config.mapper.prettyPrintedJson")) { + if (Context.getConfig().getBoolean("mapper.prettyPrintedJson")) { objectMapper.enable(SerializationFeature.INDENT_OUTPUT); } @@ -354,7 +354,7 @@ public final class Context { } if (config.getBoolean("geolocation.enable")) { - initLocationResolutionSystem(); + initGeolocationModule(); } if (config.getBoolean("web.enable")) { @@ -368,7 +368,7 @@ public final class Context { tripsConfig = initTripsConfig(); if (config.getBoolean("event.enable")) { - initEventsSubsystem(); + initEventsModule(); } serverManager = new ServerManager(); @@ -395,7 +395,7 @@ public final class Context { } - private static void initLocationResolutionSystem() { + private static void initGeolocationModule() { String type = config.getString("geolocation.type", "mozilla"); String url = config.getString("geolocation.url"); @@ -417,7 +417,7 @@ public final class Context { } } - private static void initEventsSubsystem() { + private static void initEventsModule() { geofenceManager = new GeofenceManager(dataManager); calendarManager = new CalendarManager(dataManager); diff --git a/src/org/traccar/notification/EventForwarder.java b/src/org/traccar/notification/EventForwarder.java index d7e0eca19..1a10d7ca2 100644 --- a/src/org/traccar/notification/EventForwarder.java +++ b/src/org/traccar/notification/EventForwarder.java @@ -15,11 +15,10 @@ */ package org.traccar.notification; -import java.nio.charset.StandardCharsets; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder; import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.traccar.Context; import org.traccar.helper.Log; @@ -28,8 +27,9 @@ import org.traccar.model.Event; import org.traccar.model.Geofence; import org.traccar.model.Position; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.ning.http.client.AsyncHttpClient.BoundRequestBuilder; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; import com.ning.http.client.FluentCaseInsensitiveStringsMap; public abstract class EventForwarder { diff --git a/src/org/traccar/notification/JsonTypeEventForwarder.java b/src/org/traccar/notification/JsonTypeEventForwarder.java index 196a4eca5..c1e4220d0 100644 --- a/src/org/traccar/notification/JsonTypeEventForwarder.java +++ b/src/org/traccar/notification/JsonTypeEventForwarder.java @@ -9,7 +9,6 @@ public class JsonTypeEventForwarder extends EventForwarder { @Override protected String getContentType() { - return "application/json; charset=utf-8"; } diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java index ba3fdbecb..114825a83 100644 --- a/src/org/traccar/notification/NotificationFormatter.java +++ b/src/org/traccar/notification/NotificationFormatter.java @@ -88,7 +88,7 @@ public final class NotificationFormatter { public static MailMessage formatMailMessage(long userId, Event event, Position position) { String templatePath = Context.getConfig().getString("mail.templatesPath", "mail"); VelocityContext velocityContext = prepareContext(userId, event, position); - String formattedMessage = formatterLogic(velocityContext, userId, event, position, templatePath); + String formattedMessage = formatMessage(velocityContext, userId, event, position, templatePath); return new MailMessage((String) velocityContext.get("subject"), formattedMessage); } @@ -96,10 +96,10 @@ public final class NotificationFormatter { public static String formatSmsMessage(long userId, Event event, Position position) { String templatePath = Context.getConfig().getString("sms.templatesPath", "sms"); - return formatterLogic(null, userId, event, position, templatePath); + return formatMessage(null, userId, event, position, templatePath); } - private static String formatterLogic(VelocityContext vc, Long userId, Event event, Position position, + private static String formatMessage(VelocityContext vc, Long userId, Event event, Position position, String templatePath) { VelocityContext velocityContext = vc; -- cgit v1.2.3