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 11:34:24 UTC

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

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


##########
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:
   most likely it is due to lack of permission.... it's the original message and i didn't alter that one. i would leave out any confusing attempt to explain what could potentially be wrong.... but that's my take.



-- 
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