Hi Alexander,
Alexander Klimetschek schrieb:
On Tue, Mar 17, 2009 at 4:24 PM, Andreas Hartmann <[email protected]> wrote:
I'd like to provide a JSON-based service for a subtree of my repository. My
first idea would be to register a servlet like this:
@scr.property name="sling.servlet.paths"
value1="/path/to/my/content/root"
value2="/path/to/my/content/root/**"
But I guess wildcards are not supported in paths.
No. But I would also not recommend to use servlet paths, as there is
no easy way to find out what is rendered by what if you have too many
of them.
Is there a straightforward way to achieve this? Unfortunately request
selectors or extensions don't seem to work, because it is not possible to
use URIs like
(A) /path/to/my/content/root.tree.json
(B) /path/to/my/content/root.tree.json/foo.node.json
When the (B) is requested, the same response as for (A) is returned (I guess
there is some top-down matching algorithm). Apart from that, the URIs don't
look very nice.
Selectors and extensions are applied only for the "current" node, not
in combination with its parent. That would be too complicated. In case
(B), what happens is that sling tries to find the longest-matching
path with an existing resource, which is /path/to/my/content/root
(because there is a jcr node at this location). Everything after that
will be split up into selectors (dots as separators), extension (last
dot-separated part) and suffix (after an additional slash). In (B) it
would be (afaik):
resource = /path/to/my/content/root
selectors = [tree]
extension = [json]
suffix = /foo.node.json
thanks a lot for clarifying!
To solve your problem, I would rather try to set a resource type for
all nodes in the resource tree and register a servlet for the json
extension, that resource type (and maybe a selector, if desired).
Yes, I was afraid that this would be the only option at the moment. I
implemented this option. Thanks again for your answer!
-- Andreas
--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01