X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2Ffs%2FFsContentProvider.java;h=1b5741431145663d55e871141c0191287fa4a1ce;hb=00fec502abb8eeccb813fe33d5e9ba53436b44d6;hp=62b20af3df7570df6380a06671dedcc14e26a717;hpb=dcdbf77c4ec46f1dcad5d3fa011fe072e921f187;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 62b20af3d..1b5741431 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 @@ -24,31 +24,26 @@ 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; + protected String mountPath; + protected Path rootPath; private NavigableMap prefixes = new TreeMap<>(); public FsContentProvider(String mountPath, Path rootPath) { Objects.requireNonNull(mountPath); Objects.requireNonNull(rootPath); - + this.mountPath = mountPath; this.rootPath = rootPath; // FIXME make it more robust initNamespaces(); } -// @Deprecated -// public FsContentProvider(String mountPath, Path rootPath, boolean isRoot) { -// this.mountPath = mountPath; -// this.rootPath = rootPath; -//// this.isRoot = isRoot; -//// initNamespaces(); -// } + protected FsContentProvider() { + + } - private void initNamespaces() { + protected void initNamespaces() { try { UserDefinedFileAttributeView udfav = Files.getFileAttributeView(rootPath, UserDefinedFileAttributeView.class); @@ -103,7 +98,7 @@ public class FsContentProvider implements ContentProvider { return mountPath; } - boolean isMountRoot(Path path) { + boolean isMountBase(Path path) { try { return Files.isSameFile(rootPath, path); } catch (IOException e) { @@ -112,7 +107,7 @@ public class FsContentProvider implements ContentProvider { } @Override - public ProvidedContent get(ProvidedSession session, String mountPath, String relativePath) { + public ProvidedContent get(ProvidedSession session, String relativePath) { return new FsContent(session, this, rootPath.resolve(relativePath)); } @@ -120,6 +115,11 @@ public class FsContentProvider implements ContentProvider { * NAMESPACE CONTEXT */ + @Override + public boolean exists(ProvidedSession session, String relativePath) { + return Files.exists(rootPath.resolve(relativePath)); + } + @Override public String getNamespaceURI(String prefix) { return NamespaceUtils.getNamespaceURI((p) -> prefixes.get(p), prefix);