From 2309d53f52f25efe00f2195a58c448506a2605ab Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Mon, 13 Mar 2017 17:52:28 +0500 Subject: - Add timezone field to User and Server model - Pass Velocity DateTool to templates - Adjusted templates to use timezone --- pom.xml | 5 +++++ schema/changelog-3.11.xml | 10 +++++++++- setup/default.xml | 6 ++++-- src/org/traccar/model/Server.java | 15 +++++++++++++++ src/org/traccar/model/User.java | 14 ++++++++++++++ src/org/traccar/notification/NotificationFormatter.java | 5 +++++ src/org/traccar/reports/ReportUtils.java | 9 +++++++++ templates/mail/alarm.vm | 2 +- templates/mail/commandResult.vm | 2 +- templates/mail/deviceMoving.vm | 2 +- templates/mail/deviceOffline.vm | 2 +- templates/mail/deviceOnline.vm | 2 +- templates/mail/deviceOverspeed.vm | 2 +- templates/mail/deviceStopped.vm | 2 +- templates/mail/deviceUnknown.vm | 2 +- templates/mail/geofenceEnter.vm | 2 +- templates/mail/geofenceExit.vm | 2 +- templates/mail/ignitionOff.vm | 2 +- templates/mail/ignitionOn.vm | 2 +- templates/mail/maintenance.vm | 2 +- templates/sms/alarm.vm | 2 +- templates/sms/commandResult.vm | 2 +- templates/sms/deviceMoving.vm | 2 +- templates/sms/deviceOffline.vm | 2 +- templates/sms/deviceOnline.vm | 2 +- templates/sms/deviceOverspeed.vm | 2 +- templates/sms/deviceStopped.vm | 2 +- templates/sms/deviceUnknown.vm | 2 +- templates/sms/geofenceEnter.vm | 2 +- templates/sms/geofenceExit.vm | 2 +- templates/sms/ignitionOff.vm | 2 +- templates/sms/ignitionOn.vm | 2 +- templates/sms/maintenance.vm | 2 +- 33 files changed, 87 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index 952a24795..4ef3bb40f 100644 --- a/pom.xml +++ b/pom.xml @@ -143,6 +143,11 @@ velocity 1.7 + + org.apache.velocity + velocity-tools + 2.0 + org.mnode.ical4j ical4j diff --git a/schema/changelog-3.11.xml b/schema/changelog-3.11.xml index c169e1146..1fdaa3f17 100644 --- a/schema/changelog-3.11.xml +++ b/schema/changelog-3.11.xml @@ -11,7 +11,7 @@ - + @@ -20,6 +20,14 @@ + + + + + + + + diff --git a/setup/default.xml b/setup/default.xml index 9fe49edbe..90bdc1973 100644 --- a/setup/default.xml +++ b/setup/default.xml @@ -51,6 +51,7 @@ longitude = :longitude, zoom = :zoom, twelveHourFormat = :twelveHourFormat, + timezone = :timezone, attributes = :attributes WHERE id = :id @@ -65,8 +66,8 @@ - INSERT INTO users (name, email, phone, hashedPassword, salt, readonly, admin, map, distanceUnit, speedUnit, latitude, longitude, zoom, twelveHourFormat, coordinateFormat, disabled, expirationTime, deviceLimit, userLimit, deviceReadonly, token, attributes) - VALUES (:name, :email, :phone, :hashedPassword, :salt, :readonly, :admin, :map, :distanceUnit, :speedUnit, :latitude, :longitude, :zoom, :twelveHourFormat, :coordinateFormat, :disabled, :expirationTime, :deviceLimit, :userLimit, :deviceReadonly, :token, :attributes) + INSERT INTO users (name, email, phone, hashedPassword, salt, readonly, admin, map, distanceUnit, speedUnit, latitude, longitude, zoom, twelveHourFormat, coordinateFormat, disabled, expirationTime, deviceLimit, userLimit, deviceReadonly, token, timezone, attributes) + VALUES (:name, :email, :phone, :hashedPassword, :salt, :readonly, :admin, :map, :distanceUnit, :speedUnit, :latitude, :longitude, :zoom, :twelveHourFormat, :coordinateFormat, :disabled, :expirationTime, :deviceLimit, :userLimit, :deviceReadonly, :token, :timezone, :attributes) @@ -90,6 +91,7 @@ userLimit = :userLimit, deviceReadonly = :deviceReadonly, token = :token, + timezone = :timezone, attributes = :attributes WHERE id = :id diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java index b588a4de0..db3f021a9 100644 --- a/src/org/traccar/model/Server.java +++ b/src/org/traccar/model/Server.java @@ -15,6 +15,8 @@ */ package org.traccar.model; +import java.util.TimeZone; + import org.traccar.helper.Log; public class Server extends Extensible { @@ -166,4 +168,17 @@ public class Server extends Extensible { this.coordinateFormat = coordinateFormat; } + private String timezone; + + public void setTimezone(String timezone) { + if (timezone != null) { + this.timezone = TimeZone.getTimeZone(timezone).getID(); + } else { + this.timezone = null; + } + } + + public String getTimezone() { + return timezone; + } } diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index 274f2b2a2..71bb563a8 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -19,6 +19,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import org.traccar.helper.Hashing; import java.util.Date; +import java.util.TimeZone; public class User extends Extensible { @@ -265,4 +266,17 @@ public class User extends Extensible { return Hashing.validatePassword(password, hashedPassword, salt); } + private String timezone; + + public void setTimezone(String timezone) { + if (timezone != null) { + this.timezone = TimeZone.getTimeZone(timezone).getID(); + } else { + this.timezone = null; + } + } + + public String getTimezone() { + return timezone; + } } diff --git a/src/org/traccar/notification/NotificationFormatter.java b/src/org/traccar/notification/NotificationFormatter.java index cec238548..eae2681c9 100644 --- a/src/org/traccar/notification/NotificationFormatter.java +++ b/src/org/traccar/notification/NotificationFormatter.java @@ -18,10 +18,12 @@ package org.traccar.notification; import java.io.StringWriter; import java.nio.charset.StandardCharsets; +import java.util.Locale; import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.exception.ResourceNotFoundException; +import org.apache.velocity.tools.generic.DateTool; import org.traccar.Context; import org.traccar.helper.Log; import org.traccar.model.Device; @@ -48,6 +50,9 @@ public final class NotificationFormatter { velocityContext.put("geofence", Context.getGeofenceManager().getGeofence(event.getGeofenceId())); } velocityContext.put("webUrl", Context.getVelocityEngine().getProperty("web.url")); + velocityContext.put("dateTool", new DateTool()); + velocityContext.put("timezone", ReportUtils.getTimezone(userId)); + velocityContext.put("locale", Locale.getDefault()); return velocityContext; } diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 1402e10d4..968fb357b 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -24,6 +24,7 @@ import java.math.BigDecimal; import java.math.RoundingMode; import java.util.ArrayList; import java.util.Collection; +import java.util.TimeZone; public final class ReportUtils { @@ -46,6 +47,14 @@ public final class ReportUtils { return unit != null ? unit : "kn"; } + public static TimeZone getTimezone(long userId) { + String timezone = Context.getPermissionsManager().getUser(userId).getTimezone(); + if (timezone == null) { + timezone = Context.getPermissionsManager().getServer().getTimezone(); + } + return timezone != null ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault(); + } + public static Collection getDeviceList(Collection deviceIds, Collection groupIds) { Collection result = new ArrayList<>(); result.addAll(deviceIds); diff --git a/templates/mail/alarm.vm b/templates/mail/alarm.vm index b64b2126a..253c0b7a3 100644 --- a/templates/mail/alarm.vm +++ b/templates/mail/alarm.vm @@ -4,7 +4,7 @@ Device: $device.name
Alarm: $position.getString("alarm")
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/commandResult.vm b/templates/mail/commandResult.vm index 4c330584d..3d2a7ceb8 100644 --- a/templates/mail/commandResult.vm +++ b/templates/mail/commandResult.vm @@ -4,7 +4,7 @@ Device: $device.name
Result: $position.getString("result")
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceMoving.vm b/templates/mail/deviceMoving.vm index 9ad2d8bdc..a734e59b4 100644 --- a/templates/mail/deviceMoving.vm +++ b/templates/mail/deviceMoving.vm @@ -4,7 +4,7 @@ Device: $device.name
Moving
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceOffline.vm b/templates/mail/deviceOffline.vm index ee7e96f05..d77f4e6a9 100644 --- a/templates/mail/deviceOffline.vm +++ b/templates/mail/deviceOffline.vm @@ -4,7 +4,7 @@ Device: $device.name
Offline
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceOnline.vm b/templates/mail/deviceOnline.vm index 379b5cc80..9ea65c843 100644 --- a/templates/mail/deviceOnline.vm +++ b/templates/mail/deviceOnline.vm @@ -4,7 +4,7 @@ Device: $device.name
Online
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceOverspeed.vm b/templates/mail/deviceOverspeed.vm index a8a58a181..1836dacd5 100644 --- a/templates/mail/deviceOverspeed.vm +++ b/templates/mail/deviceOverspeed.vm @@ -11,7 +11,7 @@ Device: $device.name
Exceeds the speed: $speedString
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceStopped.vm b/templates/mail/deviceStopped.vm index 273e1c988..45f97e463 100644 --- a/templates/mail/deviceStopped.vm +++ b/templates/mail/deviceStopped.vm @@ -4,7 +4,7 @@ Device: $device.name
Stopped
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceUnknown.vm b/templates/mail/deviceUnknown.vm index 40b8fbfa7..73696bc47 100644 --- a/templates/mail/deviceUnknown.vm +++ b/templates/mail/deviceUnknown.vm @@ -4,7 +4,7 @@ Device: $device.name
Status is unknown
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/geofenceEnter.vm b/templates/mail/geofenceEnter.vm index 75d16617f..f0f84fb67 100644 --- a/templates/mail/geofenceEnter.vm +++ b/templates/mail/geofenceEnter.vm @@ -4,7 +4,7 @@ Device: $device.name
Has entered geofence: $geofence.name
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/geofenceExit.vm b/templates/mail/geofenceExit.vm index 6d4d1639d..90e61b618 100644 --- a/templates/mail/geofenceExit.vm +++ b/templates/mail/geofenceExit.vm @@ -4,7 +4,7 @@ Device: $device.name
Has exited geofence: $geofence.name
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/ignitionOff.vm b/templates/mail/ignitionOff.vm index 3a3212b12..407577640 100644 --- a/templates/mail/ignitionOff.vm +++ b/templates/mail/ignitionOff.vm @@ -4,7 +4,7 @@ Device: $device.name
Ignition OFF
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/ignitionOn.vm b/templates/mail/ignitionOn.vm index bbe6c40f6..ad039a849 100644 --- a/templates/mail/ignitionOn.vm +++ b/templates/mail/ignitionOn.vm @@ -4,7 +4,7 @@ Device: $device.name
Ignition ON
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/maintenance.vm b/templates/mail/maintenance.vm index c94c35cc4..2951fdfda 100644 --- a/templates/mail/maintenance.vm +++ b/templates/mail/maintenance.vm @@ -4,7 +4,7 @@ Device: $device.name
Maintenance is required
-Time: $event.serverTime
+Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/sms/alarm.vm b/templates/sms/alarm.vm index e35a573b3..0277fbddf 100644 --- a/templates/sms/alarm.vm +++ b/templates/sms/alarm.vm @@ -1 +1 @@ -$device.name alarm: $position.getString("alarm") at $event.serverTime +$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/commandResult.vm b/templates/sms/commandResult.vm index 38fddcf25..4962eaa36 100644 --- a/templates/sms/commandResult.vm +++ b/templates/sms/commandResult.vm @@ -1 +1 @@ -$device.name command result received: $position.getString("result") at $event.serverTime +$device.name command result received: $position.getString("result") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceMoving.vm b/templates/sms/deviceMoving.vm index febae6331..4f62421b2 100644 --- a/templates/sms/deviceMoving.vm +++ b/templates/sms/deviceMoving.vm @@ -1 +1 @@ -$device.name moving at $event.serverTime +$device.name moving at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOffline.vm b/templates/sms/deviceOffline.vm index 490502946..7df007f81 100644 --- a/templates/sms/deviceOffline.vm +++ b/templates/sms/deviceOffline.vm @@ -1 +1 @@ -$device.name offline at $event.serverTime +$device.name offline at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOnline.vm b/templates/sms/deviceOnline.vm index e8bc0a5bf..48e81ec75 100644 --- a/templates/sms/deviceOnline.vm +++ b/templates/sms/deviceOnline.vm @@ -1 +1 @@ -$device.name online at $event.serverTime +$device.name online at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOverspeed.vm b/templates/sms/deviceOverspeed.vm index 63f967bc3..4e3219a18 100644 --- a/templates/sms/deviceOverspeed.vm +++ b/templates/sms/deviceOverspeed.vm @@ -5,4 +5,4 @@ #else #set($speedString = "$position.speed kn") #end -$device.name exceeds the speed $speedString at $event.serverTime +$device.name exceeds the speed $speedString at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceStopped.vm b/templates/sms/deviceStopped.vm index cf9118cac..80e2c085f 100644 --- a/templates/sms/deviceStopped.vm +++ b/templates/sms/deviceStopped.vm @@ -1 +1 @@ -$device.name stopped at $event.serverTime +$device.name stopped at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceUnknown.vm b/templates/sms/deviceUnknown.vm index 533219799..150d05df1 100644 --- a/templates/sms/deviceUnknown.vm +++ b/templates/sms/deviceUnknown.vm @@ -1 +1 @@ -$device.name status is unknown at $event.serverTime +$device.name status is unknown at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/geofenceEnter.vm b/templates/sms/geofenceEnter.vm index 5a216f361..443b1c0a8 100644 --- a/templates/sms/geofenceEnter.vm +++ b/templates/sms/geofenceEnter.vm @@ -1 +1 @@ -$device.name has entered geofence $geofence.name at $event.serverTime +$device.name has entered geofence $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/geofenceExit.vm b/templates/sms/geofenceExit.vm index fd8a8409d..1314a7ebc 100644 --- a/templates/sms/geofenceExit.vm +++ b/templates/sms/geofenceExit.vm @@ -1 +1 @@ -$device.name has exited geofence $geofence.name at $event.serverTime +$device.name has exited geofence $geofence.name at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/ignitionOff.vm b/templates/sms/ignitionOff.vm index 6f90eb552..2795dc1a5 100644 --- a/templates/sms/ignitionOff.vm +++ b/templates/sms/ignitionOff.vm @@ -1 +1 @@ -$device.name ignition OFF at $event.serverTime +$device.name ignition OFF at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/ignitionOn.vm b/templates/sms/ignitionOn.vm index 9c0d79888..76a8fc676 100644 --- a/templates/sms/ignitionOn.vm +++ b/templates/sms/ignitionOn.vm @@ -1 +1 @@ -$device.name ignition ON at $event.serverTime +$device.name ignition ON at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/maintenance.vm b/templates/sms/maintenance.vm index f2e6940f6..2375feefb 100644 --- a/templates/sms/maintenance.vm +++ b/templates/sms/maintenance.vm @@ -1 +1 @@ -$device.name maintenance is required at $event.serverTime +$device.name maintenance is required at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) -- cgit v1.2.3 From 632e6ad06c435ca8d044e5ae3209cde36cf42743 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 14 Mar 2017 09:11:11 +0500 Subject: - Use ternary operator - Apply server.forceSettings to speed units, distance units and timezone - Use hyphens for date formatting --- pom.xml | 8 ++++---- src/org/traccar/model/Server.java | 6 +----- src/org/traccar/model/User.java | 6 +----- src/org/traccar/reports/ReportUtils.java | 6 +++--- templates/mail/alarm.vm | 2 +- templates/mail/commandResult.vm | 2 +- templates/mail/deviceMoving.vm | 2 +- templates/mail/deviceOffline.vm | 2 +- templates/mail/deviceOnline.vm | 2 +- templates/mail/deviceOverspeed.vm | 2 +- templates/mail/deviceStopped.vm | 2 +- templates/mail/deviceUnknown.vm | 2 +- templates/mail/geofenceEnter.vm | 2 +- templates/mail/geofenceExit.vm | 2 +- templates/mail/ignitionOff.vm | 2 +- templates/mail/ignitionOn.vm | 2 +- templates/mail/maintenance.vm | 2 +- templates/sms/alarm.vm | 2 +- templates/sms/commandResult.vm | 2 +- templates/sms/deviceMoving.vm | 2 +- templates/sms/deviceOffline.vm | 2 +- templates/sms/deviceOnline.vm | 2 +- templates/sms/deviceOverspeed.vm | 2 +- templates/sms/deviceStopped.vm | 2 +- templates/sms/deviceUnknown.vm | 2 +- templates/sms/geofenceEnter.vm | 2 +- templates/sms/geofenceExit.vm | 2 +- templates/sms/ignitionOff.vm | 2 +- templates/sms/ignitionOn.vm | 2 +- templates/sms/maintenance.vm | 2 +- 30 files changed, 35 insertions(+), 43 deletions(-) diff --git a/pom.xml b/pom.xml index 4ef3bb40f..8700c6ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -144,10 +144,10 @@ 1.7
- org.apache.velocity - velocity-tools - 2.0 - + org.apache.velocity + velocity-tools + 2.0 + org.mnode.ical4j ical4j diff --git a/src/org/traccar/model/Server.java b/src/org/traccar/model/Server.java index db3f021a9..4ded65204 100644 --- a/src/org/traccar/model/Server.java +++ b/src/org/traccar/model/Server.java @@ -171,11 +171,7 @@ public class Server extends Extensible { private String timezone; public void setTimezone(String timezone) { - if (timezone != null) { - this.timezone = TimeZone.getTimeZone(timezone).getID(); - } else { - this.timezone = null; - } + this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null; } public String getTimezone() { diff --git a/src/org/traccar/model/User.java b/src/org/traccar/model/User.java index 71bb563a8..366ced503 100644 --- a/src/org/traccar/model/User.java +++ b/src/org/traccar/model/User.java @@ -269,11 +269,7 @@ public class User extends Extensible { private String timezone; public void setTimezone(String timezone) { - if (timezone != null) { - this.timezone = TimeZone.getTimeZone(timezone).getID(); - } else { - this.timezone = null; - } + this.timezone = timezone != null ? TimeZone.getTimeZone(timezone).getID() : null; } public String getTimezone() { diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 968fb357b..3699b1bea 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -33,7 +33,7 @@ public final class ReportUtils { public static String getDistanceUnit(long userId) { String unit = Context.getPermissionsManager().getUser(userId).getDistanceUnit(); - if (unit == null) { + if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) { unit = Context.getPermissionsManager().getServer().getDistanceUnit(); } return unit != null ? unit : "km"; @@ -41,7 +41,7 @@ public final class ReportUtils { public static String getSpeedUnit(long userId) { String unit = Context.getPermissionsManager().getUser(userId).getSpeedUnit(); - if (unit == null) { + if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) { unit = Context.getPermissionsManager().getServer().getSpeedUnit(); } return unit != null ? unit : "kn"; @@ -49,7 +49,7 @@ public final class ReportUtils { public static TimeZone getTimezone(long userId) { String timezone = Context.getPermissionsManager().getUser(userId).getTimezone(); - if (timezone == null) { + if (timezone == null || Context.getPermissionsManager().getServer().getForceSettings()) { timezone = Context.getPermissionsManager().getServer().getTimezone(); } return timezone != null ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault(); diff --git a/templates/mail/alarm.vm b/templates/mail/alarm.vm index 253c0b7a3..8f1164291 100644 --- a/templates/mail/alarm.vm +++ b/templates/mail/alarm.vm @@ -4,7 +4,7 @@ Device: $device.name
Alarm: $position.getString("alarm")
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/commandResult.vm b/templates/mail/commandResult.vm index 3d2a7ceb8..5b6d8ef3e 100644 --- a/templates/mail/commandResult.vm +++ b/templates/mail/commandResult.vm @@ -4,7 +4,7 @@ Device: $device.name
Result: $position.getString("result")
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceMoving.vm b/templates/mail/deviceMoving.vm index a734e59b4..6e98af1de 100644 --- a/templates/mail/deviceMoving.vm +++ b/templates/mail/deviceMoving.vm @@ -4,7 +4,7 @@ Device: $device.name
Moving
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceOffline.vm b/templates/mail/deviceOffline.vm index d77f4e6a9..1f6d02fb2 100644 --- a/templates/mail/deviceOffline.vm +++ b/templates/mail/deviceOffline.vm @@ -4,7 +4,7 @@ Device: $device.name
Offline
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceOnline.vm b/templates/mail/deviceOnline.vm index 9ea65c843..9211eff11 100644 --- a/templates/mail/deviceOnline.vm +++ b/templates/mail/deviceOnline.vm @@ -4,7 +4,7 @@ Device: $device.name
Online
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/deviceOverspeed.vm b/templates/mail/deviceOverspeed.vm index 1836dacd5..3b203ddcd 100644 --- a/templates/mail/deviceOverspeed.vm +++ b/templates/mail/deviceOverspeed.vm @@ -11,7 +11,7 @@ Device: $device.name
Exceeds the speed: $speedString
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceStopped.vm b/templates/mail/deviceStopped.vm index 45f97e463..2ec0f8db9 100644 --- a/templates/mail/deviceStopped.vm +++ b/templates/mail/deviceStopped.vm @@ -4,7 +4,7 @@ Device: $device.name
Stopped
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/deviceUnknown.vm b/templates/mail/deviceUnknown.vm index 73696bc47..34fa01a8a 100644 --- a/templates/mail/deviceUnknown.vm +++ b/templates/mail/deviceUnknown.vm @@ -4,7 +4,7 @@ Device: $device.name
Status is unknown
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Link: $webUrl?eventId=$event.id diff --git a/templates/mail/geofenceEnter.vm b/templates/mail/geofenceEnter.vm index f0f84fb67..e83a0de62 100644 --- a/templates/mail/geofenceEnter.vm +++ b/templates/mail/geofenceEnter.vm @@ -4,7 +4,7 @@ Device: $device.name
Has entered geofence: $geofence.name
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/geofenceExit.vm b/templates/mail/geofenceExit.vm index 90e61b618..3557f6eb2 100644 --- a/templates/mail/geofenceExit.vm +++ b/templates/mail/geofenceExit.vm @@ -4,7 +4,7 @@ Device: $device.name
Has exited geofence: $geofence.name
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/ignitionOff.vm b/templates/mail/ignitionOff.vm index 407577640..0281eef02 100644 --- a/templates/mail/ignitionOff.vm +++ b/templates/mail/ignitionOff.vm @@ -4,7 +4,7 @@ Device: $device.name
Ignition OFF
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/ignitionOn.vm b/templates/mail/ignitionOn.vm index ad039a849..27135a7f0 100644 --- a/templates/mail/ignitionOn.vm +++ b/templates/mail/ignitionOn.vm @@ -4,7 +4,7 @@ Device: $device.name
Ignition ON
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/mail/maintenance.vm b/templates/mail/maintenance.vm index 2951fdfda..7f69b6c0d 100644 --- a/templates/mail/maintenance.vm +++ b/templates/mail/maintenance.vm @@ -4,7 +4,7 @@ Device: $device.name
Maintenance is required
-Time: $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone)
+Time: $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone)
Point: #{if}($position.address)$position.address#{else}$position.latitude°, $position.longitude°#{end}
diff --git a/templates/sms/alarm.vm b/templates/sms/alarm.vm index 0277fbddf..389341cf1 100644 --- a/templates/sms/alarm.vm +++ b/templates/sms/alarm.vm @@ -1 +1 @@ -$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name alarm: $position.getString("alarm") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/commandResult.vm b/templates/sms/commandResult.vm index 4962eaa36..4a327d850 100644 --- a/templates/sms/commandResult.vm +++ b/templates/sms/commandResult.vm @@ -1 +1 @@ -$device.name command result received: $position.getString("result") at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name command result received: $position.getString("result") at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceMoving.vm b/templates/sms/deviceMoving.vm index 4f62421b2..aaa72ab0d 100644 --- a/templates/sms/deviceMoving.vm +++ b/templates/sms/deviceMoving.vm @@ -1 +1 @@ -$device.name moving at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name moving at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOffline.vm b/templates/sms/deviceOffline.vm index 7df007f81..8c4a02335 100644 --- a/templates/sms/deviceOffline.vm +++ b/templates/sms/deviceOffline.vm @@ -1 +1 @@ -$device.name offline at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name offline at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOnline.vm b/templates/sms/deviceOnline.vm index 48e81ec75..62854feb0 100644 --- a/templates/sms/deviceOnline.vm +++ b/templates/sms/deviceOnline.vm @@ -1 +1 @@ -$device.name online at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name online at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceOverspeed.vm b/templates/sms/deviceOverspeed.vm index 4e3219a18..3c9eae628 100644 --- a/templates/sms/deviceOverspeed.vm +++ b/templates/sms/deviceOverspeed.vm @@ -5,4 +5,4 @@ #else #set($speedString = "$position.speed kn") #end -$device.name exceeds the speed $speedString at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name exceeds the speed $speedString at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceStopped.vm b/templates/sms/deviceStopped.vm index 80e2c085f..c2437b5f6 100644 --- a/templates/sms/deviceStopped.vm +++ b/templates/sms/deviceStopped.vm @@ -1 +1 @@ -$device.name stopped at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name stopped at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/deviceUnknown.vm b/templates/sms/deviceUnknown.vm index 150d05df1..07f39f3a9 100644 --- a/templates/sms/deviceUnknown.vm +++ b/templates/sms/deviceUnknown.vm @@ -1 +1 @@ -$device.name status is unknown at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name status is unknown at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/geofenceEnter.vm b/templates/sms/geofenceEnter.vm index 443b1c0a8..9dd861931 100644 --- a/templates/sms/geofenceEnter.vm +++ b/templates/sms/geofenceEnter.vm @@ -1 +1 @@ -$device.name has entered geofence $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name has entered geofence $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/geofenceExit.vm b/templates/sms/geofenceExit.vm index 1314a7ebc..8553458f7 100644 --- a/templates/sms/geofenceExit.vm +++ b/templates/sms/geofenceExit.vm @@ -1 +1 @@ -$device.name has exited geofence $geofence.name at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name has exited geofence $geofence.name at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/ignitionOff.vm b/templates/sms/ignitionOff.vm index 2795dc1a5..ddf860413 100644 --- a/templates/sms/ignitionOff.vm +++ b/templates/sms/ignitionOff.vm @@ -1 +1 @@ -$device.name ignition OFF at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name ignition OFF at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/ignitionOn.vm b/templates/sms/ignitionOn.vm index 76a8fc676..00b365be9 100644 --- a/templates/sms/ignitionOn.vm +++ b/templates/sms/ignitionOn.vm @@ -1 +1 @@ -$device.name ignition ON at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name ignition ON at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) diff --git a/templates/sms/maintenance.vm b/templates/sms/maintenance.vm index 2375feefb..554b74400 100644 --- a/templates/sms/maintenance.vm +++ b/templates/sms/maintenance.vm @@ -1 +1 @@ -$device.name maintenance is required at $dateTool.format("YYYY.MM.dd HH:mm:ss", $event.serverTime, $locale, $timezone) +$device.name maintenance is required at $dateTool.format("YYYY-MM-dd HH:mm:ss", $event.serverTime, $locale, $timezone) -- cgit v1.2.3 From 31ab23aeacce2ed9777ea38cdaf4cda199fc3a86 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 14 Mar 2017 09:29:24 +0500 Subject: Fix forceSettings applying --- src/org/traccar/reports/ReportUtils.java | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 3699b1bea..9614ecf71 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -32,25 +32,37 @@ public final class ReportUtils { } public static String getDistanceUnit(long userId) { - String unit = Context.getPermissionsManager().getUser(userId).getDistanceUnit(); - if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) { - unit = Context.getPermissionsManager().getServer().getDistanceUnit(); + String unit; + String userUnit = Context.getPermissionsManager().getUser(userId).getDistanceUnit(); + String serverUnit = Context.getPermissionsManager().getServer().getDistanceUnit(); + if (Context.getPermissionsManager().getServer().getForceSettings()) { + unit = serverUnit != null ? serverUnit : userUnit; + } else { + unit = userUnit != null ? userUnit : serverUnit; } return unit != null ? unit : "km"; } public static String getSpeedUnit(long userId) { - String unit = Context.getPermissionsManager().getUser(userId).getSpeedUnit(); - if (unit == null || Context.getPermissionsManager().getServer().getForceSettings()) { - unit = Context.getPermissionsManager().getServer().getSpeedUnit(); + String unit; + String userUnit = Context.getPermissionsManager().getUser(userId).getSpeedUnit(); + String serverUnit = Context.getPermissionsManager().getServer().getSpeedUnit(); + if (Context.getPermissionsManager().getServer().getForceSettings()) { + unit = serverUnit != null ? serverUnit : userUnit; + } else { + unit = userUnit != null ? userUnit : serverUnit; } return unit != null ? unit : "kn"; } public static TimeZone getTimezone(long userId) { - String timezone = Context.getPermissionsManager().getUser(userId).getTimezone(); - if (timezone == null || Context.getPermissionsManager().getServer().getForceSettings()) { - timezone = Context.getPermissionsManager().getServer().getTimezone(); + String timezone; + String userTimezone = Context.getPermissionsManager().getUser(userId).getTimezone(); + String serverTimezone = Context.getPermissionsManager().getServer().getTimezone(); + if (Context.getPermissionsManager().getServer().getForceSettings()) { + timezone = serverTimezone != null ? serverTimezone : userTimezone; + } else { + timezone = userTimezone != null ? userTimezone : serverTimezone; } return timezone != null ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault(); } -- cgit v1.2.3 From e1deb7ae138a8821fd91cf85321b68c5a73675c7 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 14 Mar 2017 12:05:25 +0500 Subject: Implemented helper lookupPreference --- src/org/traccar/database/PermissionsManager.java | 30 ++++++++++++++++++++++++ src/org/traccar/reports/ReportUtils.java | 29 +++-------------------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index 5313859df..0607a2141 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -25,6 +25,8 @@ import org.traccar.model.Server; import org.traccar.model.User; import org.traccar.model.UserPermission; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; @@ -395,4 +397,32 @@ public class PermissionsManager { return users.get(usersTokens.get(token)); } + public Object lookupPreference(long userId, String key, Object defaultValue) { + String methodName = "get" + key.substring(0, 1).toUpperCase() + key.substring(1); + Object preference; + Object serverPreference = null; + Object userPreference = null; + try { + Method method = null; + method = User.class.getMethod(methodName, (Class[]) null); + if (method != null) { + userPreference = method.invoke(users.get(userId), (Object[]) null); + } + method = null; + method = Server.class.getMethod(methodName, (Class[]) null); + if (method != null) { + serverPreference = method.invoke(server, (Object[]) null); + } + } catch (NoSuchMethodException | SecurityException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException exception) { + return defaultValue; + } + if (server.getForceSettings()) { + preference = serverPreference != null ? serverPreference : userPreference; + } else { + preference = userPreference != null ? userPreference : serverPreference; + } + return preference != null ? preference : defaultValue; + } + } diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java index 9614ecf71..ed97c6857 100644 --- a/src/org/traccar/reports/ReportUtils.java +++ b/src/org/traccar/reports/ReportUtils.java @@ -32,38 +32,15 @@ public final class ReportUtils { } public static String getDistanceUnit(long userId) { - String unit; - String userUnit = Context.getPermissionsManager().getUser(userId).getDistanceUnit(); - String serverUnit = Context.getPermissionsManager().getServer().getDistanceUnit(); - if (Context.getPermissionsManager().getServer().getForceSettings()) { - unit = serverUnit != null ? serverUnit : userUnit; - } else { - unit = userUnit != null ? userUnit : serverUnit; - } - return unit != null ? unit : "km"; + return (String) Context.getPermissionsManager().lookupPreference(userId, "distanceUnit", "km"); } public static String getSpeedUnit(long userId) { - String unit; - String userUnit = Context.getPermissionsManager().getUser(userId).getSpeedUnit(); - String serverUnit = Context.getPermissionsManager().getServer().getSpeedUnit(); - if (Context.getPermissionsManager().getServer().getForceSettings()) { - unit = serverUnit != null ? serverUnit : userUnit; - } else { - unit = userUnit != null ? userUnit : serverUnit; - } - return unit != null ? unit : "kn"; + return (String) Context.getPermissionsManager().lookupPreference(userId, "speedUnit", "kn"); } public static TimeZone getTimezone(long userId) { - String timezone; - String userTimezone = Context.getPermissionsManager().getUser(userId).getTimezone(); - String serverTimezone = Context.getPermissionsManager().getServer().getTimezone(); - if (Context.getPermissionsManager().getServer().getForceSettings()) { - timezone = serverTimezone != null ? serverTimezone : userTimezone; - } else { - timezone = userTimezone != null ? userTimezone : serverTimezone; - } + String timezone = (String) Context.getPermissionsManager().lookupPreference(userId, "timezone", null); return timezone != null ? TimeZone.getTimeZone(timezone) : TimeZone.getDefault(); } -- cgit v1.2.3 From 0e2e23f0d1bfef546992c399a7f62aaa4d6f7ad6 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 14 Mar 2017 12:46:09 +0500 Subject: Fix indentation --- src/org/traccar/database/PermissionsManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index 0607a2141..5814a1203 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -415,7 +415,7 @@ public class PermissionsManager { } } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException exception) { - return defaultValue; + return defaultValue; } if (server.getForceSettings()) { preference = serverPreference != null ? serverPreference : userPreference; -- cgit v1.2.3 From 1b499620810fe6d376a4a72c5ab66b6be2f4af5c Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 14 Mar 2017 14:21:18 +0500 Subject: Combine some exceptions to ReflectiveOperationException --- src/org/traccar/database/PermissionsManager.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index 5814a1203..e4bd6f5db 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -25,7 +25,6 @@ import org.traccar.model.Server; import org.traccar.model.User; import org.traccar.model.UserPermission; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.sql.SQLException; import java.util.ArrayList; @@ -413,8 +412,7 @@ public class PermissionsManager { if (method != null) { serverPreference = method.invoke(server, (Object[]) null); } - } catch (NoSuchMethodException | SecurityException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException exception) { + } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException exception) { return defaultValue; } if (server.getForceSettings()) { -- cgit v1.2.3