From 215ade01a36146e00a07c40916b7bd56cc15a737 Mon Sep 17 00:00:00 2001 From: Olga Larinova Date: Fri, 18 Mar 2022 09:32:34 +0300 Subject: [PATCH] java: changing arguments --- .../src/main/java/controllers/IndexServlet.java | 7 +++++-- .../java/src/main/java/helpers/TrackManager.java | 16 +++++----------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index c5fa2279..92d973fd 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -329,7 +329,7 @@ public class IndexServlet extends HttpServlet if (users.indexOf(user) == -1) { String key = (String) body.get("key"); try { - TrackManager.commandRequest("forcesave", key); // create a command request with the forcesave method + TrackManager.commandRequest("forcesave", key, null); // create a command request with the forcesave method } catch (Exception e) { e.printStackTrace(); } @@ -573,7 +573,10 @@ public class IndexServlet extends HttpServlet String newfilename = (String) body.get("newfilename"); String dockey = (String) body.get("dockey"); - TrackManager.commandRequest(newfilename, dockey); + HashMap meta = new HashMap<>(); + meta.put("title", newfilename); + + TrackManager.commandRequest("meta", dockey, meta); } catch (Exception e) { e.printStackTrace(); diff --git a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java index 0076f9c8..b0a58a5d 100755 --- a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java @@ -277,23 +277,17 @@ public class TrackManager { } // create a command request - public static void commandRequest(String method, String key) throws Exception { + public static void commandRequest(String method, String key, HashMap meta) throws Exception { String DocumentCommandUrl = ConfigManager.GetProperty("files.docservice.url.site") + ConfigManager.GetProperty("files.docservice.url.command"); URL url = new URL(DocumentCommandUrl); java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection(); HashMap params = new HashMap(); + params.put("c", method); + params.put("key", key); - if (method == "forcesave") { - params.put("c", method); - params.put("key", key); - } else { - HashMap meta = new HashMap<>(); - meta.put("title", method); - - params.put("c", "meta"); - params.put("key", key); + if (meta != null) { params.put("meta", meta); } @@ -324,7 +318,7 @@ public class TrackManager { try (OutputStream os = connection.getOutputStream()) { os.write(bodyByte); // write bytes to the output stream } - InputStream stream = connection.getInputStream();; // get input stream + InputStream stream = connection.getInputStream(); // get input stream if (stream == null) throw new Exception("Could not get an answer");