diff options
author | Rafael Guterres <guterresrafael@gmail.com> | 2015-11-27 03:32:59 -0200 |
---|---|---|
committer | Rafael Guterres <guterresrafael@gmail.com> | 2015-11-27 03:32:59 -0200 |
commit | c57bd2d472467b1b3a45aee1b97c9a0aeef5958a (patch) | |
tree | 26fae20adf1970b5834f06393a3c703c972f39b1 /src/org/traccar/web/ServerServlet.java | |
parent | 77cd23da84ebebcf99a97a8aef88aa9a4884ca40 (diff) | |
download | trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.tar.gz trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.tar.bz2 trackermap-server-c57bd2d472467b1b3a45aee1b97c9a0aeef5958a.zip |
Initial implementation of new api with jax-rs.
Revert servlets to old api and remove plurals.
Fix findbugs for header origin.
Diffstat (limited to 'src/org/traccar/web/ServerServlet.java')
-rw-r--r-- | src/org/traccar/web/ServerServlet.java | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/org/traccar/web/ServerServlet.java b/src/org/traccar/web/ServerServlet.java index 312876f36..7ed096bc6 100644 --- a/src/org/traccar/web/ServerServlet.java +++ b/src/org/traccar/web/ServerServlet.java @@ -18,17 +18,16 @@ package org.traccar.web; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.traccar.Context; -import org.traccar.helper.CommandCall; import org.traccar.model.Server; -public class ServerServlet extends BaseServletResource<Server> { +public class ServerServlet extends BaseServlet { @Override protected boolean handle(String command, HttpServletRequest req, HttpServletResponse resp) throws Exception { switch (command) { case "/get": - get(req, resp); + get(resp); break; case "/update": update(req, resp); @@ -39,22 +38,16 @@ public class ServerServlet extends BaseServletResource<Server> { return true; } - @Override - protected void update(HttpServletRequest req, HttpServletResponse resp) throws Exception { - super.update(req, resp, new CommandCall() { - - @Override - public void check() { - Context.getPermissionsManager().checkAdmin(getUserId()); - } - - }); - } - - @Override - protected void get(HttpServletRequest req, HttpServletResponse resp) throws Exception { + private void get(HttpServletResponse resp) throws Exception { sendResponse(resp.getWriter(), JsonConverter.objectToJson( Context.getDataManager().getServer())); } + private void update(HttpServletRequest req, HttpServletResponse resp) throws Exception { + Server server = JsonConverter.objectFromJson(req.getReader(), new Server()); + Context.getPermissionsManager().checkAdmin(getUserId(req)); + Context.getDataManager().updateServer(server); + sendResponse(resp.getWriter(), true); + } + } |