You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Jessi Abrahams <je...@oracle.com> on 2012/11/01 22:53:31 UTC
Node property type constraints violated when setting strings
Hi,
I'm new to this list so I apologize if this question has been asked (I
tried searching the archives) or if this is not the right place to ask.
I have a custom node type with a definition like this:
[foo:bar] > mix:lastModified, mix:created, nt:base
- someBooleanProperty (BOOLEAN)
When I create a node of this type and use any of the setProperty methods
on Node, the repository allows me to set string values (such as "abc")
for someBooleanProperty even though as far as I understand from the type
definition, only booleans should be allowed. The repository throws a
ConstraintViolationException (as I would expect) if I try to to set
someBooleanProperty to any other incorrect (non-boolean) type - but not
strings. It seems like properties can always be set to a string, whether
or not it's allowed by the node type definition. Is this expected? It
doesn't seem in line with the spec.
Thanks
Jessi
Re: Node property type constraints violated when setting strings
Posted by Stefan Guggisberg <st...@gmail.com>.
hi jessi,
On Tue, Nov 6, 2012 at 9:08 PM, Jessi Abrahams
<je...@oracle.com> wrote:
> Hi Stefan,
>
> It looks like you were right that I was extending a node type with residual
> property definitions - I oversimplified the example I gave so it was not
> apparent. I've fixed the problematic inheritance and the repository is
> validating as expected. Thanks for your help.
good to hear and thanks for the feedback.
cheers
stefan
>
> Jessi
>
>
> On 11/02/2012 10:42 AM, Stefan Guggisberg wrote:
>>
>> On Fri, Nov 2, 2012 at 2:57 PM, Jessi Abrahams
>> <je...@oracle.com> wrote:
>>>
>>> Hi Michael,
>>>
>>> Thanks for your response. Based on that spec I would expect that if I
>>> tried
>>> to assign a value of "abc" then the property would end up being set to
>>> false
>>> (based on how Java converts strings to booleans). However what I am
>>> seeing
>>> is the property being assigned a string value of "abc".
>>
>> that would be a major bug. however, i suppose that your custom node type
>> extends a node type containing residual property definitions (such as e.g.
>> nt;unstructured).
>>
>> you can verify the declaring node type by running something like
>>
>> Property prop = node.setProperty("someBooleanProperty", "abc");
>> System.out.println(PropertyType.nameFromValue(prop.getType()));
>> PropertyDefinition def = prop.getDefinition();
>> System.out.println(def.getDeclaringNodeType().getName());
>> System.out.println(PropertyType.nameFromValue(def.getRequiredType()));
>>
>> cheers
>> stefan
>>
>>> Thanks
>>> Jessi
>>>
>>>
>>> On 11/02/2012 04:55 AM, Michael Dürig wrote:
>>>>
>>>>
>>>> Jessi,
>>>>
>>>> The repository will try to convert the string to a boolean. See 3.6.4
>>>> Property Type Conversion in JSR 283.
>>>>
>>>> Michael
>>>>
>>>> On 1.11.12 21:53, Jessi Abrahams wrote:
>>>>>
>>>>> Hi,
>>>>> I'm new to this list so I apologize if this question has been asked (I
>>>>> tried searching the archives) or if this is not the right place to ask.
>>>>>
>>>>> I have a custom node type with a definition like this:
>>>>>
>>>>> [foo:bar] > mix:lastModified, mix:created, nt:base
>>>>> - someBooleanProperty (BOOLEAN)
>>>>>
>>>>> When I create a node of this type and use any of the setProperty
>>>>> methods
>>>>> on Node, the repository allows me to set string values (such as "abc")
>>>>> for someBooleanProperty even though as far as I understand from the
>>>>> type
>>>>> definition, only booleans should be allowed. The repository throws a
>>>>> ConstraintViolationException (as I would expect) if I try to to set
>>>>> someBooleanProperty to any other incorrect (non-boolean) type - but not
>>>>> strings. It seems like properties can always be set to a string,
>>>>> whether
>>>>> or not it's allowed by the node type definition. Is this expected? It
>>>>> doesn't seem in line with the spec.
>>>>>
>>>>> Thanks
>>>>> Jessi
>>>>>
>>>>>
>>>>>
>>>
>
>
Re: Node property type constraints violated when setting strings
Posted by Jessi Abrahams <je...@oracle.com>.
Hi Stefan,
It looks like you were right that I was extending a node type with
residual property definitions - I oversimplified the example I gave so
it was not apparent. I've fixed the problematic inheritance and the
repository is validating as expected. Thanks for your help.
Jessi
On 11/02/2012 10:42 AM, Stefan Guggisberg wrote:
> On Fri, Nov 2, 2012 at 2:57 PM, Jessi Abrahams
> <je...@oracle.com> wrote:
>> Hi Michael,
>>
>> Thanks for your response. Based on that spec I would expect that if I tried
>> to assign a value of "abc" then the property would end up being set to false
>> (based on how Java converts strings to booleans). However what I am seeing
>> is the property being assigned a string value of "abc".
> that would be a major bug. however, i suppose that your custom node type
> extends a node type containing residual property definitions (such as e.g.
> nt;unstructured).
>
> you can verify the declaring node type by running something like
>
> Property prop = node.setProperty("someBooleanProperty", "abc");
> System.out.println(PropertyType.nameFromValue(prop.getType()));
> PropertyDefinition def = prop.getDefinition();
> System.out.println(def.getDeclaringNodeType().getName());
> System.out.println(PropertyType.nameFromValue(def.getRequiredType()));
>
> cheers
> stefan
>
>> Thanks
>> Jessi
>>
>>
>> On 11/02/2012 04:55 AM, Michael Dürig wrote:
>>>
>>> Jessi,
>>>
>>> The repository will try to convert the string to a boolean. See 3.6.4
>>> Property Type Conversion in JSR 283.
>>>
>>> Michael
>>>
>>> On 1.11.12 21:53, Jessi Abrahams wrote:
>>>> Hi,
>>>> I'm new to this list so I apologize if this question has been asked (I
>>>> tried searching the archives) or if this is not the right place to ask.
>>>>
>>>> I have a custom node type with a definition like this:
>>>>
>>>> [foo:bar] > mix:lastModified, mix:created, nt:base
>>>> - someBooleanProperty (BOOLEAN)
>>>>
>>>> When I create a node of this type and use any of the setProperty methods
>>>> on Node, the repository allows me to set string values (such as "abc")
>>>> for someBooleanProperty even though as far as I understand from the type
>>>> definition, only booleans should be allowed. The repository throws a
>>>> ConstraintViolationException (as I would expect) if I try to to set
>>>> someBooleanProperty to any other incorrect (non-boolean) type - but not
>>>> strings. It seems like properties can always be set to a string, whether
>>>> or not it's allowed by the node type definition. Is this expected? It
>>>> doesn't seem in line with the spec.
>>>>
>>>> Thanks
>>>> Jessi
>>>>
>>>>
>>>>
>>
Re: Node property type constraints violated when setting strings
Posted by Stefan Guggisberg <st...@gmail.com>.
On Fri, Nov 2, 2012 at 2:57 PM, Jessi Abrahams
<je...@oracle.com> wrote:
> Hi Michael,
>
> Thanks for your response. Based on that spec I would expect that if I tried
> to assign a value of "abc" then the property would end up being set to false
> (based on how Java converts strings to booleans). However what I am seeing
> is the property being assigned a string value of "abc".
that would be a major bug. however, i suppose that your custom node type
extends a node type containing residual property definitions (such as e.g.
nt;unstructured).
you can verify the declaring node type by running something like
Property prop = node.setProperty("someBooleanProperty", "abc");
System.out.println(PropertyType.nameFromValue(prop.getType()));
PropertyDefinition def = prop.getDefinition();
System.out.println(def.getDeclaringNodeType().getName());
System.out.println(PropertyType.nameFromValue(def.getRequiredType()));
cheers
stefan
>
> Thanks
> Jessi
>
>
> On 11/02/2012 04:55 AM, Michael Dürig wrote:
>>
>>
>> Jessi,
>>
>> The repository will try to convert the string to a boolean. See 3.6.4
>> Property Type Conversion in JSR 283.
>>
>> Michael
>>
>> On 1.11.12 21:53, Jessi Abrahams wrote:
>>>
>>> Hi,
>>> I'm new to this list so I apologize if this question has been asked (I
>>> tried searching the archives) or if this is not the right place to ask.
>>>
>>> I have a custom node type with a definition like this:
>>>
>>> [foo:bar] > mix:lastModified, mix:created, nt:base
>>> - someBooleanProperty (BOOLEAN)
>>>
>>> When I create a node of this type and use any of the setProperty methods
>>> on Node, the repository allows me to set string values (such as "abc")
>>> for someBooleanProperty even though as far as I understand from the type
>>> definition, only booleans should be allowed. The repository throws a
>>> ConstraintViolationException (as I would expect) if I try to to set
>>> someBooleanProperty to any other incorrect (non-boolean) type - but not
>>> strings. It seems like properties can always be set to a string, whether
>>> or not it's allowed by the node type definition. Is this expected? It
>>> doesn't seem in line with the spec.
>>>
>>> Thanks
>>> Jessi
>>>
>>>
>>>
>
>
Re: Node property type constraints violated when setting strings
Posted by Julian Reschke <ju...@gmx.de>.
On 2012-11-02 14:57, Jessi Abrahams wrote:
> Hi Michael,
>
> Thanks for your response. Based on that spec I would expect that if I
> tried to assign a value of "abc" then the property would end up being
> set to false (based on how Java converts strings to booleans). However
> what I am seeing is the property being assigned a string value of "abc".
>
> Thanks
> Jessi
> ...
That would be a bug. Maybe you could check whether there's a relevant
test case missing in jackrabbit-tests?
Best regards, Julian
Re: Node property type constraints violated when setting strings
Posted by Jessi Abrahams <je...@oracle.com>.
Hi Michael,
Thanks for your response. Based on that spec I would expect that if I
tried to assign a value of "abc" then the property would end up being
set to false (based on how Java converts strings to booleans). However
what I am seeing is the property being assigned a string value of "abc".
Thanks
Jessi
On 11/02/2012 04:55 AM, Michael Dürig wrote:
>
> Jessi,
>
> The repository will try to convert the string to a boolean. See 3.6.4
> Property Type Conversion in JSR 283.
>
> Michael
>
> On 1.11.12 21:53, Jessi Abrahams wrote:
>> Hi,
>> I'm new to this list so I apologize if this question has been asked (I
>> tried searching the archives) or if this is not the right place to ask.
>>
>> I have a custom node type with a definition like this:
>>
>> [foo:bar] > mix:lastModified, mix:created, nt:base
>> - someBooleanProperty (BOOLEAN)
>>
>> When I create a node of this type and use any of the setProperty methods
>> on Node, the repository allows me to set string values (such as "abc")
>> for someBooleanProperty even though as far as I understand from the type
>> definition, only booleans should be allowed. The repository throws a
>> ConstraintViolationException (as I would expect) if I try to to set
>> someBooleanProperty to any other incorrect (non-boolean) type - but not
>> strings. It seems like properties can always be set to a string, whether
>> or not it's allowed by the node type definition. Is this expected? It
>> doesn't seem in line with the spec.
>>
>> Thanks
>> Jessi
>>
>>
>>
Re: Node property type constraints violated when setting strings
Posted by Michael Dürig <md...@apache.org>.
Jessi,
The repository will try to convert the string to a boolean. See 3.6.4
Property Type Conversion in JSR 283.
Michael
On 1.11.12 21:53, Jessi Abrahams wrote:
> Hi,
> I'm new to this list so I apologize if this question has been asked (I
> tried searching the archives) or if this is not the right place to ask.
>
> I have a custom node type with a definition like this:
>
> [foo:bar] > mix:lastModified, mix:created, nt:base
> - someBooleanProperty (BOOLEAN)
>
> When I create a node of this type and use any of the setProperty methods
> on Node, the repository allows me to set string values (such as "abc")
> for someBooleanProperty even though as far as I understand from the type
> definition, only booleans should be allowed. The repository throws a
> ConstraintViolationException (as I would expect) if I try to to set
> someBooleanProperty to any other incorrect (non-boolean) type - but not
> strings. It seems like properties can always be set to a string, whether
> or not it's allowed by the node type definition. Is this expected? It
> doesn't seem in line with the spec.
>
> Thanks
> Jessi
>
>
>