X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2FMountManager.java;h=90d621b761e57359ac14b02d2aeed2de47526146;hb=8eca27d220993fd99f954f382c2ad9a7435e3682;hp=75ca427c7e25bdee4d96e7bbd768c65c959b3e90;hpb=6d463a65d04d641c94a493579a75f8015c82097d;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/acr/MountManager.java b/org.argeo.cms/src/org/argeo/cms/acr/MountManager.java index 75ca427c7..90d621b76 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/MountManager.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/MountManager.java @@ -51,10 +51,10 @@ class MountManager { synchronized ContentProvider findContentProvider(String path) { // if (ContentUtils.EMPTY.equals(path)) // return partitions.firstEntry().getValue(); - Map.Entry entry = partitions.floorEntry(path); - if (entry == null) - throw new IllegalArgumentException("No entry provider found for path '" + path + "'"); - String mountPath = entry.getKey(); + Map.Entry floorEntry = partitions.floorEntry(path); + if (floorEntry == null) + throw new IllegalArgumentException("No floor entry provider found for path '" + path + "'"); + String mountPath = floorEntry.getKey(); if (!path.startsWith(mountPath)) { // FIXME make it more robust and find when there is no content provider String[] parent = ContentUtils.getParentPath(path); @@ -62,15 +62,22 @@ class MountManager { // throw new IllegalArgumentException("Path " + path + " doesn't have a content // provider"); } - ContentProvider contentProvider = entry.getValue(); + ContentProvider contentProvider = floorEntry.getValue(); assert mountPath.equals(contentProvider.getMountPath()); return contentProvider; } - /** All content provider under this path. */ + /** All content providers under this path. */ synchronized NavigableMap findContentProviders(String path) { + Map.Entry floorEntry = partitions.floorEntry(path); + if (floorEntry == null) + throw new IllegalArgumentException("No floor entry provider found for path '" + path + "'"); + // we first find the parent provider + String parentProviderPath = floorEntry.getKey(); + // then gather all sub-providers NavigableMap res = new TreeMap<>(); - tail: for (Map.Entry provider : partitions.tailMap(path).entrySet()) { + res.put(floorEntry.getKey(), floorEntry.getValue()); + tail: for (Map.Entry provider : partitions.tailMap(parentProviderPath).entrySet()) { if (!provider.getKey().startsWith(path)) break tail; res.put(provider.getKey(), provider.getValue());