aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-10-07 09:21:33 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-10-07 09:21:33 -0700
commit1f37392e344faae3eb717ffe39f4c182b752ad2d (patch)
treea551502bea5b2a28bfd0d268b138497104cc5f68 /src
parent90d5b6ff470aea80679b05ba690fe0630f111dc7 (diff)
downloadtrackermap-server-1f37392e344faae3eb717ffe39f4c182b752ad2d.tar.gz
trackermap-server-1f37392e344faae3eb717ffe39f4c182b752ad2d.tar.bz2
trackermap-server-1f37392e344faae3eb717ffe39f4c182b752ad2d.zip
Better events API errors
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/traccar/api/resource/EventResource.java5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/main/java/org/traccar/api/resource/EventResource.java b/src/main/java/org/traccar/api/resource/EventResource.java
index e0ccf7020..f0a71d30d 100644
--- a/src/main/java/org/traccar/api/resource/EventResource.java
+++ b/src/main/java/org/traccar/api/resource/EventResource.java
@@ -7,7 +7,9 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.traccar.Context;
import org.traccar.api.BaseResource;
@@ -25,6 +27,9 @@ public class EventResource extends BaseResource {
@GET
public Event get(@PathParam("id") long id) throws SQLException {
Event event = Context.getDataManager().getObject(Event.class, id);
+ if (event == null) {
+ throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
+ }
Context.getPermissionsManager().checkDevice(getUserId(), event.getDeviceId());
if (event.getGeofenceId() != 0) {
Context.getPermissionsManager().checkPermission(Geofence.class, getUserId(), event.getGeofenceId());