aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/reports/ReportUtils.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-01 16:14:15 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-08-01 16:14:15 +1200
commitbf8a7aac4921d17c086e6d35e44a1bc2e37888b8 (patch)
tree166787aa64665c8699c16b17382ae1ec68035bea /src/org/traccar/reports/ReportUtils.java
parentb65dd20c5e8c7fc9b26cb27154394d2afdbd5316 (diff)
downloadtrackermap-server-bf8a7aac4921d17c086e6d35e44a1bc2e37888b8.tar.gz
trackermap-server-bf8a7aac4921d17c086e6d35e44a1bc2e37888b8.tar.bz2
trackermap-server-bf8a7aac4921d17c086e6d35e44a1bc2e37888b8.zip
Option to limit report period
Diffstat (limited to 'src/org/traccar/reports/ReportUtils.java')
-rw-r--r--src/org/traccar/reports/ReportUtils.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/org/traccar/reports/ReportUtils.java b/src/org/traccar/reports/ReportUtils.java
index cf94030ab..540feb6c6 100644
--- a/src/org/traccar/reports/ReportUtils.java
+++ b/src/org/traccar/reports/ReportUtils.java
@@ -40,6 +40,7 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
@@ -49,6 +50,13 @@ public final class ReportUtils {
private ReportUtils() {
}
+ public static void checkPeriodLimit(Date from, Date to) {
+ long limit = Context.getConfig().getLong("report.periodLimit") * 1000;
+ if (limit > 0 && to.getTime() - from.getTime() > limit) {
+ throw new IllegalArgumentException("Time period exceeds the limit");
+ }
+ }
+
public static String getDistanceUnit(long userId) {
return (String) Context.getPermissionsManager().lookupPreference(userId, "distanceUnit", "km");
}