This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.sightly.js.provider-1.0.2 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-js-provider.git
commit 0525c1e934b9962aea3653bf789abe120da542c0 Author: Radu Cotescu <[email protected]> AuthorDate: Thu Apr 9 15:01:41 2015 +0000 SLING-4578 - Incorrect Sightly JS Use-API script dependency resolution * script dependency resolution now also takes into account relative paths for sling:resourceSuperType git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/sightly/js-use-provider@1672383 13f79535-47bb-0310-9956-ffa450edef68 --- .../sling/scripting/sightly/js/impl/JsEnvironment.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java index d91b764..b2d096a 100644 --- a/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java +++ b/src/main/java/org/apache/sling/scripting/sightly/js/impl/JsEnvironment.java @@ -32,6 +32,7 @@ import javax.script.SimpleScriptContext; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.api.scripting.SlingBindings; import org.apache.sling.api.scripting.SlingScriptHelper; @@ -185,21 +186,18 @@ public class JsEnvironment { private boolean isResourceOverlay(Resource resourceA, Resource resourceB) { String resourceBSuperType = resourceB.getResourceSuperType(); if (StringUtils.isNotEmpty(resourceBSuperType)) { + ResourceResolver resolver = resourceA.getResourceResolver(); String parentResourceType = resourceA.getResourceType(); if ("nt:file".equals(parentResourceType)) { parentResourceType = ResourceUtil.getParent(resourceA.getPath()); } - if (resourceBSuperType.equals(parentResourceType)) { - return true; - } - Resource parentB = resourceB.getResourceResolver().getResource(resourceBSuperType); - resourceBSuperType = parentB.getResourceSuperType(); - while (!"/".equals(parentB.getPath()) && StringUtils.isNotEmpty(resourceBSuperType)) { - if (resourceBSuperType.equals(parentResourceType)) { + Resource parentB = resolver.getResource(resourceBSuperType); + while (parentB != null && !"/".equals(parentB.getPath()) && StringUtils.isNotEmpty(resourceBSuperType)) { + if (parentB.getPath().equals(parentResourceType)) { return true; } - parentB = parentB.getParent(); resourceBSuperType = parentB.getResourceSuperType(); + parentB = resolver.getResource(resourceBSuperType); } } return false; -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
