aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/CommandServlet.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-11-30 13:55:05 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-11-30 13:55:05 +1300
commitcefc12afe98f610aa0f266bcac4361f9ec414ee5 (patch)
tree48d47a0eec0c2d8a3ee7f448f8d535d7d826d546 /src/org/traccar/web/CommandServlet.java
parentc6692703c8099577cb86c3eace5d8d1bc11f212d (diff)
parent1a25796d62bdf88f2cba0387a09e2eb71599e588 (diff)
downloadtrackermap-server-cefc12afe98f610aa0f266bcac4361f9ec414ee5.tar.gz
trackermap-server-cefc12afe98f610aa0f266bcac4361f9ec414ee5.tar.bz2
trackermap-server-cefc12afe98f610aa0f266bcac4361f9ec414ee5.zip
Merge master of guterresrafael/traccar into rest
Diffstat (limited to 'src/org/traccar/web/CommandServlet.java')
-rw-r--r--src/org/traccar/web/CommandServlet.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/org/traccar/web/CommandServlet.java b/src/org/traccar/web/CommandServlet.java
index 67bca2d57..d307913df 100644
--- a/src/org/traccar/web/CommandServlet.java
+++ b/src/org/traccar/web/CommandServlet.java
@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletResponse;
import org.traccar.Context;
import org.traccar.database.ActiveDevice;
import org.traccar.model.Command;
+import org.traccar.model.Device;
public class CommandServlet extends BaseServlet {
@@ -49,19 +50,17 @@ public class CommandServlet extends BaseServlet {
}
private void send(HttpServletRequest req, HttpServletResponse resp) throws Exception {
-
- Command command = JsonConverter.objectFromJson(req.getReader(), new Command());
- Context.getPermissionsManager().checkDevice(getUserId(req), command.getDeviceId());
+ Command command = JsonConverter.objectFromJson(req.getReader(), Command.class);
+ Context.getPermissionsManager().check(Device.class, getUserId(req), command.getDeviceId());
getActiveDevice(command.getDeviceId()).sendCommand(command);
sendResponse(resp.getWriter(), true);
}
private void raw(HttpServletRequest req, HttpServletResponse resp) throws Exception {
-
JsonObject json = Json.createReader(req.getReader()).readObject();
long deviceId = json.getJsonNumber("deviceId").longValue();
String command = json.getString("command");
- Context.getPermissionsManager().checkDevice(getUserId(req), deviceId);
+ Context.getPermissionsManager().check(Device.class, getUserId(req), deviceId);
getActiveDevice(deviceId).write(command);
sendResponse(resp.getWriter(), true);
}