Hi Amit

I managed to get things working with the APIs you specified, however I find the 
ResourceCollection API a little inconsistent.  For example there is a mixed 
concept between the actual resource and the sling:member reference.  Which is 
why I ended up over looking getProperties.  My initial though was that you 
would be getting the properties of the _actual_ resource which the collection 
references.  I thought this because when you add a resource to the collection 
it is the actual resource, so having a mix between the sling:member resources 
vs actual resources is confusing.  

I also have a requirement to iterate through the sling:members in the 
collection and pull the properties off the nodes to render UI, however this 
isn't simple enough to do with the current API.  The two apis we have to use 
are getResources(), and getProperties() are do not reference the same resources 
which muddies the water.  It would be nice to have a getMembers() API that 
would return you the sling:members which then you could iterate over.  

There is a public static ResourceCollectionConstants.MEMBERS_NODE_NAME which 
gave me the feeling that there should be an API that would return these values. 
 If this is not the case then I thought it would have been protected or private.

Ben

On 2013-07-24, at 9:43 PM, Amit.. Gupta. <[email protected]> wrote:

> ResourceCollection has
> 
> /**
>     * Creates a new entry in the collection at the last position and add a 
> reference to resource
>     * in the entry.
>     * Changes are transient & have to be saved by calling resolver.commit()
>     *
>     * @param resource resource to be added
>     * @param properties The additional properties to be stored with the 
> collection entry (can be null).
>     * @return true if addition of resource to collection was successful or
>     *         false if collection already contained the resource or resource 
> is null.
>     *
>     * @throws {@link PersistenceException} if the operation fails
>     */
> boolean add(Resource resource, Map<String, Object> properties) throws 
> PersistenceException;
> 
> And, then to retrieve and update the properties.
> /**
>     * Returns additional properties for a particular resource in Collection 
> entry.
>     *
>     * @return properties of the Collection entry as 
> <code>ModifiableValueMap</code>, returns null if entry found.
>     */
>    ModifiableValueMap getProperties(Resource resource);
> 
> Thanks
> -Amit
> From: Ben Helleman [mailto:[email protected]]
> Sent: 25 July 2013 00:10
> To: [email protected]
> Subject: [sling/collection] Properties
> 
> Is there any way which to apply properties to members of a sling/collection?
> 
> For example I would like to apply properties to the websites node, not the 
> resource which websites references.  Yes, I'm aware that I could get the 
> collection and dig through children until I find the node of interest and 
> then apply properties.  But there must a better way.
> 
> [cid:[email protected]]
> 
> Thanks
> Ben

Reply via email to