aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/api/resource
diff options
context:
space:
mode:
authorjcardus <asklocation.net@gmail.com>2021-07-11 02:05:50 +0100
committerjcardus <asklocation.net@gmail.com>2021-07-11 02:05:50 +0100
commitce3a16ef9d235390e839e6c01bc2ccc96049ead6 (patch)
treeb89d37cac95a4fdc79facf8aab22e58259fecbf9 /src/main/java/org/traccar/api/resource
parent9562e31ffebaa9621b28bce453d4383e9eed78b2 (diff)
downloadtrackermap-server-ce3a16ef9d235390e839e6c01bc2ccc96049ead6.tar.gz
trackermap-server-ce3a16ef9d235390e839e6c01bc2ccc96049ead6.tar.bz2
trackermap-server-ce3a16ef9d235390e839e6c01bc2ccc96049ead6.zip
check permission types
Diffstat (limited to 'src/main/java/org/traccar/api/resource')
-rw-r--r--src/main/java/org/traccar/api/resource/PermissionsResource.java16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/api/resource/PermissionsResource.java b/src/main/java/org/traccar/api/resource/PermissionsResource.java
index db16bf941..50ae11aaf 100644
--- a/src/main/java/org/traccar/api/resource/PermissionsResource.java
+++ b/src/main/java/org/traccar/api/resource/PermissionsResource.java
@@ -20,6 +20,7 @@ import java.sql.SQLException;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Set;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -82,16 +83,13 @@ public class PermissionsResource extends BaseResource {
return Response.noContent().build();
}
- private void checkPermissionTypes(List<LinkedHashMap<String, Long>> entities) throws ClassNotFoundException {
- if (!entities.isEmpty()) {
- Permission first = new Permission(entities.get(0));
- for (LinkedHashMap<String, Long> entity: entities) {
- Permission permission = new Permission(entity);
- if (!first.getOwnerClass().equals(permission.getOwnerClass())
- || !first.getPropertyClass().equals(permission.getPropertyClass())) {
- throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).build());
- }
+ private void checkPermissionTypes(List<LinkedHashMap<String, Long>> entities) {
+ Set<String> keys = null;
+ for (LinkedHashMap<String, Long> entity: entities) {
+ if (keys != null & !entity.keySet().equals(keys)) {
+ throw new WebApplicationException(Response.status(Response.Status.BAD_REQUEST).build());
}
+ keys = entity.keySet();
}
}