From 68abcc05ddd3633167f4e1c45d0ae9cf05dbcc43 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Tue, 17 Jan 2017 09:36:29 +0500 Subject: - rename otherUserId variable - optimize HashSet creation --- src/org/traccar/api/resource/GeofenceResource.java | 8 ++++---- src/org/traccar/database/PermissionsManager.java | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/org/traccar/api/resource/GeofenceResource.java b/src/org/traccar/api/resource/GeofenceResource.java index 5f085023a..d5acf106a 100644 --- a/src/org/traccar/api/resource/GeofenceResource.java +++ b/src/org/traccar/api/resource/GeofenceResource.java @@ -52,20 +52,20 @@ public class GeofenceResource extends BaseResource { geofenceManager.refreshGeofences(); } - Set result; + Set result = new HashSet<>(); if (all) { if (Context.getPermissionsManager().isAdmin(getUserId())) { - result = new HashSet<>(geofenceManager.getAllGeofencesIds()); + result.addAll(geofenceManager.getAllGeofencesIds()); } else { Context.getPermissionsManager().checkManager(getUserId()); - result = new HashSet<>(geofenceManager.getManagedGeofencesIds(getUserId())); + result.addAll(geofenceManager.getManagedGeofencesIds(getUserId())); } } else { if (userId == 0) { userId = getUserId(); } Context.getPermissionsManager().checkUser(getUserId(), userId); - result = new HashSet<>(geofenceManager.getUserGeofencesIds(userId)); + result.addAll(geofenceManager.getUserGeofencesIds(userId)); } if (groupId != 0) { diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java index c49ffb00c..4a5f759a8 100644 --- a/src/org/traccar/database/PermissionsManager.java +++ b/src/org/traccar/database/PermissionsManager.java @@ -179,9 +179,9 @@ public class PermissionsManager { } } - public void checkManager(long userId, long otherUserId) throws SecurityException { + public void checkManager(long userId, long managedUserId) throws SecurityException { checkManager(userId); - if (!userPermissions.get(userId).contains(otherUserId)) { + if (!userPermissions.get(userId).contains(managedUserId)) { throw new SecurityException("User access denied"); } } @@ -241,9 +241,9 @@ public class PermissionsManager { } } - public void checkUser(long userId, long otherUserId) throws SecurityException { - if (userId != otherUserId && !isAdmin(userId)) { - checkManager(userId, otherUserId); + public void checkUser(long userId, long managedUserId) throws SecurityException { + if (userId != managedUserId && !isAdmin(userId)) { + checkManager(userId, managedUserId); } } -- cgit v1.2.3