Add link(handler) to onRequestHistoryData jwt Java

This commit is contained in:
Andrey Yumatov
2021-12-17 15:39:38 +03:00
parent 2accdeac3b
commit dfd2d49e6c
2 changed files with 18 additions and 1 deletions

View File

@ -180,7 +180,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.GetPathUri(verDir + File.separator + "prev" + FileUtility.GetFileExtension(document.title)));
dataObj.put("url", i == curVer ? document.url : DocumentManager.GetDownloadHistoryUrl(document.title, i.toString(), "prev" + FileUtility.GetFileExtension(document.title)));
dataObj.put("version", i);
if (i > 1) { //check if the version number is greater than 1

View File

@ -446,6 +446,23 @@ public class DocumentManager
}
}
// get url to download a file to History prev.*
public static String GetDownloadHistoryUrl(String fileName, String version, String file) {
String serverPath = GetServerUrl(true);
String hostAddress = CurUserHostAddress(null);
try
{
String query = "?type=download&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());
return serverPath + "/IndexServlet" + query;
}
catch (UnsupportedEncodingException e)
{
return "";
}
}
// get an editor internal extension
public static String GetInternalExtension(FileType fileType)
{