On 14 Dec 2009, at 10:08, Carsten Ziegeler wrote:
> Hi,
>
> I've written a sample application for Sling which is a nice photo
> gallery (I'm planing to commit this as a sample in Sling).
>
> Obviously the app acts on images. For better separation and managing the
> data, the images are stored in folders under a root folder ("myapp").
>
> I've wrapped my head around the problem of how to detect the correct
> resource type for the images stored there for several weeks now :(
>
> In order to be displayed correctly, each folder needs an album resource
> type and each image a photo resource type. This can be done by observing
> "myapp" and adding the properties to the corresponding files and folders.
> But for one I don't like to use observation just to add a resource type
> and secondly this only works if all your data is in the repository. With
> Sling we have the nice resource abstraction. And I could just mount a
> folder from my file system at myapp/myimages. And there is no way of
> adding a resource type to those files.
>
> For the jcr resource provider we have the JcrResourceTypeProvider
> interface which allows to implement a custom resolution mechanism for
> JCR content.
>
> So one solution to my problem would be to make this interface more
> general and I could implement something like the path based resource
> type provider: if path starts with /myapp and extension is an image
> extension -> resource type photo. No extension -> resource type is an
> album. Or something along these lines.
I think the provider implementation should make the decisions on exactly how it
decides its a resource type it knows about.
One might use a rule like "starts with /myapp"
but others might use "has a parent node with sling:resourceType sling/album"
etc
Ian
>
> Now I'm wondering if this is the way to go, or if there maybe is a
> better approach?
>
> Carsten
> --
> Carsten Ziegeler
> [email protected]