aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/PermissionsManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-09-06 21:08:31 +1200
committerGitHub <noreply@github.com>2017-09-06 21:08:31 +1200
commitf0578c7b5f8737e019a9cf05935d2caaa940f0ca (patch)
tree778b00dd1a6162007cb08239d475884843a678ba /src/org/traccar/database/PermissionsManager.java
parent3e5167131c758dd6e75e0f5d9b265a1514baac0c (diff)
parentfe5e6f7e1aaa01dfe8d61af46c3b818f8c566a25 (diff)
downloadtrackermap-server-f0578c7b5f8737e019a9cf05935d2caaa940f0ca.tar.gz
trackermap-server-f0578c7b5f8737e019a9cf05935d2caaa940f0ca.tar.bz2
trackermap-server-f0578c7b5f8737e019a9cf05935d2caaa940f0ca.zip
Merge pull request #3507 from Abyss777/units_attributes
Move units to attributes and add volume units
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r--src/org/traccar/database/PermissionsManager.java22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 3b03c1900..0708cc5c9 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -29,7 +29,6 @@ import org.traccar.model.Permission;
import org.traccar.model.Server;
import org.traccar.model.User;
-import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.HashSet;
@@ -382,25 +381,10 @@ public class PermissionsManager {
return null;
}
- public Object lookupPreference(long userId, String key, Object defaultValue) {
- String methodName = "get" + key.substring(0, 1).toUpperCase() + key.substring(1);
+ public Object lookupAttribute(long userId, String key, Object defaultValue) {
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(getUser(userId), (Object[]) null);
- }
- method = null;
- method = Server.class.getMethod(methodName, (Class<?>[]) null);
- if (method != null) {
- serverPreference = method.invoke(server, (Object[]) null);
- }
- } catch (ReflectiveOperationException | SecurityException | IllegalArgumentException exception) {
- return defaultValue;
- }
+ Object serverPreference = server.getAttributes().get(key);
+ Object userPreference = getUser(userId).getAttributes().get(key);
if (server.getForceSettings()) {
preference = serverPreference != null ? serverPreference : userPreference;
} else {