You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Justin Edelson <ju...@justinedelson.com> on 2011/02/12 02:30:03 UTC

How should the case where sling:resourceType is a multi-valued property be handled?

I ran into a strange issue today where the sling:resourceType property
was multi-valued on one of my nodes.

This produced an error because this code from JcrItemResource assumes
it is a single-valued property:
        if (node.hasProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY))
{
            result =
node.getProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY).getValue().getString();
        }

I was thinking that if sling:resourceType is multi-valued, the first
value should be used and a warning logged.

WDYT?

Justin

Re: How should the case where sling:resourceType is a multi-valued property be handled?

Posted by Felix Meschberger <fm...@adobe.com>.
Hi,

sling:resourceType is not expected to be multi-value and the Node based
resources don't support it.

I am undecided: The keep-the-concepts-clean part of my mind says this
should be considered an error. On the other hand maybe just be graceful,
using the first value and log a warn message might be useful, too...

Regards
Felix

Am Samstag, den 12.02.2011, 01:30 +0000 schrieb Justin Edelson: 
> I ran into a strange issue today where the sling:resourceType property
> was multi-valued on one of my nodes.
> 
> This produced an error because this code from JcrItemResource assumes
> it is a single-valued property:
>         if (node.hasProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY))
> {
>             result =
> node.getProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY).getValue().getString();
>         }
> 
> I was thinking that if sling:resourceType is multi-valued, the first
> value should be used and a warning logged.
> 
> WDYT?
> 
> Justin



Re: How should the case where sling:resourceType is a multi-valued property be handled?

Posted by Ian Boston <ie...@tfd.co.uk>.
On 18 Feb 2011, at 15:30, Bertrand Delacretaz wrote:

> On Sat, Feb 12, 2011 at 2:30 AM, Justin Edelson
> <ju...@justinedelson.com> wrote:
>> ...I was thinking that if sling:resourceType is multi-valued, the first
>> value should be used and a warning logged....
> 
> I think I'd fail loudly on that one, it could be very confusing to
> troubleshoot otherwise?


Having spent some time in a debugger with resource type and servlet resolution getting extreemly confused about the bindings to servlets, opting servlets and selectors.... simple would be better. 

Also 
>   result =
> node.getProperty(JcrResourceConstants.SLING_RESOURCE_TYPE_PROPERTY).getValue().getString();
>        }

is going to be used all over the place in client code since sling:resourceType has been assumed by many to be part of a defacto schema.
Ian


> 
> -Bertrand


Re: How should the case where sling:resourceType is a multi-valued property be handled?

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Sat, Feb 12, 2011 at 2:30 AM, Justin Edelson
<ju...@justinedelson.com> wrote:
> ...I was thinking that if sling:resourceType is multi-valued, the first
> value should be used and a warning logged....

I think I'd fail loudly on that one, it could be very confusing to
troubleshoot otherwise?

-Bertrand