aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/BaseObjectResource.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-16 07:09:00 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-16 07:09:00 -0700
commitd3e83f9fa0d066e5a15fde225599cc43071c031a (patch)
tree0ed36805063b795fb5f2e30ad785a9222ef00990 /src/main/java/org/traccar/api/BaseObjectResource.java
parentd3fd20d4a4f7dc647e75c5a0cb962759630ed967 (diff)
downloadtrackermap-server-d3e83f9fa0d066e5a15fde225599cc43071c031a.tar.gz
trackermap-server-d3e83f9fa0d066e5a15fde225599cc43071c031a.tar.bz2
trackermap-server-d3e83f9fa0d066e5a15fde225599cc43071c031a.zip
Remove groups manager
Diffstat (limited to 'src/main/java/org/traccar/api/BaseObjectResource.java')
-rw-r--r--src/main/java/org/traccar/api/BaseObjectResource.java11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/org/traccar/api/BaseObjectResource.java b/src/main/java/org/traccar/api/BaseObjectResource.java
index f8545a5d7..78aa12dbe 100644
--- a/src/main/java/org/traccar/api/BaseObjectResource.java
+++ b/src/main/java/org/traccar/api/BaseObjectResource.java
@@ -18,7 +18,6 @@ package org.traccar.api;
import org.traccar.Context;
import org.traccar.database.BaseObjectManager;
-import org.traccar.database.ExtendedObjectManager;
import org.traccar.helper.LogAction;
import org.traccar.model.BaseModel;
import org.traccar.model.Device;
@@ -92,10 +91,16 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
public Response update(T entity) throws StorageException {
permissionsService.checkEdit(getUserId(), entity, false);
permissionsService.checkPermission(baseClass, getUserId(), entity.getId());
+
if (entity instanceof User) {
User before = storage.getObject(User.class, new Request(
new Columns.All(), new Condition.Equals("id", "id", entity.getId())));
permissionsService.checkUserUpdate(getUserId(), before, (User) entity);
+ } else if (entity instanceof Group) {
+ Group group = (Group) entity;
+ if (group.getId() == group.getGroupId()) {
+ throw new IllegalArgumentException("Cycle in group hierarchy");
+ }
}
BaseObjectManager<T> manager = Context.getManager(baseClass);
@@ -125,9 +130,6 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
BaseObjectManager<T> manager = Context.getManager(baseClass);
if (manager != null) {
manager.removeItem(id);
- if (manager instanceof ExtendedObjectManager) {
- ((ExtendedObjectManager<T>) manager).refreshExtendedPermissions();
- }
} else {
storage.removeObject(baseClass, new Request(new Condition.Equals("id", "id", id)));
}
@@ -137,7 +139,6 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
if (baseClass.equals(Group.class) || baseClass.equals(Device.class) || baseClass.equals(User.class)) {
if (baseClass.equals(Group.class)) {
- Context.getGroupsManager().refreshItems();
Context.getDeviceManager().updateDeviceCache(true);
}
Context.getPermissionsManager().refreshDeviceAndGroupPermissions();