regex for sling:amtch had to be:
http/[^/]+/imgs/(.+)/([^/]+)/r/([^/]+)$

JcrResourceResolver2.getMapPath("http", "localhost", 8080,
"/imgs/2010/10/14/190x190/r/img.jpg")
==>
http/localhost.8080/imgs/2010/10/14/190x190/r/img.jpg


So, this solved:
curl -F'sling:match=http/[^/]+/imgs/(.+)/([^/]+)/r/([^/]+)$'
-F'sling:internalRedirect=/content/images/$1/$3/jcr:content/thumbnails/$2'
-F'jcr:primaryType=sling:Mapping' http://admin:ad...@localhost
:8080/etc/map/any

On Thu, Oct 14, 2010 at 10:48 PM, sam lee <[email protected]> wrote:

> Oops, it's a typo.
> Request is to "r", too.
> I'll have to step through and see what's happening.
>
> This is the script I used on
> org.apache.sling.launchpad.app-5-incubator.jar:
>
> curl -F'jcr:primaryType=sling:Folder' http://admin:ad...@localhost
> :8080/etc/map
> curl -F'sling:match=http://[^/]+/imgs/(.+)/([^/]+)/r/([^/]+)$'
> -F'sling:internalRedirect=/content/images/$1/$3/jcr:content/thumbnails/$2'
> -F'jcr:primaryType=sling:Mapping' http://admin:ad...@localhost
> :8080/etc/map/any
> curl -F'jcr:primaryType=sling:Folder' http://admin:ad...@localhost
> :8080/content/images/2010/10/14
> curl -F'jcr:primaryType=nt:unstructured' http://admin:ad...@localhost
> :8080/content/images/2010/10/14/img.jpg
> curl -F'jcr:primaryType=nt:unstructured' http://admin:ad...@localhost
> :8080/content/images/2010/10/14/img.jpg/jcr:content
> curl -F'jcr:primaryType=sling:Folder' http://admin:ad...@localhost
> :8080/content/images/2010/10/14/img.jpg/jcr:content/thumbnails
> curl -T 190x190 http://admin:ad...@localhost
> :8080/content/images/2010/10/14/img.jpg/jcr:content/thumbnails/190x190
>
>
>
> After running the script, I can see
> http://localhost:8080/system/console/jcrresolver  has patterns that I
> need.
> But when I test it on the page (felix web console 3.1.2), I get
> NonExistingResource, path=/imgs/2010/10/14/190x190/r/img.jpg
>
> I'll have to step through this..
> Is there a way to attach debugger from eclipse?
> I started sling with:
> java -Xmx384M -Xdebug -Xnoagent -Djava.compiler=NONE
> -Xrunjdwp:transport=dt_socket,address=30303,server=y,suspend=n -jar
> org.apache.sling.launchpad.app-5-incubator.jar
>
> And on eclipse, I created a Debug Configuration that connects to
> localhost:30303 and Source Lookup Path includes
> org.apache.sling.launchpad.app-5-incubator-sources.jar
>
> But I get:
> Failed to connect to remote VM. Connection refused.
> Connection refused
>
>
>
>
>
> On Thu, Oct 14, 2010 at 7:46 PM, Justin Edelson 
> <[email protected]>wrote:
>
>> This might be a typo or the source of your problem, but you have this:
>>
>> > /imgs/a/b/c/640x480/r/img.jpg
>>
>> but are requesting
>>
>> > /imgs/a/b/c/640x480/of/img.jpg
>>
>> look at the second-to-last path segment. Is "r" in the first example
>> (and your regex) and "of" in the second example.
>>
>> Justin
>>
>> On Thu, Oct 14, 2010 at 5:43 PM, sam lee <[email protected]> wrote:
>> > Hey,
>> >
>> > I want http request:
>> > GET /imgs/a/b/c/640x480/r/img.jpg
>> >
>> > to be resolved to the JCR node:
>> > /content/images/a/b/c/img.jpg/jcr:content/thumbnails/640x480
>> >
>> > I looked at:
>> > http://sling.apache.org/site/mappings-for-resource-resolution.html
>> >
>> > And, my current /etc/map is:
>> > /etc/map/any (sling:Mapping)
>> > - sling:match = http://[^/]+/imgs/(.+)/([^/]+)/r/([^/]+)$
>> > - sling:internalRedirect =
>> /content/images/$1/$3/jcr:content/thumbnails/$2
>> >
>> > But, GET /imgs/a/b/c/640x480/of/img.jpg  gives me 404.
>> > Is there something I'm doing wrong?
>> >
>> > Am I approaching the problem properly?
>> > Using regex seems brittle.
>> >
>> > If I were to write a class that knows how to convert short path to
>> actual
>> > jcr path, what interface should the class implement? And, how can I
>> register
>> > it to sling's DefaultGetServlet?
>> >
>> > Thanks.
>> > Sam
>> >
>>
>
>

Reply via email to