You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ra...@apache.org on 2022/06/21 09:04:22 UTC

[sling-org-apache-sling-scripting-sightly] branch issues/SLING-11373 created (now 2adb775)

This is an automated email from the ASF dual-hosted git repository.

radu pushed a change to branch issues/SLING-11373
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly.git


      at 2adb775  SLING-11373 - The MergingServletResourceProvider does not wrap resources correctly

This branch includes the following new commits:

     new 2adb775  SLING-11373 - The MergingServletResourceProvider does not wrap resources correctly

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[sling-org-apache-sling-scripting-sightly] 01/01: SLING-11373 - The MergingServletResourceProvider does not wrap resources correctly

Posted by ra...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

radu pushed a commit to branch issues/SLING-11373
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly.git

commit 2adb7758a963c488a4771300d0e8bc28640115e3
Author: Radu Cotescu <ra...@apache.org>
AuthorDate: Mon Jun 20 17:40:29 2022 +0200

    SLING-11373 - The MergingServletResourceProvider does not wrap resources correctly
    
    * switched from resolve to getResource
---
 .../sling/scripting/sightly/engine/ResourceResolution.java     | 10 +++-------
 .../apache/sling/scripting/sightly/impl/utils/ScriptUtils.java | 10 +++-------
 2 files changed, 6 insertions(+), 14 deletions(-)

diff --git a/src/main/java/org/apache/sling/scripting/sightly/engine/ResourceResolution.java b/src/main/java/org/apache/sling/scripting/sightly/engine/ResourceResolution.java
index 41f359c..a34fdcb 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/engine/ResourceResolution.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/engine/ResourceResolution.java
@@ -183,15 +183,11 @@ public final class ResourceResolution {
 
     private static Resource getScriptResource(@NotNull ResourceResolver resourceResolver, @NotNull String path) {
          if (path.startsWith("/")) {
-             Resource resource = resourceResolver.resolve(path);
-             if (ResourceUtil.isNonExistingResource(resource)) {
-                 return null;
-             }
-             return resource;
+             return resourceResolver.getResource(path);
          } else {
              for (String searchPath : resourceResolver.getSearchPath()) {
-                 Resource resource = resourceResolver.resolve(searchPath + path);
-                 if (!ResourceUtil.isNonExistingResource(resource)) {
+                 Resource resource = resourceResolver.getResource(searchPath + path);
+                 if (resource != null) {
                      return resource;
                  }
              }
diff --git a/src/main/java/org/apache/sling/scripting/sightly/impl/utils/ScriptUtils.java b/src/main/java/org/apache/sling/scripting/sightly/impl/utils/ScriptUtils.java
index 64ce4ff..d045624 100644
--- a/src/main/java/org/apache/sling/scripting/sightly/impl/utils/ScriptUtils.java
+++ b/src/main/java/org/apache/sling/scripting/sightly/impl/utils/ScriptUtils.java
@@ -46,17 +46,13 @@ public class ScriptUtils {
     private static Resource getResource(@NotNull ResourceResolver resolver, @NotNull Resource resource) {
         String path = resource.getPath();
         if (path.startsWith("/")) {
-            Resource resolved = resolver.resolve(path);
-            if (ResourceUtil.isNonExistingResource(resolved)) {
-                return null;
-            }
-            return resolved;
+            return resolver.getResource(path);
         } else {
             for (String sp : resolver.getSearchPath()) {
                 String absolutePath = ResourceUtil.normalize(sp + path);
                 if (absolutePath != null) {
-                    Resource resolved = resolver.resolve(absolutePath);
-                    if (!ResourceUtil.isNonExistingResource(resolved)) {
+                    Resource resolved = resolver.getResource(absolutePath);
+                    if (resolved != null) {
                         return resolved;
                     }
                 }