aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/GroupResource.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-07-21 11:55:38 +0500
committerAbyss777 <abyss@fox5.ru>2017-07-21 11:55:38 +0500
commitf77912f14ed17bfbe533b664b6b82154c80e3b58 (patch)
tree62ad0749e28740be85743caa097afac516768302 /src/org/traccar/api/resource/GroupResource.java
parentb22735e5dbc22539a6bf9d36cff042094c50d927 (diff)
downloadtrackermap-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/GroupResource.java')
-rw-r--r--src/org/traccar/api/resource/GroupResource.java37
1 files changed, 1 insertions, 36 deletions
diff --git a/src/org/traccar/api/resource/GroupResource.java b/src/org/traccar/api/resource/GroupResource.java
index 0d9572332..5d575ebfe 100644
--- a/src/org/traccar/api/resource/GroupResource.java
+++ b/src/org/traccar/api/resource/GroupResource.java
@@ -32,8 +32,6 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.sql.SQLException;
import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
@Path("groups")
@Produces(MediaType.APPLICATION_JSON)
@@ -63,10 +61,7 @@ public class GroupResource extends BaseResource {
public Response add(Group entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
Context.getDeviceManager().addGroup(entity);
- LinkedHashMap<String, Long> link = new LinkedHashMap<>();
- link.put("userId", getUserId());
- link.put("groupId", entity.getId());
- Context.getDataManager().linkObject(link, true);
+ linkNew(entity);
Context.getPermissionsManager().refreshPermissions();
Context.getPermissionsManager().refreshAllExtendedPermissions();
return Response.ok(entity).build();
@@ -93,34 +88,4 @@ public class GroupResource extends BaseResource {
return Response.noContent().build();
}
- @Path("/{slave : (geofences|drivers|attributes)}")
- @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);
- Context.getPermissionsManager().refreshPermissions(entity);
- return Response.noContent().build();
- }
-
- @Path("/{slave : (geofences|drivers|attributes)}")
- @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);
- Context.getPermissionsManager().refreshPermissions(entity);
- return Response.noContent().build();
- }
-
}