Hi.
Thanks for this solution, it helped us a lot:
We used your solution for revision in filename and improved it a little: Revision filename is added in filename as in your case, but we also add it when downloading document version from history, and also when converting document to pdf.
You will find below the patch.
I think this is worth integrating in community version, what is your opinion about that?
Regards
Mountain73
Code: Select alldiff --git a/src/main/java/com/openkm/servlet/frontend/ConverterServlet.java b/src/main/java/com/openkm/servlet/frontend/ConverterServlet.java
index c4ba980..8b2e9cd 100644
--- a/src/main/java/com/openkm/servlet/frontend/ConverterServlet.java
+++ b/src/main/java/com/openkm/servlet/frontend/ConverterServlet.java
@@ -95,11 +95,12 @@ public class ConverterServlet extends OKMHttpServlet {
String path = OKMRepository.getInstance().getNodePath(null, uuid);
Document doc = OKMDocument.getInstance().getProperties(null, path);
+ final String versionToAppend = OKMDocument.getInstance().getProperties(null,uuid).getActualVersion().getName();
String fileName = PathUtils.getName(doc.getPath());
-
+ String[] nameParts = fileName.split("\\.(?=[^\\.]+$)");
+ String newFileName = nameParts[0] + " rev " + versionToAppend + "." + nameParts[1];
// Save content to temporary file
- tmp = File.createTempFile("okm", "." + FileUtils.getFileExtension(fileName));
-
+ tmp = new File(System.getProperty("java.io.tmpdir"),newFileName);
if (Config.REPOSITORY_NATIVE) {
// If is used to preview, it should workaround the DOWNLOAD extended permission.
is = new DbDocumentModule().getContent(null, path, false, !(toSwf));
@@ -124,7 +125,7 @@ public class ConverterServlet extends OKMHttpServlet {
// Prepare conversion
ConversionData cd = new ConversionData();
cd.uuid = uuid;
- cd.fileName = fileName;
+ cd.fileName = newFileName;
cd.mimeType = doc.getMimeType();
cd.file = tmp;
diff --git a/src/main/java/com/openkm/servlet/frontend/DownloadServlet.java b/src/main/java/com/openkm/servlet/frontend/DownloadServlet.java
index 309481a..ec4aa96 100644
--- a/src/main/java/com/openkm/servlet/frontend/DownloadServlet.java
+++ b/src/main/java/com/openkm/servlet/frontend/DownloadServlet.java
@@ -150,17 +150,21 @@ public class DownloadServlet extends OKMHttpServlet {
if (OKMDocument.getInstance().isValid(null, path)) {
// Get document
Document doc = OKMDocument.getInstance().getProperties(null, path);
-
+ String versionToAppend = "";
if (ver != null && !ver.equals("")) {
is = OKMDocument.getInstance().getContentByVersion(null, path, ver);
+ versionToAppend = " rev " + ver;
} else {
is = OKMDocument.getInstance().getContent(null, path, checkout != null);
- }
-
+ if (checkout == null) {
+ versionToAppend = " rev " + OKMDocument.getInstance().getProperties(null,uuid).getActualVersion().getName();
+ }
+ }
// Send document
String fileName = PathUtils.getName(doc.getPath());
- WebUtils.sendFile(request, response, fileName, doc.getMimeType(), inline, is);
- } else if (OKMMail.getInstance().isValid(null, path)) {
+ String[] nameParts = fileName.split("\\.(?=[^\\.]+$)");
+ String newFileName = nameParts[0] + versionToAppend + "." + nameParts[1];
+ WebUtils.sendFile(request, response, newFileName, doc.getMimeType(), inline, is); } else if (OKMMail.getInstance().isValid(null, path)) {
// Get mail
Mail mail = OKMMail.getInstance().getProperties(null, path);