diff --git a/modules/content_management/dist/maarchCM.jar b/modules/content_management/dist/maarchCM.jar index 1647f4f19d8e2399ae9deb0fff5822f0e84faaeb..88810e42bdd928e6f01067de844fd6c7d39ae2b0 100644 Binary files a/modules/content_management/dist/maarchCM.jar and b/modules/content_management/dist/maarchCM.jar differ diff --git a/modules/content_management/dist/not_signed/maarchCM.jar b/modules/content_management/dist/not_signed/maarchCM.jar index ca094010467be26803c485b80067d968599eb140..55314d2d605df605dbdefcd44afe80df749e17d7 100644 Binary files a/modules/content_management/dist/not_signed/maarchCM.jar and b/modules/content_management/dist/not_signed/maarchCM.jar differ diff --git a/modules/content_management/dist/src/FileManager.java b/modules/content_management/dist/src/FileManager.java index 6980d78a6d2a180278be466bd2353eacf1b07079..6b6ff16db4676801c53ad87cc2f8588b3002590c 100644 --- a/modules/content_management/dist/src/FileManager.java +++ b/modules/content_management/dist/src/FileManager.java @@ -340,5 +340,12 @@ public class FileManager { } } } - } + } + + public static String getFileExtension(File file) { + String fileName = file.getName(); + if(fileName.lastIndexOf(".") != -1 && fileName.lastIndexOf(".") != 0) + return fileName.substring(fileName.lastIndexOf(".")+1); + else return ""; + } } diff --git a/modules/content_management/dist/src/MaarchCM.java b/modules/content_management/dist/src/MaarchCM.java index b7aa4179aa547f80016874a3b99f78982f3ff990..4d3ca1163d8b62eb839fba9dea3ea4ea428ac83c 100644 --- a/modules/content_management/dist/src/MaarchCM.java +++ b/modules/content_management/dist/src/MaarchCM.java @@ -23,6 +23,7 @@ import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.FileSystems; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; @@ -768,7 +769,9 @@ public class MaarchCM { public void editObject_v2() throws InterruptedException, IOException, PrivilegedActionException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, Exception { String urlToSend; if (checksumFile(md5File) == false) { - logger.log("The file is not here in maarchTmp folder.", Level.INFO); + System.out.println("The file is not found in maarchTmp folder."); + logger.log("The file is not found in maarchTmp folder.", Level.INFO); + System.out.println("RETRIEVE DOCUMENT ..."); logger.log("RETRIEVE DOCUMENT ...", Level.INFO); urlToSend = url + "?action=editObject&objectType=" + objectType @@ -783,9 +786,15 @@ public class MaarchCM { logger.log("CREATE FILE IN LOCAL PATH", Level.INFO); //fileToEdit = "thefile_" + idApplet + "." + fileExtension; + if (md5File.equals("0")) { + md5File = "thefile_" + idApplet; + } fileToEdit = md5File + "." + fileExtension; fM.createFile(fileContent, userLocalDirTmp + File.separator + fileToEdit); + } else { + System.out.println("Document found in maarchTmp folder !"); + logger.log("Document found in maarchTmp folder !", Level.INFO); } //fileToDelete.add(userLocalDirTmp + File.separator + fileToEdit); @@ -916,13 +925,23 @@ public class MaarchCM { endMessage = endMessage + " mais la conversion pdf n'a pas fonctionné (le document ne pourra pas être signé)"; } } - File fileToRename = new File(userLocalDirTmp + File.separator + fileToEdit); + logger.log("----------END SEND OF THE OBJECT----------", Level.INFO); + + logger.log("----------CREATE NEW TMP FILE----------", Level.INFO); String newMd5 = getchecksumFile(userLocalDirTmp + File.separator + fileToEdit); - fileToRename.renameTo(new File(userLocalDirTmp + File.separator + newMd5 + "." + fileExtension)); + + if (os.equals("win")) { + fileContent = FileManager.encodeFile(userLocalDirTmp + File.separator + fileToEdit); + fM.createFile(fileContent,userLocalDirTmp + File.separator + newMd5 + "." + fileExtension); + } else { + Files.move(new File(userLocalDirTmp + File.separator + fileToEdit).toPath(), new File(userLocalDirTmp + File.separator + newMd5 + "." + fileExtension).toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING); + } + FileManager.deleteSpecificFilesOnDir(fileToDelete); FileManager.deleteEnvDir(userLocalDirTmp + File.separator + idApplet + "_conv"); FileManager.deleteFilesOnDirWithTime(userLocalDirTmp); - logger.log("----------END SEND OF THE OBJECT----------", Level.INFO); + + return; } } @@ -1026,6 +1045,7 @@ public class MaarchCM { System.out.println("MD5 checksum file found ! " + checksum); if (checksum.equals(md5)) { fileToEdit = child.getName().toString(); + fileExtension = FileManager.getFileExtension(child); return true; } else { return false;