aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/web/ServerServlet.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/web/ServerServlet.java')
-rw-r--r--src/org/traccar/web/ServerServlet.java27
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);
+ }
+
}