diff --git a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java index 26206d81..89e01672 100755 --- a/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java +++ b/web/documentserver-example/java/src/main/java/controllers/IndexServlet.java @@ -635,7 +635,7 @@ public class IndexServlet extends HttpServlet { String newfilename = (String) body.get("newfilename"); String dockey = (String) body.get("dockey"); - String origExt = "." + (String) body.get("ext"); + String origExt = (String) body.get("ext"); String curExt = newfilename; if (newfilename.indexOf(".") != -1) { @@ -643,7 +643,7 @@ public class IndexServlet extends HttpServlet { } if (origExt.compareTo(curExt) != 0) { - newfilename += origExt; + newfilename += "." + origExt; } HashMap meta = new HashMap<>(); @@ -724,7 +724,7 @@ public class IndexServlet extends HttpServlet { referenceData.put("fileKey", gson.toJson(fileKey)); HashMap data = new HashMap<>(); - data.put("fileType", FileUtility.getFileExtension(fileName).replace(".", "")); + data.put("fileType", FileUtility.getFileExtension(fileName)); data.put("url", DocumentManager.getDownloadUrl(fileName, true)); data.put("directUrl", directUrl ? DocumentManager.getDownloadUrl(fileName, false) : null); data.put("referenceData", referenceData); @@ -805,7 +805,7 @@ public class IndexServlet extends HttpServlet { bumpedChangesFileWriter.close(); String sourceExtension = FileUtility.getFileExtension(sourceBasename); - String previousBasename = "prev" + sourceExtension; + String previousBasename = "prev." + sourceExtension; Path bumpedFile = Paths.get(bumpedVersionStringDirectory, previousBasename); Files.move(sourcePathFile, bumpedFile); @@ -947,16 +947,16 @@ public class IndexServlet extends HttpServlet { key = DocumentManager.readFileToEnd(new File(verDir + File.separator + "key.txt")); } - dataObj.put("fileType", FileUtility.getFileExtension(fileName).substring(1)); + dataObj.put("fileType", FileUtility.getFileExtension(fileName)); dataObj.put("key", key); dataObj.put("url", i == curVer ? DocumentManager.getDownloadUrl(fileName, true) - : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev." + FileUtility .getFileExtension(fileName), true)); if (directUrl.equals("true")) { dataObj.put("directUrl", i == curVer ? DocumentManager.getDownloadUrl(fileName, false) - : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev" + FileUtility + : DocumentManager.getDownloadHistoryUrl(fileName, i, "prev." + FileUtility .getFileExtension(fileName), false)); } diff --git a/web/documentserver-example/java/src/main/java/entities/FileModel.java b/web/documentserver-example/java/src/main/java/entities/FileModel.java index 13e94499..c50c4ad3 100755 --- a/web/documentserver-example/java/src/main/java/entities/FileModel.java +++ b/web/documentserver-example/java/src/main/java/entities/FileModel.java @@ -63,7 +63,7 @@ public class FileModel { document.setDirectUrl(isEnableDirectUrl ? DocumentManager.getDownloadUrl(fileName, false) : ""); // get file extension from the file name - document.setFileType(FileUtility.getFileExtension(fileName).replace(".", "")); + document.setFileType(FileUtility.getFileExtension(fileName)); // generate document key document.setKey(ServiceConverter .generateRevisionId(DocumentManager diff --git a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java index 90472488..2e4d5dc1 100755 --- a/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/DocumentManager.java @@ -248,12 +248,12 @@ public final class DocumentManager { public static String getCorrectName(final String fileName, final String userAddress) { String baseName = FileUtility.getFileNameWithoutExtension(fileName); String ext = FileUtility.getFileExtension(fileName); - String name = baseName + ext; + String name = baseName + "." + ext; File file = new File(storagePath(name, userAddress)); for (int i = 1; file.exists(); i++) { // run through all the files with such a name in the storage directory - name = baseName + " (" + i + ")" + ext; // and add an index to the base name + name = baseName + " (" + i + ")." + ext; // and add an index to the base name file = new File(storagePath(name, userAddress)); } diff --git a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java index e98446a9..1ebc5fd4 100644 --- a/web/documentserver-example/java/src/main/java/helpers/FileUtility.java +++ b/web/documentserver-example/java/src/main/java/helpers/FileUtility.java @@ -75,7 +75,7 @@ public final class FileUtility { if (fileName == null) { return null; } - String fileExt = fileName.substring(fileName.lastIndexOf(".")); + String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1); return fileExt.toLowerCase(); } diff --git a/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java b/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java index de29d42e..9c76e84f 100644 --- a/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java +++ b/web/documentserver-example/java/src/main/java/helpers/ServiceConverter.java @@ -158,8 +158,8 @@ public final class ServiceConverter { ConvertBody body = new ConvertBody(); body.setRegion(lang); body.setUrl(documentUri); - body.setOutputtype(toExtension.replace(".", "")); - body.setFiletype(fromExt.replace(".", "")); + body.setOutputtype(toExtension); + body.setFiletype(fromExt); body.setTitle(title); body.setKey(documentRevId); body.setPassword(filePass); diff --git a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java index 5acddef1..83fdae5e 100755 --- a/web/documentserver-example/java/src/main/java/helpers/TrackManager.java +++ b/web/documentserver-example/java/src/main/java/helpers/TrackManager.java @@ -150,7 +150,7 @@ public final class TrackManager { String newFileName = fileName; String curExt = FileUtility.getFileExtension(fileName); // get current file extension - String downloadExt = "." + (String) body.get("filetype"); // get the extension of the downloaded file + String downloadExt = (String) body.get("filetype"); // get the extension of the downloaded file // convert downloaded file to the file with the current extension if these extensions aren't equal if (!curExt.equals(downloadExt)) { @@ -164,13 +164,13 @@ public final class TrackManager { // get the correct file name if it already exists newFileName = DocumentManager .getCorrectName(FileUtility - .getFileNameWithoutExtension(fileName) + downloadExt, userAddress); + .getFileNameWithoutExtension(fileName) + "." + downloadExt, userAddress); } else { downloadUri = newFileUri; } } catch (Exception e) { newFileName = DocumentManager.getCorrectName(FileUtility - .getFileNameWithoutExtension(fileName) + downloadExt, userAddress); + .getFileNameWithoutExtension(fileName) + "." + downloadExt, userAddress); } } @@ -193,7 +193,7 @@ public final class TrackManager { } // get the path to the previous file version and rename the last file version with it - lastVersion.renameTo(new File(versionDir + File.separator + "prev" + curExt)); + lastVersion.renameTo(new File(versionDir + File.separator + "prev." + curExt)); saveFile(byteArrayFile, toSave); // save document file @@ -236,7 +236,7 @@ public final class TrackManager { String downloadUri = (String) body.get("url"); String curExt = FileUtility.getFileExtension(fileName); // get current file extension - String downloadExt = "." + (String) body.get("filetype"); // get the extension of the downloaded file + String downloadExt = (String) body.get("filetype"); // get the extension of the downloaded file Boolean newFileName = false; @@ -265,10 +265,10 @@ public final class TrackManager { // new file if (newFileName) { fileName = DocumentManager.getCorrectName(FileUtility.getFileNameWithoutExtension(fileName) - + "-form" + downloadExt, userAddress); // get the correct file name if it already exists + + "-form." + downloadExt, userAddress); // get the correct file name if it already exists } else { fileName = DocumentManager.getCorrectName(FileUtility.getFileNameWithoutExtension(fileName) - + "-form" + curExt, userAddress); + + "-form." + curExt, userAddress); } forcesavePath = DocumentManager.storagePath(fileName, userAddress); } else { diff --git a/web/documentserver-example/java/src/main/webapp/index.jsp b/web/documentserver-example/java/src/main/webapp/index.jsp index ca1dbab6..2a95a6f6 100755 --- a/web/documentserver-example/java/src/main/webapp/index.jsp +++ b/web/documentserver-example/java/src/main/webapp/index.jsp @@ -367,9 +367,9 @@