Hi,

On Fri, 2017-01-27 at 14:27 -0700, lancedolan wrote:
> Hi friends,
> 
> I've tried routing questions through stackoverflow to cut down my
> mails to
> this list. I'm losing lots of time on this one, though, and am stuck.
> 
> I need to create APIs which don't represent Sling Resources. Example:
> /services/images/123123123
> that image will exist somewhere else.
> 
> Bertrand suggests creating a ResourceProvider, as in the example here
> [1].
> However, that uses the spi package which is not in version 2.9.0 of
> org.apache.sling.api, and thus, not available to me in Sling 8.

You can always look at how that ResourceProvider was before moving to
the new ResourceProvider SPI [3],[4]
  
(snip)

> The result is that I get a 403 response. How do I control the
> authentication
> for resources that don't actually exist? The fact that I'm not
> getting 404
> means that my ResourceProvider is at least registering successfully. 

I would check exactly what is going on using the 'Recent Requests'
WebConsole page. IIRC ResourceProviders do not provide authentication
by default.


> Finally, I'd much prefer to use Jersey if possible... Anybody have
> success
> getting Jersey to work in Sling 8? I dumped a bunch of time into it
> and gave
> up after class not found errors for classes that should be found [2].

I would suggest that you stick with the ResourceProvider for now. Yes,
it might not be familiar like Jersey, but it fits in really nicely with
Sling. And BTW, JCR is exposed to Sling via a ResourceProvider, so you
can really get creative with these APIs :-)

Robert

> 
> The ultimate goal is just to provide a restful API in Sling 8 and the
> static-path-declaration of SlingSafeMethodsServlet just doesn't cut
> it.
> 
> Thanks a million guys...


[3]: https://github.com/apache/sling/blob/30cadbca86c46e1460e19d045ce7d
6f0d475a778/launchpad/test-
services/src/main/java/org/apache/sling/launchpad/testservices/resource
provider/PlanetsResourceProvider.java
[4]: https://github.com/apache/sling/blob/30cadbca86c46e1460e19d045ce7d
6f0d475a778/launchpad/test-
services/src/main/java/org/apache/sling/launchpad/testservices/resource
provider/PlanetResource.java

> 
> 
> 
> [1]
> https://github.com/apache/sling/blob/trunk/launchpad/test-services/sr
> c/main/java/org/apache/sling/launchpad/testservices/resourceprovider/
> PlanetsResourceProvider.java
> 
> [2] http://stackoverflow.com/questions/41901337/how-to-use-jersey-in-
> sling
> 
> 
> 
> 
> 
> --
> View this message in context: http://apache-sling.73963.n3.nabble.com
> /How-to-create-Rest-APIs-for-non-JCR-data-in-Sling-8-tp4069947.html
> Sent from the Sling - Users mailing list archive at Nabble.com.

Reply via email to