You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Felix Knecht <fe...@otego.com> on 2010/10/29 15:20:06 UTC
Valid filter?
Sorry about silly questions, but is this a valid filter "(object=)"? I
don't think so, but I'm not sure :(
Anyway should not result in NPE.
(Try fixing https://issues.apache.org/jira/browse/DIRSHARED-69)
Thanks
Felix
Re: toString(null) -> "null" or "" [was: Valid filter?]
Posted by Emmanuel Lecharny <el...@gmail.com>.
On 10/29/10 7:57 PM, Felix Knecht wrote:
>
>> Note that it won't be enough. We have to do the same thing in other
>> XXXNode classes.
>
> Thanks for hints. Doing so it makes the null-string question obsolete.
> Hope I got all the XXXNode classes (found 4)
Thanks a bunch Felix !
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com
Re: toString(null) -> "null" or "" [was: Valid filter?]
Posted by Felix Knecht <fe...@apache.org>.
> Note that it won't be enough. We have to do the same thing in other
> XXXNode classes.
Thanks for hints. Doing so it makes the null-string question obsolete.
Hope I got all the XXXNode classes (found 4)
Felix
Re: toString(null) -> "null" or "" [was: Valid filter?]
Posted by Emmanuel Lecharny <el...@gmail.com>.
On 10/29/10 5:31 PM, Felix Knecht wrote:
> Imagine following test:
>
> String str="(objectClass=)";
> ExprNode node = FilterParser.parse( str );
> assertEquals( str, node.toString() );
>
> This test will fail ATM because we do
> 'return value == null ? "null" : value;'
In fact, the node.toString() is throwing a NPE. There are two problems
here :
- first we don't check that the wrapped value is null before returning
an escapedValue when we try to create one => NPE
- second, if we do, as the Value will be null, the toString() applied on
this value will return "null".
>
> So what's closer to what we really want to show?
We should fix the filter toString() method plus the AbstractExprNode
escapeFilterValue() method :
protected static Value<?> escapeFilterValue( Value<?> value )
{
if ( value.isNull() )
{
return value;
}
...
and in EqualityNode :
public String toString()
{
StringBuilder buf = new StringBuilder();
buf.append( '(' );
...
Value<?> escapedValue = getEscapedValue();
buf.append( "=" );
if ( !escapedValue.isNull() )
{
buf.append( escapedValue );
}
Note that it won't be enough. We have to do the same thing in other
XXXNode classes.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com
Re: toString(null) -> "null" or "" [was: Valid filter?]
Posted by Kiran Ayyagari <ka...@apache.org>.
On 10/29/10, Felix Knecht <fe...@apache.org> wrote:
> Imagine following test:
>
> String str="(objectClass=)";
> ExprNode node = FilterParser.parse( str );
> assertEquals( str, node.toString() );
>
> This test will fail ATM because we do
> 'return value == null ? "null" : value;'
>
> This is done in
> - org.apache.directory.shared.ldap.entry.StringValue
> - org.apache.directory.shared.ldap.entry.BinaryValue
>
> So what's closer to what we really want to show?
>
> My +1 for returning an empty String instead if "null"
> 'return value == null ? "" : value;'
+1
>
>
> Felix
>
--
Kiran Ayyagari
toString(null) -> "null" or "" [was: Valid filter?]
Posted by Felix Knecht <fe...@apache.org>.
Imagine following test:
String str="(objectClass=)";
ExprNode node = FilterParser.parse( str );
assertEquals( str, node.toString() );
This test will fail ATM because we do
'return value == null ? "null" : value;'
This is done in
- org.apache.directory.shared.ldap.entry.StringValue
- org.apache.directory.shared.ldap.entry.BinaryValue
So what's closer to what we really want to show?
My +1 for returning an empty String instead if "null"
'return value == null ? "" : value;'
Felix
Re: Valid filter?
Posted by Emmanuel Lecharny <el...@gmail.com>.
On 10/29/10 3:20 PM, Felix Knecht wrote:
> Sorry about silly questions, but is this a valid filter "(object=)"? I
> don't think so, but I'm not sure :(
My bad, and Steven is right : this should be a valid filter, of course
if the AttributeType support a null value.
In any case, the parser should *not* throw an exception.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com
RE: Valid filter?
Posted by "Hammond, Steven" <St...@Polycom.com>.
(objectClass=) is valid right? (givenName=) also valid. Find record where user does not have a first name (not present)
If object is defined in your schema, that would make Felix's valid too. I am not understanding what attributetype assertion needs to be added. Can you show an example?
Thanx.
-----Original Message-----
From: ayyagarikiran@gmail.com [mailto:ayyagarikiran@gmail.com] On Behalf Of Kiran Ayyagari
Sent: Friday, October 29, 2010 7:32 AM
To: Apache Directory Developers List
Subject: Re: Valid filter?
On 10/29/10, Kiran Ayyagari <ka...@apache.org> wrote:
> On 10/29/10, Felix Knecht <fe...@otego.com> wrote:
>> Sorry about silly questions, but is this a valid filter "(object=)"? I
>> don't think so, but I'm not sure :(
>>
> syntax wise it is correct and yes over all it is correct but treated by
> server
> as undefined unless there exists a attributetype 'object' is present
> in the server
oops sorry, it is not a valid filter AFAIK, the attributetype
assertion value is missing
(I read it wrong)
>> Anyway should not result in NPE.
>>
>> (Try fixing https://issues.apache.org/jira/browse/DIRSHARED-69)
>>
>> Thanks
>> Felix
>>
>
>
> --
> Kiran Ayyagari
>
--
Kiran Ayyagari
Re: Valid filter?
Posted by Kiran Ayyagari <ka...@apache.org>.
On 10/29/10, Kiran Ayyagari <ka...@apache.org> wrote:
> On 10/29/10, Felix Knecht <fe...@otego.com> wrote:
>> Sorry about silly questions, but is this a valid filter "(object=)"? I
>> don't think so, but I'm not sure :(
>>
> syntax wise it is correct and yes over all it is correct but treated by
> server
> as undefined unless there exists a attributetype 'object' is present
> in the server
oops sorry, it is not a valid filter AFAIK, the attributetype
assertion value is missing
(I read it wrong)
>> Anyway should not result in NPE.
>>
>> (Try fixing https://issues.apache.org/jira/browse/DIRSHARED-69)
>>
>> Thanks
>> Felix
>>
>
>
> --
> Kiran Ayyagari
>
--
Kiran Ayyagari
Re: Valid filter?
Posted by Kiran Ayyagari <ka...@apache.org>.
On 10/29/10, Felix Knecht <fe...@otego.com> wrote:
> Sorry about silly questions, but is this a valid filter "(object=)"? I
> don't think so, but I'm not sure :(
>
syntax wise it is correct and yes over all it is correct but treated by server
as undefined unless there exists a attributetype 'object' is present
in the server
> Anyway should not result in NPE.
>
> (Try fixing https://issues.apache.org/jira/browse/DIRSHARED-69)
>
> Thanks
> Felix
>
--
Kiran Ayyagari
Re: Valid filter?
Posted by Emmanuel Lecharny <el...@gmail.com>.
On 10/29/10 3:20 PM, Felix Knecht wrote:
> Sorry about silly questions, but is this a valid filter "(object=)"? I
> don't think so, but I'm not sure :(
No it's not
>
> Anyway should not result in NPE.
+1
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com