aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/DeviceServlet.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-12-07 10:09:08 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2015-12-07 10:09:08 +1300
commit5b57c0fdb81bae87ca487e1d0087f8927b3fd07f (patch)
treec3733bca54002ca694b6d7b83b147de87212c5eb /src/org/traccar/web/DeviceServlet.java
parent33b2a5c9ab70ffe7bbdd074ce430920d2a0d3941 (diff)
downloadtrackermap-server-5b57c0fdb81bae87ca487e1d0087f8927b3fd07f.tar.gz
trackermap-server-5b57c0fdb81bae87ca487e1d0087f8927b3fd07f.tar.bz2
trackermap-server-5b57c0fdb81bae87ca487e1d0087f8927b3fd07f.zip
Replace factory method with reflection
Diffstat (limited to 'src/org/traccar/web/DeviceServlet.java')
-rw-r--r--src/org/traccar/web/DeviceServlet.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/org/traccar/web/DeviceServlet.java b/src/org/traccar/web/DeviceServlet.java
index 8f983ad78..a501bd8f6 100644
--- a/src/org/traccar/web/DeviceServlet.java
+++ b/src/org/traccar/web/DeviceServlet.java
@@ -70,7 +70,7 @@ public class DeviceServlet extends BaseServlet {
}
private void add(HttpServletRequest req, HttpServletResponse resp) throws Exception {
- Device device = JsonConverter.objectFromJson(req.getReader(), new Device());
+ Device device = JsonConverter.objectFromJson(req.getReader(), Device.class);
long userId = getUserId(req);
Context.getDataManager().addDevice(device);
Context.getDataManager().linkDevice(userId, device.getId());
@@ -79,14 +79,14 @@ public class DeviceServlet extends BaseServlet {
}
private void update(HttpServletRequest req, HttpServletResponse resp) throws Exception {
- Device device = JsonConverter.objectFromJson(req.getReader(), new Device());
+ Device device = JsonConverter.objectFromJson(req.getReader(), Device.class);
Context.getPermissionsManager().checkDevice(getUserId(req), device.getId());
Context.getDataManager().updateDevice(device);
sendResponse(resp.getWriter(), true);
}
private void remove(HttpServletRequest req, HttpServletResponse resp) throws Exception {
- Device device = JsonConverter.objectFromJson(req.getReader(), new Device());
+ Device device = JsonConverter.objectFromJson(req.getReader(), Device.class);
Context.getPermissionsManager().checkDevice(getUserId(req), device.getId());
Context.getDataManager().removeDevice(device);
Context.getPermissionsManager().refresh();