mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
java: changing arguments
This commit is contained in:
@ -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();
|
||||
|
||||
@ -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");
|
||||
|
||||
Reference in New Issue
Block a user