X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2Ffs%2FFsContentProvider.java;h=3445733e18a13ff1727c20fb139ed82c9ba49c5f;hb=e3db2eba9a7f8380a6f76d7b0e6cd4825e91893e;hp=65bdd343ef72b213289e982008f917940877c8c2;hpb=c615307d7b87bcb260d8a9f402c6e0a880862f38;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContentProvider.java b/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContentProvider.java index 65bdd343e..3445733e1 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContentProvider.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/fs/FsContentProvider.java @@ -23,12 +23,14 @@ import org.argeo.api.acr.spi.ProvidedSession; public class FsContentProvider implements ContentProvider { final static String XMLNS_ = "xmlns:"; + private final String mountPath; private final Path rootPath; private final boolean isRoot; private NavigableMap prefixes = new TreeMap<>(); - public FsContentProvider(Path rootPath, boolean isRoot) { + public FsContentProvider(String mountPath, Path rootPath, boolean isRoot) { + this.mountPath = mountPath; this.rootPath = rootPath; this.isRoot = isRoot; initNamespaces(); @@ -64,11 +66,30 @@ public class FsContentProvider implements ContentProvider { throws IOException { if (!prefixes.containsKey(prefix)) { ByteBuffer bb = ByteBuffer.wrap(namespace.getBytes(StandardCharsets.UTF_8)); - int size = udfav.write(XMLNS_ + prefix, bb); + udfav.write(XMLNS_ + prefix, bb); prefixes.put(prefix, namespace); } } + public void registerPrefix(String prefix, String namespace) { + if (prefixes.containsKey(prefix)) + prefixes.remove(prefix); + try { + UserDefinedFileAttributeView udfav = Files.getFileAttributeView(rootPath, + UserDefinedFileAttributeView.class); + addDefaultNamespace(udfav, prefix, namespace); + } catch (IOException e) { + throw new RuntimeException("Cannot register namespace " + prefix + " " + namespace + " on " + rootPath, e); + } + + } + + +@Override + public String getMountPath() { + return mountPath; + } + boolean isRoot(Path path) { try { return isRoot && Files.isSameFile(rootPath, path);