The resource provider returns the resource for the path of the resource, ".json" is the rendering info - so your provider should return the resource if /etc/myroot/myresource is the path passed into the provider.
Everything else is taken care of by Sling Carsten 2014-02-21 12:06 GMT+01:00 Marius Petria <[email protected]>: > Hi, > > I am trying to implement a custom ResourceProvider and return a resource > that can be adapted to a ValueMap and eventually be rendered by > JsonRendererServlet. > > The request will be /etc/myroot/myresource.json. > I implemented the resource provider the following way: > > - It returns a resource for path /etc/myroot/myresource.json > > - The resource has the following properties: > > o resourcePath = /etc/myroot/myresource > > o metadata.resourcePath = /etc/myroot/myresource > > o metadata.resourcePathInfo = .json > > However that does not work because the ResourceProvider overrides the > metadata.resourcePath in [1] to the full requestPath, and > metdata.requestPathInfo to the remainder of the path (the empty string). > > Does that mean that in a ResourceProvider one should only return the > resource for the exact resource path /etc/myroot/myresource and ignore > paths with additional info? > Another way would be to trick the ResourceResolver and always return a new > metadata object, hence making the ResourceResolver overrides non effective. > > What is the correct way to implement the resource provider? > > Thanks, > Marius > > > [1] > https://github.com/apache/sling/blob/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java?source=cc#L935 > [2] > https://github.com/apache/sling/blob/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java?source=cc#L803 > > > -- Carsten Ziegeler [email protected]
