aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/database/PermissionsManager.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-24 17:02:39 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-24 17:02:39 +0500
commitaf00329fd0addf84071927dbc18cb0b4e5345f2b (patch)
tree8a8def831332ed70e63544b54c70bcf82e777fbb /src/org/traccar/database/PermissionsManager.java
parentd6c7cdf1e103c977ed94b737dc838d7ac22b9fa7 (diff)
downloadtrackermap-server-af00329fd0addf84071927dbc18cb0b4e5345f2b.tar.gz
trackermap-server-af00329fd0addf84071927dbc18cb0b4e5345f2b.tar.bz2
trackermap-server-af00329fd0addf84071927dbc18cb0b4e5345f2b.zip
Use Permission instead of Map
Diffstat (limited to 'src/org/traccar/database/PermissionsManager.java')
-rw-r--r--src/org/traccar/database/PermissionsManager.java28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index b9cdfc36b..70969d749 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -115,11 +115,10 @@ public class PermissionsManager {
public final void refreshUserPermissions() {
userPermissions.clear();
try {
- for (Map<String, Long> permission : dataManager.getPermissions(User.class, User.class)) {
- getUserPermissions(permission.get(DataManager.makeNameId(User.class)))
- .add(permission.get(DataManager.makeNameId(ManagedUser.class)));
+ for (Permission permission : dataManager.getPermissions(User.class, User.class)) {
+ getUserPermissions(permission.getOwnerId()).add(permission.getPropertyId());
}
- } catch (SQLException error) {
+ } catch (SQLException | ClassNotFoundException error) {
Log.warning(error);
}
}
@@ -130,23 +129,20 @@ public class PermissionsManager {
try {
GroupTree groupTree = new GroupTree(Context.getDeviceManager().getAllGroups(),
Context.getDeviceManager().getAllDevices());
- for (Map<String, Long> groupPermission : dataManager.getPermissions(User.class, Group.class)) {
- Set<Long> userGroupPermissions = getGroupPermissions(groupPermission
- .get(DataManager.makeNameId(User.class)));
- Set<Long> userDevicePermissions = getDevicePermissions(groupPermission
- .get(DataManager.makeNameId(User.class)));
- userGroupPermissions.add(groupPermission.get(DataManager.makeNameId(Group.class)));
- for (Group group : groupTree.getGroups(groupPermission.get(DataManager.makeNameId(Group.class)))) {
+ for (Permission groupPermission : dataManager.getPermissions(User.class, Group.class)) {
+ Set<Long> userGroupPermissions = getGroupPermissions(groupPermission.getOwnerId());
+ Set<Long> userDevicePermissions = getDevicePermissions(groupPermission.getOwnerId());
+ userGroupPermissions.add(groupPermission.getPropertyId());
+ for (Group group : groupTree.getGroups(groupPermission.getPropertyId())) {
userGroupPermissions.add(group.getId());
}
- for (Device device : groupTree.getDevices(groupPermission.get(DataManager.makeNameId(Group.class)))) {
+ for (Device device : groupTree.getDevices(groupPermission.getPropertyId())) {
userDevicePermissions.add(device.getId());
}
}
- for (Map<String, Long> devicePermission : dataManager.getPermissions(User.class, Device.class)) {
- getDevicePermissions(devicePermission.get(DataManager.makeNameId(User.class)))
- .add(devicePermission.get(DataManager.makeNameId(Device.class)));
+ for (Permission devicePermission : dataManager.getPermissions(User.class, Device.class)) {
+ getDevicePermissions(devicePermission.getOwnerId()).add(devicePermission.getPropertyId());
}
groupDevices.clear();
@@ -156,7 +152,7 @@ public class PermissionsManager {
}
}
- } catch (SQLException error) {
+ } catch (SQLException | ClassNotFoundException error) {
Log.warning(error);
}