Hi,

Alexander Klimetschek schrieb:
> Hi all,
> 
> when working on "Import" servlets I stumbled upon the problem that
> servlets registered under selectors don't get called for non-existing
> resources.
> 
> The use case is that you POST or PUT a file to a certain path, eg.
> /content/foo/i18n, which does not exist yet, and there should be a
> servlet handling the import and create a custom jcr node structure
> from the file contents (eg. an i18n dictionary in the example).
> 
> Now in current Sling, if you register the servlet for the
> "sling/servlet/default" resource type and make it handle a special
> selector (say "i18n"), it won't get triggered if the path does not
> exist, but rather the standard sling POST servlet is triggered and
> creates unwanted nodes/properties depending of the request's contents.
> It would be cool to get the NonExistingResource in the servlet and
> have the servlet create the path itself.

Well, the mention of the NonExistingResource may be the key in your use
case: Since NonExistingResources have their own resource type
(sling:nonexisting IIRC), you may register a servlet for that resource
type and act upon it as desired. If you don't want to handle the
concrete request for any one reason, you can -- as a servlet --
implement the OptingServlet interface and return false on the respective
method.

It is a bit hacky, but it should work -- the problem is, that it is
limited to your special use case.

> 
> Did I miss something or is this really not possible at the moment? And
> if not, would it make sense to change the servlet resolution for that
> case?

I am not a big fan of extending or changing the servlet resolution just
for this.

What we might do is provide some plugin functionality based on the
sling:nonexisting resource type, where one might register its interest
in handling requests to such resources.


Regards
Felix

Reply via email to