Hi Bertrand,
These tests don't demonstrate my problem. I think a variation of
testPathExtAndSuffix() would:
public void testPathAndSuffixOnly() {
RequestPathInfo p = new SlingRequestPathInfo(new MockResource(
"/some/path/here", "/some/suffix"));
assertEquals("/some/path/here", p.getResourcePath());
assertNull("Selectors are null",p.getSelectorString());
assertEquals(0, p.getSelectors().length);
assertEquals("Extension is null", p.getExtension());
assertEquals("/some/suffix", p.getSuffix());
}
Where /some/path/here is a resolvable resource, but both
/some/path/here/some and /some/path/here/some/suffix are non-existent.
Best,
Branden
Bertrand Delacretaz wrote:
Hi Branden,
2009/8/24 <[email protected]>:
...it contradicts the documentation under "URL Decomposition" at
http://sling.apache.org/site/sling-api.html, and even worse, makes my program
less elegant! :) In the Sling API, the resource is said to not need an extension
to register as the located resource....
Could you have a look at the tests in [1], and see if they demonstrate
your problem?
If not I'd like to enhance them to clarify this.
-Bertrand
[1]
http://svn.apache.org/repos/asf/sling/trunk/bundles/engine/src/test/java/org/apache/sling/engine/impl/request/SlingRequestPathInfoTest.java
(just added a link to that class to sling-api.html BTW)
Is this by design, or is this a bug?
Thanks,
------------------------------------------
Branden Visser
LMS Application Programmer - Information Systems Services
Information Technology Services
University of Windsor
-----Dominik Süß <[email protected]> wrote: -----
To: [email protected], [email protected]
From: Dominik Süß <[email protected]>
Date: 08/24/2009 02:54PM
Subject: Re: Script Resolution to non-existing resource
Hi Branden,
it might help you to have a look at:
http://dev.day.com/microsling/content/blogs/main/cheatsheet.html
There you can see how URLs are composed/decomposed. For your case
/content/portal/users/admin/pages/home/widgets/hello_world.html/widget.html
might do the trick ;)
HTH
Best regards,
Dominik
On Mon, Aug 24, 2009 at 8:46 PM, Branden Visser <[email protected]> wrote:
Hi all,
I'm trying to access a resource, then append a suffix to the URI. The problem
is that the GET servlet seems to be taking my full URI, and returning a 404,
even though there is a valid resource found in a substring of the URL. Here is
what I have:
URI: /content/portal/users/admin/pages/home/widgets/hello_world/widget.html
The idea is that /widget.html is the suffix (there is no 'widget' resource!),
and therefore Sling will attempt to execute hello_world.
hello_world has sling:resourceType="portal/widgets/url/url", and the following
file exists: /apps/portal/widgets/url/url/GET.esp.
However, when I hit the URI above, I get 404. My intention is to make GET.esp create the
resource "widget" below hello_world automatically if it does not exist.
From what I understand from the URL decomposition and resource resolution [1],
since /widget does not exist, hello_world should be the mapped resource, while
/widget.html is the suffix. Correct?
Here is my request breakdown:
0 (2009-08-24 14:33:17) Starting Request Processing
0 (2009-08-24 14:33:17) Method=GET,
PathInfo=/content/portal/users/admin/pages/home/widgets/hello_world/widget.html
0 (2009-08-24 14:33:17) Starting ResourceResolution
9 (2009-08-24 14:33:17)
URI=/content/portal/users/admin/pages/home/widgets/hello_world/widget.html
resolves to Resource=NonExistingResource,
path=/content/portal/users/admin/pages/home/widgets/hello_world/widget.html,
elapsed = 9ms
9 (2009-08-24 14:33:17) Resource Path Info: SlingRequestPathInfo:
path='/content/portal/users/admin/pages/home/widgets/hello_world/widget.html',
selectorString='null', extension='null', suffix='null'
9 (2009-08-24 14:33:17) Starting ServletResolution
9 (2009-08-24 14:33:17) Starting resolveServlet(NonExistingResource,
path=/content/portal/users/admin/pages/home/widgets/hello_world/widget.html)
9 (2009-08-24 14:33:17) Using servlet
org.apache.sling.servlets.get.DefaultGetServlet, elapsed = 0ms
9 (2009-08-24 14:33:17)
URI=/content/portal/users/admin/pages/home/widgets/hello_world/widget.html
handled by Servlet=org.apache.sling.servlets.get.DefaultGetServlet, elapsed =
0ms
9 (2009-08-24 14:33:17) Applying request filters
9 (2009-08-24 14:33:17) Calling filter:
org.apache.sling.engine.impl.debug.RequestProgressTrackerLogFilter
9 (2009-08-24 14:33:17) Starting
org.apache.sling.servlets.get.DefaultGetServlet#0
9 (2009-08-24 14:33:17) org.apache.sling.servlets.get.DefaultGetServlet#0,
elapsed = 0ms
10 (2009-08-24 14:33:17) Starting handleError:status=404
10 (2009-08-24 14:33:17) Using handler Sling Default Error Handler Servlet,
elapsed = 0ms
10 (2009-08-24 14:33:17) Error handler finished, elapsed = 0ms
It's clear that the GetServlet is using the full URI, and not attempting to
parse a suffix.
Any ideas?
Thanks,
Branden
[1] http://sling.apache.org/site/sling-api.html