java: changing arguments

This commit is contained in:
Olga Larinova
2022-03-18 09:32:34 +03:00
parent eb196613e7
commit 215ade01a3
2 changed files with 10 additions and 13 deletions

View File

@ -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<String, String> meta = new HashMap<>();
meta.put("title", newfilename);
TrackManager.commandRequest("meta", dockey, meta);
} catch (Exception e) {
e.printStackTrace();

View File

@ -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<String, Object> params = new HashMap<String, Object>();
params.put("c", method);
params.put("key", key);
if (method == "forcesave") {
params.put("c", method);
params.put("key", key);
} else {
HashMap<String, Object> 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");