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/08/03 08:41:20 UTC

[sling-org-apache-sling-scripting-sightly] branch issue/SLING-11508 created (now c956002)

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

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


      at c956002  SLING-11508 - Make dependency resolution use ResourceResolver#getResource instead of ResourceResolver#resolve

This branch includes the following new commits:

     new c956002  SLING-11508 - Make dependency resolution use ResourceResolver#getResource instead of ResourceResolver#resolve

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-11508 - Make dependency resolution use ResourceResolver#getResource instead of ResourceResolver#resolve

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

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

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

    SLING-11508 - Make dependency resolution use ResourceResolver#getResource instead of ResourceResolver#resolve
    
    * 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;
                     }
                 }