diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-17 12:35:16 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2015-10-17 12:35:16 +1300 |
commit | 843a370660646499c3007256be953506567f23fb (patch) | |
tree | bb912568b1dad621271a2016ba946634e8e93306 /src/org/traccar/web/DeviceServlet.java | |
parent | 60343748265c7fdc228bc7078d2defb877bf66e1 (diff) | |
download | trackermap-server-843a370660646499c3007256be953506567f23fb.tar.gz trackermap-server-843a370660646499c3007256be953506567f23fb.tar.bz2 trackermap-server-843a370660646499c3007256be953506567f23fb.zip |
Add linking and unlinking of devices
Diffstat (limited to 'src/org/traccar/web/DeviceServlet.java')
-rw-r--r-- | src/org/traccar/web/DeviceServlet.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/org/traccar/web/DeviceServlet.java b/src/org/traccar/web/DeviceServlet.java index 1ae94c1d0..8f983ad78 100644 --- a/src/org/traccar/web/DeviceServlet.java +++ b/src/org/traccar/web/DeviceServlet.java @@ -38,6 +38,12 @@ public class DeviceServlet extends BaseServlet { case "/remove": remove(req, resp); break; + case "/link": + link(req, resp); + break; + case "/unlink": + unlink(req, resp); + break; default: return false; } @@ -87,4 +93,22 @@ public class DeviceServlet extends BaseServlet { sendResponse(resp.getWriter(), true); } + private void link(HttpServletRequest req, HttpServletResponse resp) throws Exception { + Context.getPermissionsManager().checkAdmin(getUserId(req)); + Context.getDataManager().linkDevice( + Long.parseLong(req.getParameter("userId")), + Long.parseLong(req.getParameter("deviceId"))); + Context.getPermissionsManager().refresh(); + sendResponse(resp.getWriter(), true); + } + + private void unlink(HttpServletRequest req, HttpServletResponse resp) throws Exception { + Context.getPermissionsManager().checkAdmin(getUserId(req)); + Context.getDataManager().unlinkDevice( + Long.parseLong(req.getParameter("userId")), + Long.parseLong(req.getParameter("deviceId"))); + Context.getPermissionsManager().refresh(); + sendResponse(resp.getWriter(), true); + } + } |