X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2Ffs%2FFsContentProvider.java;h=62b20af3df7570df6380a06671dedcc14e26a717;hb=dcdbf77c4ec46f1dcad5d3fa011fe072e921f187;hp=e17384b942162d7cefbde3fde1fdb0682ad3674f;hpb=cc1dd97ebcc32e1bd754073ad23def182f460452;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 e17384b94..62b20af3d 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 @@ -9,10 +9,10 @@ import java.nio.file.attribute.UserDefinedFileAttributeView; import java.util.Iterator; import java.util.Map; import java.util.NavigableMap; +import java.util.Objects; import java.util.TreeMap; import java.util.stream.Collectors; -import org.argeo.api.acr.Content; import org.argeo.api.acr.ContentResourceException; import org.argeo.api.acr.CrName; import org.argeo.api.acr.NamespaceUtils; @@ -26,21 +26,34 @@ public class FsContentProvider implements ContentProvider { private final String mountPath; private final Path rootPath; - private final boolean isRoot; +// private final boolean isRoot; private NavigableMap prefixes = new TreeMap<>(); - public FsContentProvider(String mountPath, Path rootPath, boolean isRoot) { + public FsContentProvider(String mountPath, Path rootPath) { + Objects.requireNonNull(mountPath); + Objects.requireNonNull(rootPath); + this.mountPath = mountPath; this.rootPath = rootPath; - this.isRoot = isRoot; + // FIXME make it more robust initNamespaces(); } - protected void initNamespaces() { +// @Deprecated +// public FsContentProvider(String mountPath, Path rootPath, boolean isRoot) { +// this.mountPath = mountPath; +// this.rootPath = rootPath; +//// this.isRoot = isRoot; +//// initNamespaces(); +// } + + private void initNamespaces() { try { UserDefinedFileAttributeView udfav = Files.getFileAttributeView(rootPath, UserDefinedFileAttributeView.class); + if (udfav == null) + return; for (String name : udfav.list()) { if (name.startsWith(XMLNS_)) { ByteBuffer buf = ByteBuffer.allocate(udfav.size(name)); @@ -84,16 +97,15 @@ public class FsContentProvider implements ContentProvider { } } - - -@Override + + @Override public String getMountPath() { return mountPath; } - boolean isRoot(Path path) { + boolean isMountRoot(Path path) { try { - return isRoot && Files.isSameFile(rootPath, path); + return Files.isSameFile(rootPath, path); } catch (IOException e) { throw new ContentResourceException(e); }