]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ProvidedContent.java
e2807c0efd19e746c7a9ab41a2971e36c1fe55e9
[lgpl/argeo-commons.git] / ProvidedContent.java
1 package org.argeo.api.acr.spi;
2
3 import org.argeo.api.acr.Content;
4
5 /** A {@link Content} implementation. */
6 public interface ProvidedContent extends Content {
7 final static String ROOT_PATH = "/";
8
9 ProvidedSession getSession();
10
11 ContentProvider getProvider();
12
13 int getDepth();
14
15 /**
16 * An opaque ID which is guaranteed to uniquely identify this content within the
17 * session return by {@link #getSession()}. Typically used for UI.
18 */
19 String getSessionLocalId();
20
21 default ProvidedContent getMountPoint(String relativePath) {
22 throw new UnsupportedOperationException("This content doe not support mount");
23 }
24
25 default ProvidedContent getContent(String path) {
26 Content fileNode;
27 if (path.startsWith(ROOT_PATH)) {// absolute
28 fileNode = getSession().get(path);
29 } else {// relative
30 String absolutePath = getPath() + '/' + path;
31 fileNode = getSession().get(absolutePath);
32 }
33 return (ProvidedContent) fileNode;
34 }
35 }