Improve ACR
[lgpl/argeo-commons.git] / org.argeo.api.acr / src / org / argeo / api / acr / spi / ProvidedContent.java
index d9f378329f59a3d8932910cf2328df97f4d27796..e2807c0efd19e746c7a9ab41a2971e36c1fe55e9 100644 (file)
@@ -4,6 +4,8 @@ import org.argeo.api.acr.Content;
 
 /** A {@link Content} implementation. */
 public interface ProvidedContent extends Content {
+       final static String ROOT_PATH = "/";
+
        ProvidedSession getSession();
 
        ContentProvider getProvider();
@@ -19,4 +21,15 @@ public interface ProvidedContent extends Content {
        default ProvidedContent getMountPoint(String relativePath) {
                throw new UnsupportedOperationException("This content doe not support mount");
        }
+
+       default ProvidedContent getContent(String path) {
+               Content fileNode;
+               if (path.startsWith(ROOT_PATH)) {// absolute
+                       fileNode = getSession().get(path);
+               } else {// relative
+                       String absolutePath = getPath() + '/' + path;
+                       fileNode = getSession().get(absolutePath);
+               }
+               return (ProvidedContent) fileNode;
+       }
 }