diff options
author | Abyss777 <abyss@fox5.ru> | 2017-07-21 11:55:38 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2017-07-21 11:55:38 +0500 |
commit | f77912f14ed17bfbe533b664b6b82154c80e3b58 (patch) | |
tree | 62ad0749e28740be85743caa097afac516768302 /src/org/traccar/api/resource/PermissionsResource.java | |
parent | b22735e5dbc22539a6bf9d36cff042094c50d927 (diff) | |
download | trackermap-server-f77912f14ed17bfbe533b664b6b82154c80e3b58.tar.gz trackermap-server-f77912f14ed17bfbe533b664b6b82154c80e3b58.tar.bz2 trackermap-server-f77912f14ed17bfbe533b664b6b82154c80e3b58.zip |
- Combine all permissions to one resource
- Add two helpers to BaseResource
Diffstat (limited to 'src/org/traccar/api/resource/PermissionsResource.java')
-rw-r--r-- | src/org/traccar/api/resource/PermissionsResource.java | 18 |
1 files changed, 2 insertions, 16 deletions
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<String, Long> 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<String, Long> 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(); } |