Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 60103 invoked from network); 26 Aug 2008 07:00:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Aug 2008 07:00:35 -0000 Received: (qmail 43608 invoked by uid 500); 26 Aug 2008 07:00:34 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 43553 invoked by uid 500); 26 Aug 2008 07:00:33 -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 43544 invoked by uid 99); 26 Aug 2008 07:00:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 Aug 2008 00:00:33 -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; Tue, 26 Aug 2008 06:59:44 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B74A12388A5C; Tue, 26 Aug 2008 00:00:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r688976 - in /incubator/sling/trunk/engine: ./ src/main/java/org/apache/sling/engine/impl/request/ src/test/java/org/apache/sling/engine/impl/request/ Date: Tue, 26 Aug 2008 07:00:13 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080826070014.B74A12388A5C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: fmeschbe Date: Tue Aug 26 00:00:12 2008 New Revision: 688976 URL: http://svn.apache.org/viewvc?rev=688976&view=rev Log: SLING-627 Create SlingRequestPathInfo with the new sling.resolutionPathInfo property of the resource metadata instead of trying to cut off from the abs path. Modified: incubator/sling/trunk/engine/pom.xml incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/RequestData.java incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java incubator/sling/trunk/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java Modified: incubator/sling/trunk/engine/pom.xml URL: http://svn.apache.org/viewvc/incubator/sling/trunk/engine/pom.xml?rev=688976&r1=688975&r2=688976&view=diff ============================================================================== --- incubator/sling/trunk/engine/pom.xml (original) +++ incubator/sling/trunk/engine/pom.xml Tue Aug 26 00:00:12 2008 @@ -96,7 +96,7 @@ org.apache.sling org.apache.sling.api - 2.0.2-incubator + 2.0.3-incubator-SNAPSHOT org.apache.sling Modified: incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/RequestData.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/RequestData.java?rev=688976&r1=688975&r2=688976&view=diff ============================================================================== --- incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/RequestData.java (original) +++ incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/RequestData.java Tue Aug 26 00:00:12 2008 @@ -151,8 +151,7 @@ public void initServlet(final Resource resource) { // the resource and the request path info, will never be null - RequestPathInfo requestPathInfo = new SlingRequestPathInfo(resource, - getServletRequest().getPathInfo()); + RequestPathInfo requestPathInfo = new SlingRequestPathInfo(resource); ContentData contentData = pushContent(resource, requestPathInfo); requestProgressTracker.log("Resource Path Info: {0}", requestPathInfo); Modified: incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java?rev=688976&r1=688975&r2=688976&view=diff ============================================================================== --- incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java (original) +++ incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java Tue Aug 26 00:00:12 2008 @@ -103,7 +103,7 @@ } // ensure request path info and optional merges - SlingRequestPathInfo info = new SlingRequestPathInfo(resource, absPath); + SlingRequestPathInfo info = new SlingRequestPathInfo(resource); info = info.merge(cRequest.getRequestPathInfo()); // merge request dispatcher options and resource type overwrite Modified: incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java?rev=688976&r1=688975&r2=688976&view=diff ============================================================================== --- incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java (original) +++ incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestPathInfo.java Tue Aug 26 00:00:12 2008 @@ -46,24 +46,21 @@ private final static String[] NO_SELECTORS = new String[0]; /** break requestPath as required by SlingRequestPathInfo */ - public SlingRequestPathInfo(Resource r, String requestPath) { + public SlingRequestPathInfo(Resource r) { // ensure the resource if (r == null) { throw new NullPointerException("resource"); } - String pathToParse = requestPath; + resourcePath = r.getResourceMetadata().getResolutionPath(); + + // the extra path in the request URI + String pathToParse = r.getResourceMetadata().getResolutionPathInfo(); if (pathToParse == null) { pathToParse = ""; } - resourcePath = r.getResourceMetadata().getResolutionPath(); - if (resourcePath != null - && pathToParse.length() >= resourcePath.length()) { - pathToParse = pathToParse.substring(resourcePath.length()); - } - // separate selectors/ext from the suffix int firstSlash = pathToParse.indexOf('/'); String pathToSplit; Modified: incubator/sling/trunk/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java URL: http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java?rev=688976&r1=688975&r2=688976&view=diff ============================================================================== --- incubator/sling/trunk/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java (original) +++ incubator/sling/trunk/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java Tue Aug 26 00:00:12 2008 @@ -29,7 +29,7 @@ public void testNullResource() { try { - new SlingRequestPathInfo(null, "dontcare"); + new SlingRequestPathInfo(null); fail("Expected NullPointerException"); } catch (NullPointerException npe) { // required for a null resource @@ -37,8 +37,8 @@ } public void testTrailingDot() { - RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/some/path"), "/some/path."); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/some/path", ".")); assertEquals("/some/path", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -47,8 +47,8 @@ } public void testTrailingDotWithSuffix() { - RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/some/path"), "/some/path./suffix"); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/some/path", "./suffix")); assertEquals("/some/path", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -57,8 +57,8 @@ } public void testTrailingDotDot() { - RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/some/path"), "/some/path.."); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/some/path", "..")); assertEquals("/some/path", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -67,8 +67,8 @@ } public void testTrailingDotDotWithSuffix() { - RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/some/path"), "/some/path../suffix"); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/some/path", "../suffix")); assertEquals("/some/path", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -77,8 +77,8 @@ } public void testTrailingDotDotDot() { - RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/some/path"), "/some/path..."); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/some/path", "...")); assertEquals("/some/path", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -87,8 +87,8 @@ } public void testTrailingDotDotDotWithSuffix() { - RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/some/path"), "/some/path.../suffix"); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/some/path", ".../suffix")); assertEquals("/some/path", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -97,8 +97,8 @@ } public void testAllOptions() { - RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/some/path"), "/some/path.print.a4.html/some/suffix"); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/some/path", ".print.a4.html/some/suffix")); assertEquals("/some/path", p.getResourcePath()); assertEquals("print.a4", p.getSelectorString()); assertEquals(2, p.getSelectors().length); @@ -110,7 +110,7 @@ public void testAllEmpty() { RequestPathInfo p = new SlingRequestPathInfo( - new MockResource("/"), null); + new MockResource("/", null)); assertEquals("/", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -120,17 +120,17 @@ public void testPathOnly() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path/here"), "/some/path/here"); + "/some/path/here", "")); assertEquals("/some/path/here", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); assertNull(p.getExtension()); assertNull(p.getSuffix()); } - + public void testPathWithExtensionOnly() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path/here.html"), "/some/path/here.html"); + "/some/path/here.html", "")); assertEquals("/some/path/here.html", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -140,7 +140,7 @@ public void testPathAndExtensionOnly() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path/here"), "/some/path/here.html"); + "/some/path/here", ".html")); assertEquals("/some/path/here", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -150,7 +150,7 @@ public void testPathAndOneSelectorOnly() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path/here"), "/some/path/here.print.html"); + "/some/path/here", ".print.html")); assertEquals("/some/path/here", p.getResourcePath()); assertEquals("print", p.getSelectorString()); assertEquals(1, p.getSelectors().length); @@ -161,7 +161,7 @@ public void testPathExtAndSuffix() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path/here"), "/some/path/here.html/something"); + "/some/path/here", ".html/something")); assertEquals("/some/path/here", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -171,7 +171,7 @@ public void testSelectorsSplit() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path"), "/some/path.print.a4.html/some/suffix"); + "/some/path", ".print.a4.html/some/suffix")); assertEquals("/some/path", p.getResourcePath()); assertEquals(2, p.getSelectors().length); assertEquals("print", p.getSelectors()[0]); @@ -182,7 +182,7 @@ public void testPartialResolutionB() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path"), "/some/path.print.a4.html/some/suffix"); + "/some/path", ".print.a4.html/some/suffix")); assertEquals("/some/path", p.getResourcePath()); assertEquals("print.a4", p.getSelectorString()); assertEquals(2, p.getSelectors().length); @@ -194,7 +194,7 @@ public void testPartialResolutionC() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path.print"), "/some/path.print.a4.html/some/suffix"); + "/some/path.print", ".a4.html/some/suffix")); assertEquals("/some/path.print", p.getResourcePath()); assertEquals("a4", p.getSelectorString()); assertEquals(1, p.getSelectors().length); @@ -205,7 +205,7 @@ public void testPartialResolutionD() { RequestPathInfo p = new SlingRequestPathInfo(new MockResource( - "/some/path.print.a4"), "/some/path.print.a4.html/some/suffix"); + "/some/path.print.a4", ".html/some/suffix")); assertEquals("/some/path.print.a4", p.getResourcePath()); assertNull(p.getSelectorString()); assertEquals(0, p.getSelectors().length); @@ -214,59 +214,50 @@ } public void testJIRA_250_a() { - RequestPathInfo p = - new SlingRequestPathInfo( - new MockResource("/bunkai"), - "/bunkai.1.json" - ); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource( + "/bunkai", ".1.json")); assertEquals("/bunkai", p.getResourcePath()); assertEquals("json", p.getExtension()); assertEquals("1", p.getSelectorString()); } - + public void testJIRA_250_b() { - RequestPathInfo p = - new SlingRequestPathInfo( - new MockResource("/"), - "/.1.json" - ); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/", + ".1.json")); assertEquals("/", p.getResourcePath()); assertEquals("json", p.getExtension()); assertNull(p.getSuffix()); - assertEquals("Selector string must not be null", "1", p.getSelectorString()); + assertEquals("Selector string must not be null", "1", + p.getSelectorString()); } - + public void testJIRA_250_c() { - RequestPathInfo p = - new SlingRequestPathInfo( - new MockResource("/"), - "/.1.json/my/suffix" - ); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/", + ".1.json/my/suffix")); assertEquals("/", p.getResourcePath()); assertEquals("json", p.getExtension()); - assertEquals("/my/suffix",p.getSuffix()); - assertEquals("Selector string must not be null", "1", p.getSelectorString()); + assertEquals("/my/suffix", p.getSuffix()); + assertEquals("Selector string must not be null", "1", + p.getSelectorString()); } - + public void testJIRA_250_d() { - RequestPathInfo p = - new SlingRequestPathInfo( - new MockResource("/"), - "/.json" - ); + RequestPathInfo p = new SlingRequestPathInfo(new MockResource("/", + ".json")); assertEquals("/", p.getResourcePath()); assertEquals("json", p.getExtension()); assertNull(p.getSuffix()); assertNull(p.getSelectorString()); } - + static class MockResource implements Resource { private final ResourceMetadata metadata; - MockResource(String resolutionPath) { + MockResource(String resolutionPath, String resolutionPathInfo) { metadata = new ResourceMetadata(); metadata.setResolutionPath(resolutionPath); + metadata.setResolutionPathInfo(resolutionPathInfo); } public String getResourceType() { @@ -276,7 +267,7 @@ public String getResourceSuperType() { throw new Error("MockResource does not implement this method"); } - + public String getPath() { throw new Error("MockResource does not implement this method"); } @@ -288,7 +279,7 @@ public ResourceResolver getResourceResolver() { return null; } - + public Type adaptTo(Class type) { return null; }