aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-03-10 17:03:37 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2016-03-10 17:03:37 +1300
commitd940a84da87bcf4c164344fa7018cbf96ca1a920 (patch)
tree313942626dd5aeca60f7b0ce6ad68f87d093e88e /src
parent222265e0c884d06158426e7d0ca033127cecb22f (diff)
downloadtraccar-server-d940a84da87bcf4c164344fa7018cbf96ca1a920.tar.gz
traccar-server-d940a84da87bcf4c164344fa7018cbf96ca1a920.tar.bz2
traccar-server-d940a84da87bcf4c164344fa7018cbf96ca1a920.zip
Expand group permissions in manager
Diffstat (limited to 'src')
-rw-r--r--src/org/traccar/database/PermissionsManager.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 022691b1b..0aefb9605 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -22,7 +22,9 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.traccar.helper.Log;
+import org.traccar.model.Device;
import org.traccar.model.DevicePermission;
+import org.traccar.model.Group;
import org.traccar.model.GroupPermission;
import org.traccar.model.Server;
import org.traccar.model.User;
@@ -66,12 +68,24 @@ public class PermissionsManager {
for (User user : dataManager.getUsers()) {
users.put(user.getId(), user);
}
+
+ GroupTree groupTree = new GroupTree(dataManager.getAllGroups());
+ for (GroupPermission permission : dataManager.getGroupPermissions()) {
+ Set<Long> userGroupPermissions = getGroupPermissions(permission.getUserId());
+ userGroupPermissions.add(permission.getGroupId());
+ for (Group group : groupTree.getDescendants(permission.getGroupId())) {
+ userGroupPermissions.add(group.getId());
+ }
+ }
+
for (DevicePermission permission : dataManager.getDevicePermissions()) {
getDevicePermissions(permission.getUserId()).add(permission.getDeviceId());
}
- for (GroupPermission permission : dataManager.getGroupPermissions()) {
- getGroupPermissions(permission.getUserId()).add(permission.getGroupId());
+
+ for (Device device : dataManager.getAllDevices()) {
+ // TODO
}
+
} catch (SQLException error) {
Log.warning(error);
}