diff options
author | Anton Tananaev <atananaev@lyft.com> | 2020-12-28 17:02:23 -0800 |
---|---|---|
committer | Anton Tananaev <atananaev@lyft.com> | 2020-12-28 17:02:23 -0800 |
commit | 51704590a835057bf4850a5eaf8c5037d20f648a (patch) | |
tree | c38acebce6cfec36ead21918d6272a99452b9ac5 /src/main/java/org/traccar/config | |
parent | 551298664bbac541450d83a021a2f8d77e65b216 (diff) | |
download | traccar-server-51704590a835057bf4850a5eaf8c5037d20f648a.tar.gz traccar-server-51704590a835057bf4850a5eaf8c5037d20f648a.tar.bz2 traccar-server-51704590a835057bf4850a5eaf8c5037d20f648a.zip |
Migrate long config keys
Diffstat (limited to 'src/main/java/org/traccar/config')
-rw-r--r-- | src/main/java/org/traccar/config/Config.java | 22 | ||||
-rw-r--r-- | src/main/java/org/traccar/config/Keys.java | 86 |
2 files changed, 97 insertions, 11 deletions
diff --git a/src/main/java/org/traccar/config/Config.java b/src/main/java/org/traccar/config/Config.java index 6cc21cbeb..713f5c607 100644 --- a/src/main/java/org/traccar/config/Config.java +++ b/src/main/java/org/traccar/config/Config.java @@ -117,17 +117,17 @@ public class Config { } public long getLong(ConfigKey<Long> key) { - return getLong(key.getKey()); - } - - @Deprecated - public long getLong(String key) { - return getLong(key, 0); - } - - @Deprecated - public long getLong(String key, long defaultValue) { - return hasKey(key) ? Long.parseLong(getString(key)) : defaultValue; + String value = getString(key.getKey()); + if (value != null) { + return Long.parseLong(value); + } else { + Long defaultValue = key.getDefaultValue(); + if (defaultValue != null) { + return defaultValue; + } else { + return 0; + } + } } public double getDouble(ConfigKey<Double> key) { diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java index 3a42a66a1..ea3176afd 100644 --- a/src/main/java/org/traccar/config/Keys.java +++ b/src/main/java/org/traccar/config/Keys.java @@ -162,6 +162,45 @@ public final class Keys { Collections.singletonList(KeyType.GLOBAL)); /** + * Default category for auto-registered devices. + */ + public static final ConfigKey<String> DATABASE_REGISTER_UNKNOWN_DEFAULT_CATEGORY = new ConfigKey<>( + "database.registerUnknown.defaultCategory", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * The group id assigned to auto-registered devices. + */ + public static final ConfigKey<Long> DATABASE_REGISTER_UNKNOWN_DEFAULT_GROUP_ID = new ConfigKey<>( + "database.registerUnknown.defaultGroupId", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * Minimum device refresh timeout in seconds. Default timeout is 5 minutes. + */ + public static final ConfigKey<Long> DATABASE_REFRESH_DELAY = new ConfigKey<>( + "database.refreshDelay", + Collections.singletonList(KeyType.GLOBAL), + 300L); + + /** + * If no data is reported by a device for the given amount of time, status changes from online to unknown. Value is + * in seconds. Default timeout is 10 minutes. + */ + public static final ConfigKey<Long> STATUS_TIMEOUT = new ConfigKey<>( + "status.timeout", + Collections.singletonList(KeyType.GLOBAL), + 600L); + + /** + * WebSocket connection timeout in milliseconds. Default timeout is 10 minutes. + */ + public static final ConfigKey<Long> WEB_TIMEOUT = new ConfigKey<>( + "web.timeout", + Collections.singletonList(KeyType.GLOBAL), + 60000L); + + /** * Enable positions forwarding to other web server. */ public static final ConfigKey<Boolean> FORWARD_ENABLE = new ConfigKey<>( @@ -234,6 +273,53 @@ public final class Keys { Collections.singletonList(KeyType.GLOBAL)); /** + * Maximum time period for reports in seconds. Can be useful to prevent users to request unreasonably long reports. + * By default there is no limit. + */ + public static final ConfigKey<Long> REPORT_PERIOD_LIMIT = new ConfigKey<>( + "report.periodLimit", + Collections.singletonList(KeyType.GLOBAL)); + + /** + * Trips less than minimal duration and minimal distance are ignored. 300 seconds and 500 meters are default. + */ + public static final ConfigKey<Long> REPORT_TRIP_MINIMAL_TRIP_DISTANCE = new ConfigKey<>( + "report.trip.minimalTripDistance", + Collections.singletonList(KeyType.GLOBAL), + 500L); + + /** + * Trips less than minimal duration and minimal distance are ignored. 300 seconds and 500 meters are default. + */ + public static final ConfigKey<Long> REPORT_TRIP_MINIMAL_TRIP_DURATION = new ConfigKey<>( + "report.trip.minimalTripDuration", + Collections.singletonList(KeyType.GLOBAL), + 300L); + + /** + * Parking less than minimal duration does not cut trip. Default 300 seconds. + */ + public static final ConfigKey<Long> REPORT_TRIP_MINIMAL_PARKING_DURATION = new ConfigKey<>( + "report.trip.minimalParkingDuration", + Collections.singletonList(KeyType.GLOBAL), + 300L); + + /** + * Gaps of more than specified time are counted as stops. Default value is one hour. + */ + public static final ConfigKey<Long> REPORT_TRIP_MINIMAL_NO_DATA_DURATION = new ConfigKey<>( + "report.trip.minimalNoDataDuration", + Collections.singletonList(KeyType.GLOBAL), + 3600L); + + /** + * Flag to enable ignition use for trips calculation. + */ + public static final ConfigKey<Boolean> REPORT_TRIP_USE_IGNITION = new ConfigKey<>( + "report.trip.useIgnition", + Collections.singletonList(KeyType.GLOBAL)); + + /** * Boolean flag to enable or disable position filtering. */ public static final ConfigKey<Boolean> FILTER_ENABLE = new ConfigKey<>( |