Extend ACR api.
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 17 Jun 2023 05:04:07 +0000 (07:04 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 17 Jun 2023 05:04:07 +0000 (07:04 +0200)
org.argeo.api.acr/src/org/argeo/api/acr/spi/ProvidedContent.java
org.argeo.cms/src/org/argeo/cms/acr/AbstractContent.java

index e2807c0efd19e746c7a9ab41a2971e36c1fe55e9..3cf130a7c456d35e22c5d74e961bc1c2acc0ffd1 100644 (file)
@@ -12,6 +12,15 @@ public interface ProvidedContent extends Content {
 
        int getDepth();
 
+       /**
+        * Whether this is the root node of the related repository. Default checks
+        * whether <code>{@link #getDepth()} == 0</code>, but it can be optimised by
+        * implementations.
+        */
+       default boolean isRoot() {
+               return getDepth() == 0;
+       }
+
        /**
         * An opaque ID which is guaranteed to uniquely identify this content within the
         * session return by {@link #getSession()}. Typically used for UI.
@@ -32,4 +41,13 @@ public interface ProvidedContent extends Content {
                }
                return (ProvidedContent) fileNode;
        }
+
+       /*
+        * ACCESS
+        */
+       /** Whether the session has the right to access the parent. */
+       default boolean isParentAccessible() {
+               return true;
+       }
+
 }
index 16f39609e8aafb1c9185dec0a274ef74431cdedf..c6e07e638b9b24b7bd0ebee667446b5de25b05ed 100644 (file)
@@ -120,6 +120,11 @@ public abstract class AbstractContent extends AbstractMap<QName, Object> impleme
                return ancestors.size();
        }
 
+       @Override
+       public boolean isRoot() {
+               return CrName.root.qName().equals(getName());
+       }
+
        @Override
        public String getSessionLocalId() {
                return getPath();