mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-04-07 14:06:11 +08:00
Java: fix the code and remove the encoding of the url version
This commit is contained in:
@ -177,7 +177,7 @@ public class FileModel
|
||||
|
||||
dataObj.put("fileType", FileUtility.GetFileExtension(document.title).substring(1));
|
||||
dataObj.put("key", key);
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i.toString(), "prev" + FileUtility.GetFileExtension(document.title)));
|
||||
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i, "prev" + FileUtility.GetFileExtension(document.title)));
|
||||
dataObj.put("version", i);
|
||||
|
||||
if (i > 1) { //check if the version number is greater than 1
|
||||
@ -198,13 +198,8 @@ public class FileModel
|
||||
prevInfo.put("url", prev.get("url"));
|
||||
dataObj.put("previous", prevInfo); // write information about previous file version to the data object
|
||||
// write the path to the diff.zip archive with differences in this file version
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
|
||||
Integer verdiff = i - 1;
|
||||
String changesUrl = DocumentManager.GetDownloadHistoryUrl(document.title, verdiff.toString(), "prev" + FileUtility.GetFileExtension(document.title));
|
||||
if (new File(storagePath).isAbsolute()) {
|
||||
changesUrl = DocumentManager.GetDownloadUrl((DocumentManager.VersionDir(histDir, i - 1) + File.separator + "diff.zip").replace(storagePath, ""));
|
||||
}
|
||||
String changesUrl = DocumentManager.GetDownloadHistoryUrl(document.title, verdiff, "diff.zip");
|
||||
dataObj.put("changesUrl", changesUrl);
|
||||
}
|
||||
|
||||
|
||||
@ -169,11 +169,9 @@ public class DocumentManager
|
||||
String hostAddress = CurUserHostAddress(userAddress);
|
||||
String serverPath = request.getSession().getServletContext().getRealPath("");
|
||||
String storagePath = ConfigManager.GetProperty("storage-folder");
|
||||
|
||||
String directory = serverPath + storagePath + File.separator + hostAddress + File.separator;
|
||||
|
||||
if (file == null | file == "") {
|
||||
file = "prev"+fileName.substring(fileName.lastIndexOf("."));
|
||||
if (new File(storagePath).isAbsolute()) {
|
||||
directory = FilesRootPath(userAddress);
|
||||
}
|
||||
|
||||
directory = directory + fileName + "-hist" + File.separator + version + File.separator + file;
|
||||
@ -467,13 +465,13 @@ public class DocumentManager
|
||||
}
|
||||
|
||||
// get url to download a file to History prev.*
|
||||
public static String GetDownloadHistoryUrl(String fileName, String version, String file) {
|
||||
public static String GetDownloadHistoryUrl(String fileName, Integer version, String file) {
|
||||
String serverPath = GetServerUrl(true);
|
||||
String hostAddress = CurUserHostAddress(null);
|
||||
try
|
||||
{
|
||||
String query = "?type=downloadhistory&fileName=" + URLEncoder.encode(fileName, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&userAddress=" + URLEncoder.encode(hostAddress, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
query = query + "&ver=" + URLEncoder.encode(version, java.nio.charset.StandardCharsets.UTF_8.toString()) + "&file=" + URLEncoder.encode(file, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
query = query + "&ver=" + version + "&file=" + URLEncoder.encode(file, java.nio.charset.StandardCharsets.UTF_8.toString());
|
||||
|
||||
return serverPath + "/IndexServlet" + query;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user