aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Valley <ed.valley@yandex.com>2019-07-17 17:29:46 -0400
committerEdward Valley <ed.valley@yandex.com>2019-07-17 17:29:46 -0400
commitf647a3b4af19b9af48c0304ac2bd3e599983cc42 (patch)
tree72e0dc82b2fcdd7ff54f6746648a5ae6e76381e9 /src
parentbba38f9078a1c1455730daf80d76587cf21228cc (diff)
downloadtrackermap-server-f647a3b4af19b9af48c0304ac2bd3e599983cc42.tar.gz
trackermap-server-f647a3b4af19b9af48c0304ac2bd3e599983cc42.tar.bz2
trackermap-server-f647a3b4af19b9af48c0304ac2bd3e599983cc42.zip
Make optional server attributes lookup
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index 62e6de080..b12e7f1e5 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -325,7 +325,7 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
@Override
public boolean lookupAttributeBoolean(
long deviceId, String attributeName, boolean defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ Object result = lookupAttribute(deviceId, attributeName, true, lookupConfig);
if (result != null) {
return result instanceof String ? Boolean.parseBoolean((String) result) : (Boolean) result;
}
@@ -335,13 +335,13 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
@Override
public String lookupAttributeString(
long deviceId, String attributeName, String defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ Object result = lookupAttribute(deviceId, attributeName, true, lookupConfig);
return result != null ? (String) result : defaultValue;
}
@Override
public int lookupAttributeInteger(long deviceId, String attributeName, int defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ Object result = lookupAttribute(deviceId, attributeName, true, lookupConfig);
if (result != null) {
return result instanceof String ? Integer.parseInt((String) result) : ((Number) result).intValue();
}
@@ -351,7 +351,7 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
@Override
public long lookupAttributeLong(
long deviceId, String attributeName, long defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ Object result = lookupAttribute(deviceId, attributeName, true, lookupConfig);
if (result != null) {
return result instanceof String ? Long.parseLong((String) result) : ((Number) result).longValue();
}
@@ -360,14 +360,14 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
public double lookupAttributeDouble(
long deviceId, String attributeName, double defaultValue, boolean lookupConfig) {
- Object result = lookupAttribute(deviceId, attributeName, lookupConfig);
+ Object result = lookupAttribute(deviceId, attributeName, true, lookupConfig);
if (result != null) {
return result instanceof String ? Double.parseDouble((String) result) : ((Number) result).doubleValue();
}
return defaultValue;
}
- private Object lookupAttribute(long deviceId, String attributeName, boolean lookupConfig) {
+ private Object lookupAttribute(long deviceId, String attributeName, boolean lookupServer, boolean lookupConfig) {
Object result = null;
Device device = getById(deviceId);
if (device != null) {
@@ -390,7 +390,7 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
if (result == null) {
if (lookupConfig) {
result = Context.getConfig().getString(attributeName);
- } else {
+ } else if (lookupServer) {
Server server = Context.getPermissionsManager().getServer();
result = server.getAttributes().get(attributeName);
}