From cc3fad99dc970e58118efa9444d4fb6b1da74887 Mon Sep 17 00:00:00 2001 From: Mohamed Amine Krout Date: Thu, 11 Jul 2024 12:35:39 +0100 Subject: [PATCH] fix: [BUG] - Download selected documents / folders : Zip creation issue and empty zip - EXO-72976 (#1271) (#1274) --- .../storage/jcr/util/JCRDocumentsUtil.java | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/documents-storage-jcr/src/main/java/org/exoplatform/documents/storage/jcr/util/JCRDocumentsUtil.java b/documents-storage-jcr/src/main/java/org/exoplatform/documents/storage/jcr/util/JCRDocumentsUtil.java index f700bc626..a2768a702 100644 --- a/documents-storage-jcr/src/main/java/org/exoplatform/documents/storage/jcr/util/JCRDocumentsUtil.java +++ b/documents-storage-jcr/src/main/java/org/exoplatform/documents/storage/jcr/util/JCRDocumentsUtil.java @@ -860,7 +860,7 @@ public static void createFile(Node node, Node jrcNode = node.getNode("jcr:content"); InputStream inputStream = jrcNode.getProperty("jcr:data").getStream(); String path = ""; - String nodePath = getPath(node); + String nodePath = node.getPath(); if (StringUtils.isNotEmpty(symlinkPath) || StringUtils.isNotEmpty(sourcePath)) { nodePath = symlinkPath + nodePath.replace(sourcePath, ""); } @@ -885,7 +885,7 @@ public static void createTempFilesAndFolders(Node node, return; } if (JCRDocumentsUtil.isFolder(node)) { - String nodePath = getPath(node); + String nodePath = node.getPath(); if (StringUtils.isNotEmpty(symlinkPath) || StringUtils.isNotEmpty(sourcePath)) { nodePath = symlinkPath + nodePath.replace(sourcePath, ""); } @@ -901,32 +901,13 @@ public static void createTempFilesAndFolders(Node node, String sourceID = node.getProperty(NodeTypeConstants.EXO_SYMLINK_UUID).getString(); Node sourceNode = JCRDocumentsUtil.getNodeByIdentifier(node.getSession(), sourceID); if (sourceNode != null) { - createTempFilesAndFolders(sourceNode, getPath(node), getPath(sourceNode), tempFolderPath, parentPath); + createTempFilesAndFolders(sourceNode, node.getPath(), sourceNode.getPath(), tempFolderPath, parentPath); } } else { createFile(node, symlinkPath, sourcePath, tempFolderPath, parentPath); } } } - - static String getPath(Node node) { - Node parent = node; - LinkedList parents = new LinkedList(); - while (parent != null) { - try { - if (parent.hasProperty(NodeTypeConstants.EXO_TITLE)) { - parents.addFirst(Utils.getStringProperty(parent, NodeTypeConstants.EXO_TITLE)); - } else { - parents.addFirst(parent.getName()); - } - parent = parent.getParent(); - } catch (RepositoryException e) { - parent = null; - } - } - return String.join("/", parents); - } - public static void cleanFiles(File file) { File[] files = file.listFiles(); if (files != null) {