Extend ACR API.
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 17 Jun 2023 05:04:41 +0000 (07:04 +0200)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 17 Jun 2023 05:04:41 +0000 (07:04 +0200)
org.argeo.cms.jcr/src/org/argeo/cms/jcr/acr/JcrContent.java

index 612eea89123e785a746ef6358951701a11b0691d..68eaf3e50cd38d862d71e0d59e8aac68ca71e4ce 100644 (file)
@@ -21,6 +21,7 @@ import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.PropertyType;
 import javax.jcr.RepositoryException;
+import javax.jcr.Session;
 import javax.jcr.Value;
 import javax.jcr.nodetype.NodeType;
 import javax.xml.namespace.QName;
@@ -242,6 +243,9 @@ public class JcrContent extends AbstractContent {
 
        }
 
+       /*
+        * ACCESS
+        */
        boolean exists() {
                try {
                        return provider.getJcrSession(getSession(), jcrWorkspace).itemExists(jcrPath);
@@ -250,6 +254,16 @@ public class JcrContent extends AbstractContent {
                }
        }
 
+       @Override
+       public boolean isParentAccessible() {
+               String jcrParentPath = ContentUtils.getParentPath(jcrPath)[0];
+               try {
+                       return provider.getJcrSession(getSession(), jcrWorkspace).hasPermission(jcrParentPath, Session.ACTION_READ);
+               } catch (RepositoryException e) {
+                       throw new JcrException("Cannot check whether parent " + jcrParentPath + " is accessible", e);
+               }
+       }
+
        /*
         * ADAPTERS
         */
@@ -367,7 +381,7 @@ public class JcrContent extends AbstractContent {
        private QName nodeTypeToQName(NodeType nodeType) {
                String name = nodeType.getName();
                return NamespaceUtils.parsePrefixedName(provider, name);
-               //return QName.valueOf(name);
+               // return QName.valueOf(name);
        }
 
        @Override