aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/org/traccar/api/BaseObjectResource.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/java/org/traccar/api/BaseObjectResource.java b/src/main/java/org/traccar/api/BaseObjectResource.java
index 7de6a3877..c4206f385 100644
--- a/src/main/java/org/traccar/api/BaseObjectResource.java
+++ b/src/main/java/org/traccar/api/BaseObjectResource.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 - 2018 Anton Tananaev (anton@traccar.org)
+ * Copyright 2017 - 2020 Anton Tananaev (anton@traccar.org)
* Copyright 2017 - 2018 Andrey Kunitsyn (andrey@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,7 @@ import java.sql.SQLException;
import java.util.Set;
import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
@@ -54,7 +55,7 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
}
protected final Set<Long> getSimpleManagerItems(BaseObjectManager<T> manager, boolean all, long userId) {
- Set<Long> result = null;
+ Set<Long> result;
if (all) {
if (Context.getPermissionsManager().getUserAdmin(getUserId())) {
result = manager.getAllItems();
@@ -72,6 +73,19 @@ public abstract class BaseObjectResource<T extends BaseModel> extends BaseResour
return result;
}
+ @Path("{id}")
+ @GET
+ public Response add(@PathParam("id") long id) throws SQLException {
+ Context.getPermissionsManager().checkPermission(baseClass, getUserId(), id);
+ BaseObjectManager<T> manager = Context.getManager(baseClass);
+ T entity = manager.getById(id);
+ if (entity != null) {
+ return Response.ok(entity).build();
+ } else {
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+ }
+
@POST
public Response add(T entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());