aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <atananaev@lyft.com>2020-12-29 13:05:07 -0800
committerAnton Tananaev <atananaev@lyft.com>2020-12-29 13:05:07 -0800
commitf94951e7e78956b2bbd438665ff290a472afde76 (patch)
tree21ae964507b4e4e3a3c7f657e9057375c35701d1 /src
parent152d8fe43e4e7c15308ea39a19ac6c10da871ef7 (diff)
downloadtrackermap-server-f94951e7e78956b2bbd438665ff290a472afde76.tar.gz
trackermap-server-f94951e7e78956b2bbd438665ff290a472afde76.tar.bz2
trackermap-server-f94951e7e78956b2bbd438665ff290a472afde76.zip
Migrate more boolean keys
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/BaseProtocolDecoder.java5
-rw-r--r--src/main/java/org/traccar/config/Keys.java123
-rw-r--r--src/main/java/org/traccar/database/DataManager.java2
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java2
-rw-r--r--src/main/java/org/traccar/database/NotificationManager.java3
-rw-r--r--src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java21
-rw-r--r--src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java6
-rw-r--r--src/main/java/org/traccar/protocol/H02ProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/Mta6Protocol.java5
-rw-r--r--src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java3
-rw-r--r--src/main/java/org/traccar/protocol/WialonProtocol.java8
-rw-r--r--src/main/java/org/traccar/protocol/XexunProtocol.java5
-rw-r--r--src/main/java/org/traccar/reports/ReportUtils.java6
-rw-r--r--src/main/java/org/traccar/web/WebServer.java4
16 files changed, 170 insertions, 32 deletions
diff --git a/src/main/java/org/traccar/BaseProtocolDecoder.java b/src/main/java/org/traccar/BaseProtocolDecoder.java
index 4c35bb471..78282b4a5 100644
--- a/src/main/java/org/traccar/BaseProtocolDecoder.java
+++ b/src/main/java/org/traccar/BaseProtocolDecoder.java
@@ -21,6 +21,7 @@ import io.netty.handler.codec.http.HttpRequestDecoder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.config.Config;
+import org.traccar.config.Keys;
import org.traccar.database.CommandsManager;
import org.traccar.database.ConnectionManager;
import org.traccar.database.IdentityManager;
@@ -117,10 +118,10 @@ public abstract class BaseProtocolDecoder extends ExtendedObjectDecoder {
} catch (Exception e) {
LOGGER.warn("Find device error", e);
}
- if (deviceId == 0 && config.getBoolean("database.registerUnknown")) {
+ if (deviceId == 0 && config.getBoolean(Keys.DATABASE_REGISTER_UNKNOWN)) {
return identityManager.addUnknownDevice(uniqueIds[0]);
}
- if (device != null && !device.getDisabled() || config.getBoolean("database.storeDisabled")) {
+ if (device != null && !device.getDisabled()) {
return deviceId;
}
StringBuilder message = new StringBuilder();
diff --git a/src/main/java/org/traccar/config/Keys.java b/src/main/java/org/traccar/config/Keys.java
index 3f09190a1..ea0cf4961 100644
--- a/src/main/java/org/traccar/config/Keys.java
+++ b/src/main/java/org/traccar/config/Keys.java
@@ -59,6 +59,85 @@ public final class Keys {
Collections.singletonList(KeyType.GLOBAL));
/**
+ * Enable extended functionality for the protocol. The reason it's disabled by default is that not all devices
+ * support it.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_EXTENDED = new ConfigSuffix<>(
+ ".extended",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Decode string as UTF8 instead of ASCII. Only applicable for some protocols.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_UTF8 = new ConfigSuffix<>(
+ ".utf8",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Enable CAN decoding for the protocol. Similar to 'extended' configuration, it's not supported for some devices.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_CAN = new ConfigSuffix<>(
+ ".can",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Indicates whether server acknowledgement is required. Only applicable for some protocols.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_ACK = new ConfigSuffix<>(
+ ".ack",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Ignore device reported fix time. Useful in case some devices report invalid time. Currently only available for
+ * GL200 protocol.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_IGNORE_FIX_TIME = new ConfigSuffix<>(
+ ".ignoreFixTime",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Decode additional TK103 attributes. Not supported for some devices.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_DECODE_LOW = new ConfigSuffix<>(
+ ".decodeLow",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Use long date format for Atrack protocol.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_LONG_DATE = new ConfigSuffix<>(
+ ".longDate",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Use decimal fuel value format for Atrack protocol.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_DECIMAL_FUEL = new ConfigSuffix<>(
+ ".decimalFuel",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Indicates additional custom attributes for Atrack protocol.
+ */
+ public static final ConfigSuffix<Boolean> PROTOCOL_CUSTOM = new ConfigSuffix<>(
+ ".custom",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Custom format string for Atrack protocol.
+ */
+ public static final ConfigSuffix<String> PROTOCOL_FORM = new ConfigSuffix<>(
+ ".form",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Alarm mapping for Atrack protocol.
+ */
+ public static final ConfigSuffix<String> PROTOCOL_ALARM_MAP = new ConfigSuffix<>(
+ ".alarmMap",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
* Server wide connection timeout value in seconds. See protocol timeout for more information.
*/
public static final ConfigKey<Integer> SERVER_TIMEOUT = new ConfigKey<>(
@@ -206,6 +285,21 @@ public final class Keys {
Collections.singletonList(KeyType.GLOBAL));
/**
+ * By default server syncs with the database if it encounters and unknown device. This flag allows to disable that
+ * behavior to improve performance in some cases.
+ */
+ public static final ConfigKey<Boolean> DATABASE_IGNORE_UNKNOWN = new ConfigKey<>(
+ "database.ignoreUnknown",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Automatically register unknown devices in the database.
+ */
+ public static final ConfigKey<Boolean> DATABASE_REGISTER_UNKNOWN = new ConfigKey<>(
+ "database.registerUnknown",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
* Default category for auto-registered devices.
*/
public static final ConfigKey<String> DATABASE_REGISTER_UNKNOWN_DEFAULT_CATEGORY = new ConfigKey<>(
@@ -264,6 +358,13 @@ public final class Keys {
Collections.singletonList(KeyType.GLOBAL));
/**
+ * Force LDAP authentication.
+ */
+ public static final ConfigKey<Boolean> LDAP_FORCE = new ConfigKey<>(
+ "ldap.force",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
* LDAP user search base.
*/
public static final ConfigKey<String> LDAP_BASE = new ConfigKey<>(
@@ -357,6 +458,21 @@ public final class Keys {
Collections.singletonList(KeyType.GLOBAL));
/**
+ * Enable database access console via '/console' URL. Use only for debugging. Never use in production.
+ */
+ public static final ConfigKey<Boolean> WEB_CONSOLE = new ConfigKey<>(
+ "web.console",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
+ * Server debug version of the web app. Not recommended to use for performance reasons. It is intended to be used
+ * for development and debugging purposes.
+ */
+ public static final ConfigKey<Boolean> WEB_DEBUG = new ConfigKey<>(
+ "web.debug",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
* Enable positions forwarding to other web server.
*/
public static final ConfigKey<Boolean> FORWARD_ENABLE = new ConfigKey<>(
@@ -726,6 +842,13 @@ public final class Keys {
Collections.singletonList(KeyType.GLOBAL));
/**
+ * Perform geocoding when preparing reports and sending notifications.
+ */
+ public static final ConfigKey<Boolean> GEOCODER_ON_REQUEST = new ConfigKey<>(
+ "geocoder.onRequest",
+ Collections.singletonList(KeyType.GLOBAL));
+
+ /**
* Boolean flag to enable LBS location resolution. Some devices send cell towers information and WiFi point when GPS
* location is not available. Traccar can determine coordinates based on that information using third party
* services. Default value is false.
diff --git a/src/main/java/org/traccar/database/DataManager.java b/src/main/java/org/traccar/database/DataManager.java
index 4fae5687c..a3b31350f 100644
--- a/src/main/java/org/traccar/database/DataManager.java
+++ b/src/main/java/org/traccar/database/DataManager.java
@@ -80,7 +80,7 @@ public class DataManager {
public DataManager(Config config) throws Exception {
this.config = config;
- forceLdap = config.getBoolean("ldap.force");
+ forceLdap = config.getBoolean(Keys.LDAP_FORCE);
initDatabase();
initDatabaseSchema();
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index d238e9229..8db694d73 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -113,7 +113,7 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
boolean forceUpdate;
try {
readLock();
- forceUpdate = !devicesByUniqueId.containsKey(uniqueId) && !config.getBoolean("database.ignoreUnknown");
+ forceUpdate = !devicesByUniqueId.containsKey(uniqueId) && !config.getBoolean(Keys.DATABASE_IGNORE_UNKNOWN);
} finally {
readUnlock();
}
diff --git a/src/main/java/org/traccar/database/NotificationManager.java b/src/main/java/org/traccar/database/NotificationManager.java
index 17797e21d..ccad192f6 100644
--- a/src/main/java/org/traccar/database/NotificationManager.java
+++ b/src/main/java/org/traccar/database/NotificationManager.java
@@ -30,6 +30,7 @@ import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.traccar.Context;
+import org.traccar.config.Keys;
import org.traccar.model.Calendar;
import org.traccar.model.Event;
import org.traccar.model.Notification;
@@ -44,7 +45,7 @@ public class NotificationManager extends ExtendedObjectManager<Notification> {
public NotificationManager(DataManager dataManager) {
super(dataManager, Notification.class);
- geocodeOnRequest = Context.getConfig().getBoolean("geocoder.onRequest");
+ geocodeOnRequest = Context.getConfig().getBoolean(Keys.GEOCODER_ON_REQUEST);
}
private Set<Long> getEffectiveNotifications(long userId, long deviceId, Date time) {
diff --git a/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java b/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
index 5aaacf5a1..f11312428 100644
--- a/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/AplicomProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.traccar.BaseProtocolDecoder;
import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.Checksum;
import org.traccar.helper.UnitsConverter;
import org.traccar.model.Position;
@@ -302,7 +303,7 @@ public class AplicomProtocolDecoder extends BaseProtocolDecoder {
decodeEventData(position, buf, event);
}
- if (Context.getConfig().getBoolean(getProtocolName() + ".can")
+ if (Context.getConfig().getBoolean(Keys.PROTOCOL_CAN.withPrefix(getProtocolName()))
&& buf.isReadable() && (selector & 0x1000) != 0 && event == EVENT_DATA) {
decodeCanData(buf, position);
}
diff --git a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
index 56c00c7c1..ff7ef6c4a 100644
--- a/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/AtrackProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -61,19 +62,23 @@ public class AtrackProtocolDecoder extends BaseProtocolDecoder {
public AtrackProtocolDecoder(Protocol protocol) {
super(protocol);
- longDate = Context.getConfig().getBoolean(getProtocolName() + ".longDate");
- decimalFuel = Context.getConfig().getBoolean(getProtocolName() + ".decimalFuel");
+ longDate = Context.getConfig().getBoolean(Keys.PROTOCOL_LONG_DATE.withPrefix(getProtocolName()));
+ decimalFuel = Context.getConfig().getBoolean(Keys.PROTOCOL_DECIMAL_FUEL.withPrefix(getProtocolName()));
- custom = Context.getConfig().getBoolean(getProtocolName() + ".custom");
- form = Context.getConfig().getString(getProtocolName() + ".form");
+ custom = Context.getConfig().getBoolean(Keys.PROTOCOL_CUSTOM.withPrefix(getProtocolName()));
+ form = Context.getConfig().getString(Keys.PROTOCOL_FORM.withPrefix(getProtocolName()));
if (form != null) {
custom = true;
}
- for (String pair : Context.getConfig().getString(getProtocolName() + ".alarmMap", "").split(",")) {
- if (!pair.isEmpty()) {
- alarmMap.put(
- Integer.parseInt(pair.substring(0, pair.indexOf('='))), pair.substring(pair.indexOf('=') + 1));
+ String alarmMapString = Context.getConfig().getString(Keys.PROTOCOL_ALARM_MAP.withPrefix(getProtocolName()));
+ if (alarmMapString != null) {
+ for (String pair : alarmMapString.split(",")) {
+ if (!pair.isEmpty()) {
+ alarmMap.put(
+ Integer.parseInt(pair.substring(0, pair.indexOf('='))),
+ pair.substring(pair.indexOf('=') + 1));
+ }
}
}
}
diff --git a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
index ec569b71b..d438aa33d 100644
--- a/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Gl200TextProtocolDecoder.java
@@ -20,6 +20,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Parser;
import org.traccar.helper.PatternBuilder;
@@ -49,8 +50,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
public Gl200TextProtocolDecoder(Protocol protocol) {
super(protocol);
-
- ignoreFixTime = Context.getConfig().getBoolean(getProtocolName() + ".ignoreFixTime");
+ ignoreFixTime = Context.getConfig().getBoolean(Keys.PROTOCOL_IGNORE_FIX_TIME.withPrefix(getProtocolName()));
}
private static final Pattern PATTERN_ACK = new PatternBuilder()
@@ -1147,7 +1147,7 @@ public class Gl200TextProtocolDecoder extends BaseProtocolDecoder {
decodeDeviceTime(position, parser);
- if (Context.getConfig().getBoolean(getProtocolName() + ".ack") && channel != null) {
+ if (channel != null && Context.getConfig().getBoolean(Keys.PROTOCOL_ACK.withPrefix(getProtocolName()))) {
channel.writeAndFlush(new NetworkMessage("+SACK:" + parser.next() + "$", remoteAddress));
}
diff --git a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
index a5dc1860a..3f8611b85 100644
--- a/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/H02ProtocolDecoder.java
@@ -23,6 +23,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BcdUtil;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
@@ -331,7 +332,7 @@ public class H02ProtocolDecoder extends BaseProtocolDecoder {
if (parser.hasNext() && parser.next().equals("V1")) {
sendResponse(channel, remoteAddress, id, "V1");
- } else if (Context.getConfig().getBoolean(getProtocolName() + ".ack")) {
+ } else if (Context.getConfig().getBoolean(Keys.PROTOCOL_ACK.withPrefix(getProtocolName()))) {
sendResponse(channel, remoteAddress, id, "R12");
}
diff --git a/src/main/java/org/traccar/protocol/Mta6Protocol.java b/src/main/java/org/traccar/protocol/Mta6Protocol.java
index 632a7df80..14a66ce5c 100644
--- a/src/main/java/org/traccar/protocol/Mta6Protocol.java
+++ b/src/main/java/org/traccar/protocol/Mta6Protocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import org.traccar.config.Keys;
public class Mta6Protocol extends BaseProtocol {
@@ -33,7 +34,7 @@ public class Mta6Protocol extends BaseProtocol {
pipeline.addLast(new HttpRequestDecoder());
pipeline.addLast(new HttpObjectAggregator(65535));
pipeline.addLast(new Mta6ProtocolDecoder(
- Mta6Protocol.this, !Context.getConfig().getBoolean(getName() + ".can")));
+ Mta6Protocol.this, !Context.getConfig().getBoolean(Keys.PROTOCOL_CAN.withPrefix(getName()))));
}
});
}
diff --git a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
index 78bd33fa0..da60cf5d6 100644
--- a/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/TeltonikaProtocolDecoder.java
@@ -24,6 +24,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BitUtil;
import org.traccar.helper.Checksum;
import org.traccar.helper.UnitsConverter;
@@ -54,7 +55,7 @@ public class TeltonikaProtocolDecoder extends BaseProtocolDecoder {
public TeltonikaProtocolDecoder(Protocol protocol, boolean connectionless) {
super(protocol);
this.connectionless = connectionless;
- this.extended = Context.getConfig().getBoolean(getProtocolName() + ".extended");
+ this.extended = Context.getConfig().getBoolean(Keys.PROTOCOL_EXTENDED.withPrefix(getProtocolName()));
}
private void parseIdentification(Channel channel, SocketAddress remoteAddress, ByteBuf buf) {
diff --git a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
index 1a45fbf75..69fff5310 100644
--- a/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
+++ b/src/main/java/org/traccar/protocol/Tk103ProtocolDecoder.java
@@ -21,6 +21,7 @@ import org.traccar.Context;
import org.traccar.DeviceSession;
import org.traccar.NetworkMessage;
import org.traccar.Protocol;
+import org.traccar.config.Keys;
import org.traccar.helper.BitUtil;
import org.traccar.helper.DateBuilder;
import org.traccar.helper.Parser;
@@ -39,7 +40,7 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder {
public Tk103ProtocolDecoder(Protocol protocol) {
super(protocol);
- decodeLow = Context.getConfig().getBoolean(getProtocolName() + ".decodeLow");
+ decodeLow = Context.getConfig().getBoolean(Keys.PROTOCOL_DECODE_LOW.withPrefix(getProtocolName()));
}
private static final Pattern PATTERN = new PatternBuilder()
diff --git a/src/main/java/org/traccar/protocol/WialonProtocol.java b/src/main/java/org/traccar/protocol/WialonProtocol.java
index fd183dd2c..cb6ea5319 100644
--- a/src/main/java/org/traccar/protocol/WialonProtocol.java
+++ b/src/main/java/org/traccar/protocol/WialonProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import org.traccar.config.Keys;
import org.traccar.model.Command;
import io.netty.handler.codec.LineBasedFrameDecoder;
@@ -26,6 +27,7 @@ import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import java.nio.charset.StandardCharsets;
+
public class WialonProtocol extends BaseProtocol {
public WialonProtocol() {
@@ -38,7 +40,7 @@ public class WialonProtocol extends BaseProtocol {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast(new LineBasedFrameDecoder(4 * 1024));
- boolean utf8 = Context.getConfig().getBoolean(getName() + ".utf8");
+ boolean utf8 = Context.getConfig().getBoolean(Keys.PROTOCOL_UTF8.withPrefix(getName()));
if (utf8) {
pipeline.addLast(new StringEncoder(StandardCharsets.UTF_8));
pipeline.addLast(new StringDecoder(StandardCharsets.UTF_8));
@@ -54,7 +56,7 @@ public class WialonProtocol extends BaseProtocol {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline) {
pipeline.addLast(new LineBasedFrameDecoder(4 * 1024));
- boolean utf8 = Context.getConfig().getBoolean(getName() + ".utf8");
+ boolean utf8 = Context.getConfig().getBoolean(Keys.PROTOCOL_UTF8.withPrefix(getName()));
if (utf8) {
pipeline.addLast(new StringEncoder(StandardCharsets.UTF_8));
pipeline.addLast(new StringDecoder(StandardCharsets.UTF_8));
diff --git a/src/main/java/org/traccar/protocol/XexunProtocol.java b/src/main/java/org/traccar/protocol/XexunProtocol.java
index 401844e7b..b83c4e445 100644
--- a/src/main/java/org/traccar/protocol/XexunProtocol.java
+++ b/src/main/java/org/traccar/protocol/XexunProtocol.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org)
+ * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@ import org.traccar.BaseProtocol;
import org.traccar.Context;
import org.traccar.PipelineBuilder;
import org.traccar.TrackerServer;
+import org.traccar.config.Keys;
import org.traccar.model.Command;
import io.netty.handler.codec.LineBasedFrameDecoder;
@@ -34,7 +35,7 @@ public class XexunProtocol extends BaseProtocol {
addServer(new TrackerServer(false, getName()) {
@Override
protected void addProtocolHandlers(PipelineBuilder pipeline) {
- boolean full = Context.getConfig().getBoolean(getName() + ".extended");
+ boolean full = Context.getConfig().getBoolean(Keys.PROTOCOL_EXTENDED.withPrefix(getName()));
if (full) {
pipeline.addLast(new LineBasedFrameDecoder(1024)); // tracker bug \n\r
} else {
diff --git a/src/main/java/org/traccar/reports/ReportUtils.java b/src/main/java/org/traccar/reports/ReportUtils.java
index d8dfeed4c..58674beae 100644
--- a/src/main/java/org/traccar/reports/ReportUtils.java
+++ b/src/main/java/org/traccar/reports/ReportUtils.java
@@ -196,7 +196,7 @@ public final class ReportUtils {
trip.setStartTime(startTrip.getFixTime());
String startAddress = startTrip.getAddress();
if (startAddress == null && Context.getGeocoder() != null
- && Context.getConfig().getBoolean("geocoder.onRequest")) {
+ && Context.getConfig().getBoolean(Keys.GEOCODER_ON_REQUEST)) {
startAddress = Context.getGeocoder().getAddress(startTrip.getLatitude(), startTrip.getLongitude(), null);
}
trip.setStartAddress(startAddress);
@@ -207,7 +207,7 @@ public final class ReportUtils {
trip.setEndTime(endTrip.getFixTime());
String endAddress = endTrip.getAddress();
if (endAddress == null && Context.getGeocoder() != null
- && Context.getConfig().getBoolean("geocoder.onRequest")) {
+ && Context.getConfig().getBoolean(Keys.GEOCODER_ON_REQUEST)) {
endAddress = Context.getGeocoder().getAddress(endTrip.getLatitude(), endTrip.getLongitude(), null);
}
trip.setEndAddress(endAddress);
@@ -254,7 +254,7 @@ public final class ReportUtils {
stop.setStartTime(startStop.getFixTime());
String address = startStop.getAddress();
if (address == null && Context.getGeocoder() != null
- && Context.getConfig().getBoolean("geocoder.onRequest")) {
+ && Context.getConfig().getBoolean(Keys.GEOCODER_ON_REQUEST)) {
address = Context.getGeocoder().getAddress(stop.getLatitude(), stop.getLongitude(), null);
}
stop.setAddress(address);
diff --git a/src/main/java/org/traccar/web/WebServer.java b/src/main/java/org/traccar/web/WebServer.java
index 4ae4d24ee..ba4dbff3c 100644
--- a/src/main/java/org/traccar/web/WebServer.java
+++ b/src/main/java/org/traccar/web/WebServer.java
@@ -82,7 +82,7 @@ public class WebServer {
initApi(config, servletHandler);
initSessionConfig(config, servletHandler);
- if (config.getBoolean("web.console")) {
+ if (config.getBoolean(Keys.WEB_CONSOLE)) {
servletHandler.addServlet(new ServletHolder(new ConsoleServlet()), "/console/*");
}
@@ -135,7 +135,7 @@ public class WebServer {
private void initWebApp(Config config, ServletContextHandler servletHandler) {
ServletHolder servletHolder = new ServletHolder(DefaultServlet.class);
servletHolder.setInitParameter("resourceBase", new File(config.getString("web.path")).getAbsolutePath());
- if (config.getBoolean("web.debug")) {
+ if (config.getBoolean(Keys.WEB_DEBUG)) {
servletHandler.setWelcomeFiles(new String[] {"debug.html", "index.html"});
} else {
String cache = config.getString("web.cacheControl");