]> 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 /** The related {@link ProvidedSession}. */
10 ProvidedSession getSession();
11
12 /** The {@link ContentProvider} this {@link Content} belongs to. */
13 ContentProvider getProvider();
14
15 /** Depth relative to the root of the repository. */
16 int getDepth();
17
18 /**
19 * Whether this is the root node of the related repository. Default checks
20 * whether <code>{@link #getDepth()} == 0</code>, but it can be optimised by
21 * implementations.
22 */
23 default boolean isRoot() {
24 return getDepth() == 0;
25 }
26
27 /**
28 * An opaque ID which is guaranteed to uniquely identify this content within the
29 * session return by {@link #getSession()}. Typically used for UI.
30 */
31 String getSessionLocalId();
32
33 /**
34 * The {@link Content} within the same {@link ContentProvider} which can be used
35 * to mount another {@link ContentProvider}.
36 */
37 default ProvidedContent getMountPoint(String relativePath) {
38 throw new UnsupportedOperationException("This content doe not support mount");
39 }
40
41 @Override
42 default ProvidedContent getContent(String path) {
43 Content fileNode;
44 if (path.startsWith(ROOT_PATH)) {// absolute
45 fileNode = getSession().get(path);
46 } else {// relative
47 String absolutePath = getPath() + '/' + path;
48 fileNode = getSession().get(absolutePath);
49 }
50 return (ProvidedContent) fileNode;
51 }
52
53 /*
54 * ACCESS
55 */
56 /** Whether the session has the right to access the parent. */
57 default boolean isParentAccessible() {
58 return true;
59 }
60
61 /** Whether the related session can open this content for edit. */
62 default boolean canEdit() {
63 return false;
64 }
65 }