From 8098c2ba47e36b1aa7293a5e3987fd24e94fecf4 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Tue, 30 Apr 2019 23:20:06 -0700 Subject: Add API to get command types by protocol --- src/main/java/org/traccar/api/resource/CommandResource.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/main/java/org/traccar/api') diff --git a/src/main/java/org/traccar/api/resource/CommandResource.java b/src/main/java/org/traccar/api/resource/CommandResource.java index 703638701..a31345246 100644 --- a/src/main/java/org/traccar/api/resource/CommandResource.java +++ b/src/main/java/org/traccar/api/resource/CommandResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2017 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2019 Anton Tananaev (anton@traccar.org) * Copyright 2016 Gabor Somogyi (gabor.g.somogyi@gmail.com) * Copyright 2017 Andrey Kunitsyn (andrey@traccar.org) * @@ -23,7 +23,6 @@ import org.traccar.database.CommandsManager; import org.traccar.model.Command; import org.traccar.model.Typed; -import java.sql.SQLException; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -48,7 +47,7 @@ public class CommandResource extends ExtendedObjectResource { @GET @Path("send") - public Collection get(@QueryParam("deviceId") long deviceId) throws SQLException { + public Collection get(@QueryParam("deviceId") long deviceId) { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); CommandsManager commandsManager = Context.getCommandsManager(); Set result = new HashSet<>(commandsManager.getUserItems(getUserId())); @@ -77,11 +76,15 @@ public class CommandResource extends ExtendedObjectResource { @GET @Path("types") - public Collection get(@QueryParam("deviceId") long deviceId, + public Collection get( + @QueryParam("deviceId") long deviceId, + @QueryParam("protocol") String protocol, @QueryParam("textChannel") boolean textChannel) { if (deviceId != 0) { Context.getPermissionsManager().checkDevice(getUserId(), deviceId); return Context.getCommandsManager().getCommandTypes(deviceId, textChannel); + } else if (protocol != null) { + return Context.getCommandsManager().getCommandTypes(protocol, textChannel); } else { return Context.getCommandsManager().getAllCommandTypes(); } -- cgit v1.2.3