From 589582c7ecc0d1cd5321cb6e9f4b823284369498 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 18 Jun 2022 12:30:26 -0700 Subject: Simplify storage interface --- .../java/org/traccar/api/security/PermissionsService.java | 4 +++- src/main/java/org/traccar/storage/Storage.java | 12 ------------ 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main/java/org/traccar/api/security/PermissionsService.java b/src/main/java/org/traccar/api/security/PermissionsService.java index f39ded2b7..ea7a9d572 100644 --- a/src/main/java/org/traccar/api/security/PermissionsService.java +++ b/src/main/java/org/traccar/api/security/PermissionsService.java @@ -100,7 +100,9 @@ public class PermissionsService { } else if (clazz.equals(Device.class)) { denied = getServer().getDeviceReadonly() || getUser(userId).getDeviceReadonly(); if (addition) { - int deviceCount = storage.getPermissions(User.class, userId, Device.class).size(); + int deviceCount = storage.getObjects(Device.class, new Request( + new Columns.Include("id"), + new Condition.Permission(User.class, userId, Device.class))).size(); denied = deviceCount >= getUser(userId).getDeviceLimit(); } } else if (clazz.equals(Command.class)) { diff --git a/src/main/java/org/traccar/storage/Storage.java b/src/main/java/org/traccar/storage/Storage.java index 62dba0165..55f5c22c0 100644 --- a/src/main/java/org/traccar/storage/Storage.java +++ b/src/main/java/org/traccar/storage/Storage.java @@ -45,18 +45,6 @@ public abstract class Storage { return getPermissions(ownerClass, 0, propertyClass, 0); } - public List getPermissions( - Class ownerClass, long ownerId, - Class propertyClass) throws StorageException { - return getPermissions(ownerClass, ownerId, propertyClass, 0); - } - - public List getPermissions( - Class ownerClass, - Class propertyClass, long propertyId) throws StorageException { - return getPermissions(ownerClass, 0, propertyClass, propertyId); - } - public T getObject(Class clazz, Request request) throws StorageException { var objects = getObjects(clazz, request); return objects.isEmpty() ? null : objects.get(0); -- cgit v1.2.3