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, 17 insertions, 10 deletions
diff --git a/src/org/traccar/web/ServerServlet.java b/src/org/traccar/web/ServerServlet.java
index 7ed096bc6..312876f36 100644
--- a/src/org/traccar/web/ServerServlet.java
+++ b/src/org/traccar/web/ServerServlet.java
@@ -18,16 +18,17 @@ 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 BaseServlet {
+public class ServerServlet extends BaseServletResource<Server> {
@Override
protected boolean handle(String command, HttpServletRequest req, HttpServletResponse resp) throws Exception {
switch (command) {
case "/get":
- get(resp);
+ get(req, resp);
break;
case "/update":
update(req, resp);
@@ -38,16 +39,22 @@ public class ServerServlet extends BaseServlet {
return true;
}
- private void get(HttpServletResponse resp) throws Exception {
- sendResponse(resp.getWriter(), JsonConverter.objectToJson(
- Context.getDataManager().getServer()));
+ @Override
+ protected void update(HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ super.update(req, resp, new CommandCall() {
+
+ @Override
+ public void check() {
+ Context.getPermissionsManager().checkAdmin(getUserId());
+ }
+
+ });
}
- 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);
+ @Override
+ protected void get(HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ sendResponse(resp.getWriter(), JsonConverter.objectToJson(
+ Context.getDataManager().getServer()));
}
}