diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-21 09:59:27 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-21 09:59:27 +0500 |
commit | 839e741653c9b61e573fa1cdd0dad0641c79bcec (patch) | |
tree | 69ef63138122eb0d8cdebe38f678e1d0e2ff82df /src/org/traccar/database/PermissionsManager.java | |
parent | e00fbfa466b17e94f59e6ff8fefb83f08999b3ec (diff) | |
download | trackermap-server-839e741653c9b61e573fa1cdd0dad0641c79bcec.tar.gz trackermap-server-839e741653c9b61e573fa1cdd0dad0641c79bcec.tar.bz2 trackermap-server-839e741653c9b61e573fa1cdd0dad0641c79bcec.zip |
Abolish permissions classes and get permissions as Map from DB
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r-- | src/org/traccar/database/PermissionsManager.java | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index caae86b84..4646071aa 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -18,12 +18,9 @@ package org.traccar.database; import org.traccar.Context; 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; -import org.traccar.model.UserPermission; import java.lang.reflect.Method; import java.sql.SQLException; @@ -112,8 +109,8 @@ public class PermissionsManager { public final void refreshUserPermissions() { userPermissions.clear(); try { - for (UserPermission permission : dataManager.getObjects(UserPermission.class)) { - getUserPermissions(permission.getUserId()).add(permission.getManagedUserId()); + for (Map<String, Long> permission : dataManager.getPermissions("User", "Permission")) { + getUserPermissions(permission.get("userId")).add(permission.get("managedUserId")); } } catch (SQLException error) { Log.warning(error); @@ -126,19 +123,20 @@ public class PermissionsManager { try { GroupTree groupTree = new GroupTree(Context.getDeviceManager().getAllGroups(), Context.getDeviceManager().getAllDevices()); - for (GroupPermission permission : dataManager.getObjects(GroupPermission.class)) { - Set<Long> userGroupPermissions = getGroupPermissions(permission.getUserId()); - Set<Long> userDevicePermissions = getDevicePermissions(permission.getUserId()); - userGroupPermissions.add(permission.getGroupId()); - for (Group group : groupTree.getGroups(permission.getGroupId())) { + for (Map<String, Long> groupPermission : dataManager.getPermissions("Group", "Permission")) { + Set<Long> userGroupPermissions = getGroupPermissions(groupPermission.get("userId")); + Set<Long> userDevicePermissions = getDevicePermissions(groupPermission.get("userId")); + userGroupPermissions.add(groupPermission.get("groupId")); + for (Group group : groupTree.getGroups(groupPermission.get("groupId"))) { userGroupPermissions.add(group.getId()); } - for (Device device : groupTree.getDevices(permission.getGroupId())) { + for (Device device : groupTree.getDevices(groupPermission.get("groupId"))) { userDevicePermissions.add(device.getId()); } } - for (DevicePermission permission : dataManager.getObjects(DevicePermission.class)) { - getDevicePermissions(permission.getUserId()).add(permission.getDeviceId()); + + for (Map<String, Long> devicePermission : dataManager.getPermissions("Device", "Permission")) { + getDevicePermissions(devicePermission.get("userId")).add(devicePermission.get("deviceId")); } groupDevices.clear(); |