From bf68718e05f811ffeb2b4b57acab56dca3e7de56 Mon Sep 17 00:00:00 2001 From: Gábor Somogyi Date: Wed, 27 Apr 2016 22:22:08 +0200 Subject: Command framework ugly hack version --- src/org/traccar/api/resource/DeviceResource.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/org/traccar/api') diff --git a/src/org/traccar/api/resource/DeviceResource.java b/src/org/traccar/api/resource/DeviceResource.java index a4bfc1030..90d3ef675 100644 --- a/src/org/traccar/api/resource/DeviceResource.java +++ b/src/org/traccar/api/resource/DeviceResource.java @@ -19,6 +19,7 @@ import org.traccar.Context; import org.traccar.api.BaseResource; import java.sql.SQLException; +import java.util.ArrayList; import java.util.Collection; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -31,7 +32,12 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; + +import org.traccar.helper.Log; +import org.traccar.model.Command; import org.traccar.model.Device; +import org.traccar.model.Position; +import org.traccar.model.SupportedCommand; @Path("devices") @Produces(MediaType.APPLICATION_JSON) @@ -81,4 +87,11 @@ public class DeviceResource extends BaseResource { return Response.noContent().build(); } + @Path("{id}/supportedcommands") + @GET + public Collection get(@PathParam("id") long id) throws SQLException { + Context.getPermissionsManager().checkDevice(getUserId(), id); + Position latestPosition = Context.getDataManager().getLatestPosition(id); + return Context.getServerManager().getProtocolSuppportedCommands(latestPosition.getProtocol()); + } } -- cgit v1.2.3