aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/PermissionsManager.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-04-16 11:47:03 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2016-04-16 11:47:03 +1200
commitef25655365eb97d29295f8e0cb720b86a29c5e26 (patch)
tree49662363442f0af20b05b324fa4b663995d51fc7 /src/org/traccar/database/PermissionsManager.java
parentc463798c9e1d72c0c51cd4321826df1ff8609a5d (diff)
downloadtrackermap-server-ef25655365eb97d29295f8e0cb720b86a29c5e26.tar.gz
trackermap-server-ef25655365eb97d29295f8e0cb720b86a29c5e26.tar.bz2
trackermap-server-ef25655365eb97d29295f8e0cb720b86a29c5e26.zip
Bind async connection to user id
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r--src/org/traccar/database/PermissionsManager.java14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index dc37bbc84..57307b58a 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -38,6 +38,7 @@ public class PermissionsManager {
private final Map<Long, Set<Long>> groupPermissions = new HashMap<>();
private final Map<Long, Set<Long>> devicePermissions = new HashMap<>();
+ private final Map<Long, Set<Long>> deviceUsers = new HashMap<>();
public Set<Long> getGroupPermissions(long userId) {
if (!groupPermissions.containsKey(userId)) {
@@ -53,6 +54,13 @@ public class PermissionsManager {
return devicePermissions.get(userId);
}
+ public Set<Long> getDeviceUsers(long deviceId) {
+ if (!deviceUsers.containsKey(deviceId)) {
+ deviceUsers.put(deviceId, new HashSet<Long>());
+ }
+ return deviceUsers.get(deviceId);
+ }
+
public PermissionsManager(DataManager dataManager) {
this.dataManager = dataManager;
refresh();
@@ -88,6 +96,12 @@ public class PermissionsManager {
} catch (SQLException error) {
Log.warning(error);
}
+
+ for (Map.Entry<Long, Set<Long>> entry : devicePermissions.entrySet()) {
+ for (long deviceId : entry.getValue()) {
+ getDeviceUsers(deviceId).add(entry.getKey());
+ }
+ }
}
public boolean isAdmin(long userId) {