Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 10171 invoked from network); 5 May 2008 13:42:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 May 2008 13:42:47 -0000 Received: (qmail 14319 invoked by uid 500); 5 May 2008 13:42:49 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 14278 invoked by uid 500); 5 May 2008 13:42:49 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 14269 invoked by uid 99); 5 May 2008 13:42:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2008 06:42:49 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 May 2008 13:42:03 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2956E238898E; Mon, 5 May 2008 06:42:24 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r653479 - in /incubator/sling/trunk/sling/servlet-resolver/src: main/java/org/apache/sling/servlet/resolver/helper/ test/java/org/apache/sling/servlet/resolver/helper/ Date: Mon, 05 May 2008 13:42:23 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080505134224.2956E238898E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Mon May 5 06:42:23 2008 New Revision: 653479 URL: http://svn.apache.org/viewvc?rev=653479&view=rev Log: SLING-387 Fix last resort to only accept servlets and not any script and modify test for POST method to not expected selector consideration Modified: incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java Modified: incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java?rev=653479&r1=653478&r2=653479&view=diff ============================================================================== --- incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java (original) +++ incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/LocationUtil.java Mon May 5 06:42:23 2008 @@ -30,6 +30,7 @@ import org.apache.sling.api.resource.ResourceUtil; import org.apache.sling.api.resource.SyntheticResource; import org.apache.sling.api.servlets.HttpConstants; +import org.apache.sling.servlet.resolver.resource.ServletResourceProvider; public class LocationUtil { @@ -91,26 +92,17 @@ ordinal++; } } - + // special treatment for servlets registered with neither a method // name nor extensions and selectors - String path = location.getPath(); - String label = ResourceUtil.getName(path); - location = getResource(null, ResourceUtil.getParent(path)); - children = getResolver().listChildren(location); - while (children.hasNext()) { - Resource child = children.next(); - - String name = ResourceUtil.getName(child.getPath()); - String[] parts = name.split("\\."); - - // require base name plus script extension - if (parts.length == 2 && label.equals(parts[0])) { - LocationResource lr = new LocationResource(ordinal, child, 0, - LocationResource.WEIGHT_LAST_RESSORT); - resources.add(lr); - ordinal++; - } + String path = location.getPath() + + ServletResourceProvider.SERVLET_PATH_EXTENSION; + location = getResolver().getResource(path); + if (location != null) { + LocationResource lr = new LocationResource(ordinal, location, 0, + LocationResource.WEIGHT_LAST_RESSORT); + resources.add(lr); + ordinal++; } return ordinal; Modified: incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java?rev=653479&r1=653478&r2=653479&view=diff ============================================================================== --- incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java (original) +++ incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/LocationUtilGetServletsTest.java Mon May 5 06:42:23 2008 @@ -108,6 +108,26 @@ effectiveTest(names, baseIdxs, indices); } + public void testGetServlets4() { + String[] names = { ".servlet", // 0 + "/" + label + ".esp", // 1 + "/GET.esp", // 2 + "/" + label + ".html.esp", // 3 + "/html.esp", // 4 + ".esp", // 5 + "/image.esp", // 6 + "/print/other.esp", // 7 + "/print.other.esp", // 8 + "/print.html.esp", // 9 + "/print/a4.html.esp", // 10 + }; + + int[] baseIdxs = { 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; + int[] indices = { 10, 9, 3, 4, 1, 2, 0 }; + + effectiveTest(names, baseIdxs, indices); + } + protected void effectiveTest(String[] names, int[] baseIdxs, int[] indices) { String[] base = { "/apps/" + resourceTypePath, Modified: incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java?rev=653479&r1=653478&r2=653479&view=diff ============================================================================== --- incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java (original) +++ incubator/sling/trunk/sling/servlet-resolver/src/test/java/org/apache/sling/servlet/resolver/helper/ScriptSelectionTest.java Mon May 5 06:42:23 2008 @@ -149,9 +149,7 @@ assertScript("POST", null, "html", scripts, null); } - /** CURRENTLY FAILS, SLING-387 public void testHtmlPostSelectors() { - assertScript("POST", "print.a4", "html", SET_A, "/apps/foo/bar/print/POST.esp"); + assertScript("POST", "print.a4", "html", SET_A, "/apps/foo/bar/POST.esp"); } - */ }