X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2FMountManager.java;h=90d621b761e57359ac14b02d2aeed2de47526146;hb=55d88fba80cec198a0f11ba7545e19878c51fc5e;hp=3995dc30fcc84c1f32a55f435d94f6cbb0dd280f;hpb=cc1dd97ebcc32e1bd754073ad23def182f460452;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 3995dc30f..90d621b76 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/MountManager.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/MountManager.java @@ -31,7 +31,7 @@ class MountManager { String[] parentPath = ContentUtils.getParentPath(mountPath); Content parent = systemSession.get(parentPath[0]); Content mount = parent.add(parentPath[1]); - mount.put(CrName.MOUNT.get(), "true"); + mount.put(CrName.mount.qName(), "true"); } @@ -47,13 +47,43 @@ class MountManager { return partitions.get(mountPath); } + /** The content provider for this path. */ synchronized ContentProvider findContentProvider(String path) { - Map.Entry entry = partitions.floorEntry(path); - if (entry == null) - throw new IllegalArgumentException("No entry provider found for " + path); - String mountPath = entry.getKey(); - ContentProvider contentProvider = entry.getValue(); +// if (ContentUtils.EMPTY.equals(path)) +// return partitions.firstEntry().getValue(); + 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); + return findContentProvider(parent[0]); + // throw new IllegalArgumentException("Path " + path + " doesn't have a content + // provider"); + } + ContentProvider contentProvider = floorEntry.getValue(); assert mountPath.equals(contentProvider.getMountPath()); return contentProvider; } + + /** 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<>(); + 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()); + } + return res; + + } + }