From 4bf8cac4ce15a4a4d7e4a8bcea53f1d243b8f0c7 Mon Sep 17 00:00:00 2001 From: srosse <none@none> Date: Tue, 22 Nov 2011 17:00:33 +0100 Subject: [PATCH] FXOLAT-361: fix an issue in resolve patch from Uni. wich returned the LocalFile with the wrong parentContainer --- .../java/org/olat/core/util/vfs/VFSManager.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/olat/core/util/vfs/VFSManager.java b/src/main/java/org/olat/core/util/vfs/VFSManager.java index a7be0f073a4..41133ae9454 100644 --- a/src/main/java/org/olat/core/util/vfs/VFSManager.java +++ b/src/main/java/org/olat/core/util/vfs/VFSManager.java @@ -130,18 +130,22 @@ public class VFSManager extends BasicManager { // exists. If yes, this entry must be exactly what is // to be returned as, the proper type of, VFSItem. if (rootContainer instanceof LocalFolderImpl) { + String childName = extractChild(path); LocalFolderImpl l = (LocalFolderImpl) rootContainer; - String fsPath = l.getBasefile().getAbsolutePath()+path; - File t = new File (fsPath); + File t = new File (l.getBasefile().getAbsolutePath(), childName); if (t.exists()) { String bcroot = FolderConfig.getCanonicalRoot(); + String fsPath = t.getAbsolutePath(); if (t.isDirectory()) { + VFSContainer subContainer; if (fsPath.startsWith(bcroot)) { fsPath = fsPath.replace(bcroot,""); - return new OlatRootFolderImpl(fsPath, rootContainer); + subContainer = new OlatRootFolderImpl(fsPath, rootContainer); } else { - return new LocalFolderImpl (t, rootContainer); + subContainer = new LocalFolderImpl (t, rootContainer); } + String subPath = path.substring(childName.length() + 1); + return resolveFile(subContainer, subPath); } else { if (fsPath.startsWith(bcroot)) { fsPath = fsPath.replace(bcroot,""); @@ -156,7 +160,7 @@ public class VFSManager extends BasicManager { } //leave original code block as fall-back for non-file-system-based implementations - String childName = VFSManager.extractChild(path); + String childName = extractChild(path); List<VFSItem> children = rootContainer.getItems(); for (VFSItem child : children) { String curName = child.getName(); @@ -190,6 +194,7 @@ public class VFSManager extends BasicManager { * @return */ public static VFSContainer findInheritingSecurityCallbackContainer(VFSItem vfsItem) { + if (vfsItem == null) return null; // first resolve delegates of any NamedContainers to get the actual container (might be a MergeSource) if (vfsItem instanceof NamedContainerImpl) return findInheritingSecurityCallbackContainer(((NamedContainerImpl)vfsItem).delegate); // special treatment for MergeSource -- GitLab