You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Felix Meschberger <fm...@gmail.com> on 2010/01/26 08:19:25 UTC

Re: Property with Multiple References

[Moving to dev]

It looks like the problem is at line #103 in the JsonResourceWriter
class of the Default GET Servlet bundle. This adapts the resource to a
single string value, which is not implemented very stable in the
JcrPropertyResource.adaptTo method: It just calls Property.getString(),
which throws for a Multi-Value property.

Probably we should replace this by adapting to String[] and then either
set the result to an array of values or a single value.

WDYT ?

Yet, lets wait for the issue report ;-)


Regard
Felix

On 26.01.2010 01:10, Justin Edelson wrote:
> Can you create a JIRA issue and attach your bundle (or a simplified
> version)?
> 
> Justin
> 
> On Jan 25, 2010, at 2:22 PM, Jason Rose <jr...@meltmedia.com> wrote:
> 
>> Hello,
>>
>> In my current application using the trunk build of sling, I'm trying
>> to model a many-to-many relationship between Users and Regions.  I'm
>> setting up all my nodes via a bundle that uses the Sling/Jackrabbit
>> API directly, and I can create all the nodes and properties
>> correctly, I cannot use the reference between User and Region via my
>> URL.
>>
>> I use localhost:8181/content/users/user_a.json which shows me that
>> the 'regions' property I have set is an array of Region node
>> jcr:uuids.  But if I do localhost:8181/content/users/user_a/
>> regions.json, I get no response nor exception.  If I create a non-
>> multiple Region reference to a random element of my Region set, I
>> can properly use localhost:8181/content/users/user_a/region.json and
>> traverse the reference.  But no matter what I try, I cannot retrieve
>> the multiple Region references.
>>
>> All of my nodes are nt:unstructured with mix:referenceable.  I
>> create them via the JCR api and add the mixin, as well as all of my
>> properties.  I use the following line of code to set the regions
>> property:
>>
>> userNode.setProperty("regions", regionNodeSet.toArray(new Region[]
>> {}), PropertyType.REFERENCE);
>>
>> If I query that property, it is a PropertyType.REFERENCE and
>> isMultiple() is true.  What am I doing wrong?
>>
>> -Jason
>