aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/BaseObjectResource.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-10-13 10:31:54 -0700
committerAnton Tananaev <anton@traccar.org>2022-10-13 10:31:54 -0700
commit4c8e98ed409df6e12128591eb1d8d0cf0856deb7 (patch)
tree83da3517bb14977ab4809aecf3681b777785e83d /src/main/java/org/traccar/api/BaseObjectResource.java
parentacedd28b8584a18022d9e2343558f9acbad1666f (diff)
downloadtrackermap-server-4c8e98ed409df6e12128591eb1d8d0cf0856deb7.tar.gz
trackermap-server-4c8e98ed409df6e12128591eb1d8d0cf0856deb7.tar.bz2
trackermap-server-4c8e98ed409df6e12128591eb1d8d0cf0856deb7.zip
Refactor database code (fix #4961)
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 0ec2bfeaa..904781e54 100644
--- a/src/main/java/org/traccar/api/BaseObjectResource.java
+++ b/src/main/java/org/traccar/api/BaseObjectResource.java
@@ -56,7 +56,7 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
public Response getSingle(@PathParam("id") long id) throws StorageException {
permissionsService.checkPermission(baseClass, getUserId(), id);
T entity = storage.getObject(baseClass, new Request(
- new Columns.All(), new Condition.Equals("id", "id", id)));
+ new Columns.All(), new Condition.Equals("id", id)));
if (entity != null) {
return Response.ok(entity).build();
} else {
@@ -86,7 +86,7 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
if (entity instanceof User) {
User before = storage.getObject(User.class, new Request(
- new Columns.All(), new Condition.Equals("id", "id", entity.getId())));
+ new Columns.All(), new Condition.Equals("id", entity.getId())));
permissionsService.checkUserUpdate(getUserId(), before, (User) entity);
} else if (entity instanceof Group) {
Group group = (Group) entity;
@@ -97,12 +97,13 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
storage.updateObject(entity, new Request(
new Columns.Exclude("id"),
- new Condition.Equals("id", "id")));
+ new Condition.Equals("id", entity.getId())));
if (entity instanceof User) {
User user = (User) entity;
if (user.getHashedPassword() != null) {
storage.updateObject(entity, new Request(
- new Columns.Include("hashedPassword", "salt"), new Condition.Equals("id", "id")));
+ new Columns.Include("hashedPassword", "salt"),
+ new Condition.Equals("id", entity.getId())));
}
}
cacheManager.updateOrInvalidate(true, entity);
@@ -117,7 +118,7 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
permissionsService.checkEdit(getUserId(), baseClass, false);
permissionsService.checkPermission(baseClass, getUserId(), id);
- storage.removeObject(baseClass, new Request(new Condition.Equals("id", "id", id)));
+ storage.removeObject(baseClass, new Request(new Condition.Equals("id", id)));
cacheManager.invalidate(baseClass, id);
LogAction.remove(getUserId(), baseClass, id);