You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2022/05/10 10:37:45 UTC

[GitHub] [sling-org-apache-sling-jcr-resource] joerghoh commented on a diff in pull request #23: SLING-10011 : Use JackrabbitSession.getParentOrNull when resolving parent JCR node in JcrResourceProvider#getParent

joerghoh commented on code in PR #23:
URL: https://github.com/apache/sling-org-apache-sling-jcr-resource/pull/23#discussion_r869084037


##########
src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrItemResourceFactory.java:
##########
@@ -197,4 +201,21 @@ else if (session.itemExists(path)) {
         return item;
     }
 
+    @Nullable Node getParentOrNull(@NotNull Item child, @NotNull String parentPath) {
+        Node parent = null;
+        try {
+            // Use fast getParentOrNull if session is a JackrabbitSession
+            if (this.isJackrabbit) {
+                parent = ((JackrabbitSession) session).getParentOrNull(child);
+            } else if (session.nodeExists(parentPath)) {
+                // Fallback to slower nodeExists & getNode pattern
+                parent = session.getNode(parentPath);
+            }
+        } catch (RepositoryException e) {
+            log.debug("Unable to access node at " + parentPath + ", possibly invalid path", e);

Review Comment:
   could this also be because of access control? Would it make sense to mention it as well?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org