diff options
Diffstat (limited to 'src/org/traccar/api')
-rw-r--r-- | src/org/traccar/api/resource/DeviceResource.java | 13 |
1 files changed, 13 insertions, 0 deletions
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<SupportedCommand> get(@PathParam("id") long id) throws SQLException { + Context.getPermissionsManager().checkDevice(getUserId(), id); + Position latestPosition = Context.getDataManager().getLatestPosition(id); + return Context.getServerManager().getProtocolSuppportedCommands(latestPosition.getProtocol()); + } } |