]> git.argeo.org Git - lgpl/argeo-commons.git/blob - api/acr/spi/ProvidedContent.java
Prepare next development cycle
[lgpl/argeo-commons.git] / api / acr / spi / 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 * Whether this is the root node of the related repository. Default checks
17 * whether <code>{@link #getDepth()} == 0</code>, but it can be optimised by
18 * implementations.
19 */
20 default boolean isRoot() {
21 return getDepth() == 0;
22 }
23
24 /**
25 * An opaque ID which is guaranteed to uniquely identify this content within the
26 * session return by {@link #getSession()}. Typically used for UI.
27 */
28 String getSessionLocalId();
29
30 default ProvidedContent getMountPoint(String relativePath) {
31 throw new UnsupportedOperationException("This content doe not support mount");
32 }
33
34 default ProvidedContent getContent(String path) {
35 Content fileNode;
36 if (path.startsWith(ROOT_PATH)) {// absolute
37 fileNode = getSession().get(path);
38 } else {// relative
39 String absolutePath = getPath() + '/' + path;
40 fileNode = getSession().get(absolutePath);
41 }
42 return (ProvidedContent) fileNode;
43 }
44
45 /*
46 * ACCESS
47 */
48 /** Whether the session has the right to access the parent. */
49 default boolean isParentAccessible() {
50 return true;
51 }
52
53 }