aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-23 08:32:55 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-23 08:32:55 +0500
commitd2a2ce5d05572caadf13627d3e6c3767ad68688f (patch)
tree5969cadd519b02e345af90a6ff664a0da0daba8d /src/org/traccar
parentf92b5cd97a5d2159a890fb4817238f4c1bbb2a12 (diff)
downloadtrackermap-server-d2a2ce5d05572caadf13627d3e6c3767ad68688f.tar.gz
trackermap-server-d2a2ce5d05572caadf13627d3e6c3767ad68688f.tar.bz2
trackermap-server-d2a2ce5d05572caadf13627d3e6c3767ad68688f.zip
Use Permission object instead of Map
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/api/resource/PermissionsResource.java4
-rw-r--r--src/org/traccar/database/ExtendedObjectManager.java3
-rw-r--r--src/org/traccar/database/PermissionsManager.java29
3 files changed, 18 insertions, 18 deletions
diff --git a/src/org/traccar/api/resource/PermissionsResource.java b/src/org/traccar/api/resource/PermissionsResource.java
index 88fd9d092..9b9f65ad1 100644
--- a/src/org/traccar/api/resource/PermissionsResource.java
+++ b/src/org/traccar/api/resource/PermissionsResource.java
@@ -61,7 +61,7 @@ public class PermissionsResource extends BaseResource {
checkPermission(permission, true);
Context.getDataManager().linkObject(permission.getOwnerClass(), permission.getOwnerId(),
permission.getPropertyClass(), permission.getPropertyId(), true);
- Context.getPermissionsManager().refreshPermissions(entity);
+ Context.getPermissionsManager().refreshPermissions(permission);
return Response.noContent().build();
}
@@ -72,7 +72,7 @@ public class PermissionsResource extends BaseResource {
checkPermission(permission, false);
Context.getDataManager().linkObject(permission.getOwnerClass(), permission.getOwnerId(),
permission.getPropertyClass(), permission.getPropertyId(), false);
- Context.getPermissionsManager().refreshPermissions(entity);
+ Context.getPermissionsManager().refreshPermissions(permission);
return Response.noContent().build();
}
diff --git a/src/org/traccar/database/ExtendedObjectManager.java b/src/org/traccar/database/ExtendedObjectManager.java
index 8380b9da2..483c3a09e 100644
--- a/src/org/traccar/database/ExtendedObjectManager.java
+++ b/src/org/traccar/database/ExtendedObjectManager.java
@@ -35,8 +35,7 @@ public abstract class ExtendedObjectManager extends SimpleObjectManager {
private final Map<Long, Set<Long>> deviceItemsWithGroups = new ConcurrentHashMap<>();
private final Map<Long, Set<Long>> groupItems = new ConcurrentHashMap<>();
- protected ExtendedObjectManager(DataManager dataManager,
- Class<? extends BaseModel> baseClass) {
+ protected ExtendedObjectManager(DataManager dataManager, Class<? extends BaseModel> baseClass) {
super(dataManager, baseClass);
}
diff --git a/src/org/traccar/database/PermissionsManager.java b/src/org/traccar/database/PermissionsManager.java
index 4008134ec..8aa0dc9d7 100644
--- a/src/org/traccar/database/PermissionsManager.java
+++ b/src/org/traccar/database/PermissionsManager.java
@@ -24,6 +24,7 @@ import org.traccar.model.Driver;
import org.traccar.model.Geofence;
import org.traccar.model.Group;
import org.traccar.model.ManagedUser;
+import org.traccar.model.Permission;
import org.traccar.model.Server;
import org.traccar.model.User;
@@ -348,34 +349,34 @@ public class PermissionsManager {
Context.getAttributesManager().refreshExtendedPermissions();
}
- public void refreshPermissions(Map<String, Long> entity) {
- if (entity.containsKey(DataManager.makeNameId(User.class))) {
- if (entity.containsKey(DataManager.makeNameId(Device.class))
- || entity.containsKey(DataManager.makeNameId(Group.class))) {
+ public void refreshPermissions(Permission permission) {
+ if (permission.getOwnerClass().equals(User.class)) {
+ if (permission.getPropertyClass().equals(Device.class)
+ || permission.getPropertyClass().equals(Group.class)) {
refreshPermissions();
refreshAllExtendedPermissions();
- } else if (entity.containsKey(DataManager.makeNameId(ManagedUser.class))) {
+ } else if (permission.getPropertyClass().equals(ManagedUser.class)) {
refreshUserPermissions();
- } else if (entity.containsKey(DataManager.makeNameId(Geofence.class))) {
+ } else if (permission.getPropertyClass().equals(Geofence.class)) {
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refreshUserItems();
}
- } else if (entity.containsKey(DataManager.makeNameId(Driver.class))) {
+ } else if (permission.getPropertyClass().equals(Driver.class)) {
Context.getDriversManager().refreshUserItems();
- } else if (entity.containsKey(DataManager.makeNameId(Attribute.class))) {
+ } else if (permission.getPropertyClass().equals(Attribute.class)) {
Context.getAttributesManager().refreshUserItems();
- } else if (entity.containsKey(DataManager.makeNameId(Calendar.class))) {
+ } else if (permission.getPropertyClass().equals(Calendar.class)) {
Context.getCalendarManager().refreshUserItems();
}
- } else if (entity.containsKey(DataManager.makeNameId(Device.class))
- || entity.containsKey(DataManager.makeNameId(Group.class))) {
- if (entity.containsKey(DataManager.makeNameId(Geofence.class))) {
+ } else if (permission.getOwnerClass().equals(Device.class)
+ || permission.getOwnerClass().equals(Group.class)) {
+ if (permission.getPropertyClass().equals(Geofence.class)) {
if (Context.getGeofenceManager() != null) {
Context.getGeofenceManager().refreshExtendedPermissions();
}
- } else if (entity.containsKey(DataManager.makeNameId(Driver.class))) {
+ } else if (permission.getPropertyClass().equals(Driver.class)) {
Context.getDriversManager().refreshExtendedPermissions();
- } else if (entity.containsKey(DataManager.makeNameId(Attribute.class))) {
+ } else if (permission.getPropertyClass().equals(Attribute.class)) {
Context.getAttributesManager().refreshExtendedPermissions();
}
}