From f77912f14ed17bfbe533b664b6b82154c80e3b58 Mon Sep 17 00:00:00 2001 From: Abyss777 Date: Fri, 21 Jul 2017 11:55:38 +0500 Subject: - Combine all permissions to one resource - Add two helpers to BaseResource --- src/org/traccar/api/resource/PermissionsResource.java | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) (limited to 'src/org/traccar/api/resource/PermissionsResource.java') diff --git a/src/org/traccar/api/resource/PermissionsResource.java b/src/org/traccar/api/resource/PermissionsResource.java index e22ffae36..707242cf1 100644 --- a/src/org/traccar/api/resource/PermissionsResource.java +++ b/src/org/traccar/api/resource/PermissionsResource.java @@ -35,32 +35,18 @@ import org.traccar.api.BaseResource; @Consumes(MediaType.APPLICATION_JSON) public class PermissionsResource extends BaseResource { - @Path("/{slave : (users|devices|groups|geofences|drivers|attributes|calendars)}") @POST public Response add(Map entity) throws SQLException { Context.getPermissionsManager().checkReadonly(getUserId()); - if (entity.size() != 2) { - throw new IllegalArgumentException(); - } - for (String key : entity.keySet()) { - Context.getPermissionsManager().checkPermission(key.replace("Id", ""), getUserId(), entity.get(key)); - } - Context.getDataManager().linkObject(entity, true); + handlePermission(entity, true); Context.getPermissionsManager().refreshPermissions(entity); return Response.noContent().build(); } - @Path("/{slave : (users|devices|groups|geofences|drivers|attributes|calendars)}") @DELETE public Response remove(Map entity) throws SQLException { Context.getPermissionsManager().checkReadonly(getUserId()); - if (entity.size() != 2) { - throw new IllegalArgumentException(); - } - for (String key : entity.keySet()) { - Context.getPermissionsManager().checkPermission(key.replace("Id", ""), getUserId(), entity.get(key)); - } - Context.getDataManager().linkObject(entity, false); + handlePermission(entity, false); Context.getPermissionsManager().refreshPermissions(entity); return Response.noContent().build(); } -- cgit v1.2.3