aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/PositionServlet.java
diff options
context:
space:
mode:
authorRafael Guterres <guterresrafael@gmail.com>2015-11-21 01:57:46 -0200
committerRafael Guterres <guterresrafael@gmail.com>2015-11-21 01:57:46 -0200
commitf5a266953e53a7f1785bcb584759582621ec9de3 (patch)
tree06aed01befc06db1384d731d5d17ee897335c302 /src/org/traccar/web/PositionServlet.java
parentcfe237cf26c6309b8431b3b81d589628ae363804 (diff)
downloadtrackermap-server-f5a266953e53a7f1785bcb584759582621ec9de3.tar.gz
trackermap-server-f5a266953e53a7f1785bcb584759582621ec9de3.tar.bz2
trackermap-server-f5a266953e53a7f1785bcb584759582621ec9de3.zip
Add support to generic resources and refactor in classes to support types and commandpattern.
Diffstat (limited to 'src/org/traccar/web/PositionServlet.java')
-rw-r--r--src/org/traccar/web/PositionServlet.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/org/traccar/web/PositionServlet.java b/src/org/traccar/web/PositionServlet.java
index 796d6a81f..c63968251 100644
--- a/src/org/traccar/web/PositionServlet.java
+++ b/src/org/traccar/web/PositionServlet.java
@@ -23,8 +23,9 @@ import org.traccar.model.Position;
import java.util.HashMap;
import java.util.Map;
+import org.traccar.model.Device;
-public class PositionServlet extends BaseServlet {
+public class PositionServlet extends BaseServletResource<Position> {
@Override
protected boolean handle(String command, HttpServletRequest req, HttpServletResponse resp) throws Exception {
@@ -42,9 +43,10 @@ public class PositionServlet extends BaseServlet {
return true;
}
- private void get(HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ @Override
+ protected void get(HttpServletRequest req, HttpServletResponse resp) throws Exception {
long deviceId = Long.parseLong(req.getParameter("deviceId"));
- Context.getPermissionsManager().checkDevice(getUserId(req), deviceId);
+ Context.getPermissionsManager().check(Device.class, getUserId(req), deviceId);
sendResponse(resp.getWriter(), JsonConverter.arrayToJson(
Context.getDataManager().getPositions(
getUserId(req), deviceId,
@@ -59,7 +61,7 @@ public class PositionServlet extends BaseServlet {
for (String deviceIdString : req.getParameterValues("devicesId")) {
Long deviceId = Long.parseLong(deviceIdString);
- Context.getPermissionsManager().checkDevice(userId, deviceId);
+ Context.getPermissionsManager().check(Device.class, userId, deviceId);
Position position = Context.getConnectionManager().getLastPosition(deviceId);
positions.put(deviceId.toString(), position);