aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/BaseObjectResource.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 13:23:16 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 13:23:16 -0700
commitc79c71a734da5cb4c84dd660744e58675b1d6fb7 (patch)
treee1721f5cc3262a674389c836cd77fe90664ecaad /src/main/java/org/traccar/api/BaseObjectResource.java
parent3a293661cd2900c115cfea6037c02d659c57aa52 (diff)
downloadtrackermap-server-c79c71a734da5cb4c84dd660744e58675b1d6fb7.tar.gz
trackermap-server-c79c71a734da5cb4c84dd660744e58675b1d6fb7.tar.bz2
trackermap-server-c79c71a734da5cb4c84dd660744e58675b1d6fb7.zip
Remove device manager
Diffstat (limited to 'src/main/java/org/traccar/api/BaseObjectResource.java')
-rw-r--r--src/main/java/org/traccar/api/BaseObjectResource.java36
1 files changed, 5 insertions, 31 deletions
diff --git a/src/main/java/org/traccar/api/BaseObjectResource.java b/src/main/java/org/traccar/api/BaseObjectResource.java
index abfed9682..35ff04bf3 100644
--- a/src/main/java/org/traccar/api/BaseObjectResource.java
+++ b/src/main/java/org/traccar/api/BaseObjectResource.java
@@ -16,11 +16,8 @@
*/
package org.traccar.api;
-import org.traccar.Context;
-import org.traccar.database.BaseObjectManager;
import org.traccar.helper.LogAction;
import org.traccar.model.BaseModel;
-import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.model.Permission;
import org.traccar.model.User;
@@ -67,15 +64,8 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
public Response add(T entity) throws StorageException {
permissionsService.checkEdit(getUserId(), entity, true);
- BaseObjectManager<T> manager = Context.getManager(baseClass);
- if (manager != null) {
- manager.addItem(entity);
- } else {
- entity.setId(storage.addObject(entity, new Request(new Columns.Exclude("id"))));
- }
-
+ entity.setId(storage.addObject(entity, new Request(new Columns.Exclude("id"))));
LogAction.create(getUserId(), entity);
-
storage.addPermission(new Permission(User.class, getUserId(), baseClass, entity.getId()));
cacheManager.invalidate(User.class, getUserId(), baseClass, entity.getId());
LogAction.link(getUserId(), User.class, getUserId(), baseClass, entity.getId());
@@ -100,16 +90,10 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
}
}
- BaseObjectManager<T> manager = Context.getManager(baseClass);
- if (manager != null) {
- manager.updateItem(entity);
- } else {
- storage.updateObject(entity, new Request(
- new Columns.Exclude("id"),
- new Condition.Equals("id", "id")));
- }
+ storage.updateObject(entity, new Request(
+ new Columns.Exclude("id"),
+ new Condition.Equals("id", "id")));
cacheManager.updateOrInvalidate(entity);
-
LogAction.edit(getUserId(), entity);
return Response.ok(entity).build();
@@ -121,21 +105,11 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
permissionsService.checkEdit(getUserId(), baseClass, false);
permissionsService.checkPermission(baseClass, getUserId(), id);
- BaseObjectManager<T> manager = Context.getManager(baseClass);
- if (manager != null) {
- manager.removeItem(id);
- } else {
- storage.removeObject(baseClass, new Request(new Condition.Equals("id", "id", id)));
- }
+ storage.removeObject(baseClass, new Request(new Condition.Equals("id", "id", id)));
cacheManager.invalidate(baseClass, id);
LogAction.remove(getUserId(), baseClass, id);
- if (baseClass.equals(Group.class) || baseClass.equals(Device.class) || baseClass.equals(User.class)) {
- if (baseClass.equals(Group.class)) {
- Context.getDeviceManager().updateDeviceCache(true);
- }
- }
return Response.noContent().build();
}