You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2011/05/11 18:25:32 UTC
API evolution
Hi guys,
those last three days, I made some modifications in the API following
the discussions we has 2 weeks ago. Namely :
1) The 'simple' requests are not anymore returning a Response. If
somethng went wrong, an exception will be thrown.
For instance, instead of doing :
BindResponse bindResponse = connection.bing( "jdoe", secret" );
if ( bindResponse.getResultCode() == ResultCodeEnum.SUCCESS )
{
// do something
}
we now do :
try
{
connection.bing( "jdoe", secret" );
}
catch ( LdapException le )
{
// Deal with the issue
}
Note that if you do a connection.bind( BindRequest ), then you get back
a BindResponse.
2) The search request is now returning a EntryCursor for 'simple' searches.
The code now looks like :
EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "*" );
while ( cursor.next() )
{
Entry result = cursor.get();
// do something with the Entry
}
instead of :
Cursor<Response> cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "*" );
while ( cursor.next() )
{
Entry result = ( ( SearchResultEntry ) cursor.get() ).getEntry();
// do something with the Entry
}
Again, using a connection.search( SearchRequest ), you get back a Cursor<Response> as a result.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com
Re: API evolution
Posted by Pierre-Arnaud Marcelot <pa...@marcelot.net>.
Definitely a good step towards a very easy to use and eye-pleasing API (which is also full featured for experienced developers).
Thanks Emmanuel!
Regards,
Pierre-Arnaud
On 11 mai 2011, at 18:40, Alex Karasulu wrote:
>
> On Wed, May 11, 2011 at 7:25 PM, Emmanuel Lecharny <el...@gmail.com> wrote:
> Hi guys,
>
> those last three days, I made some modifications in the API following the discussions we has 2 weeks ago. Namely :
> 1) The 'simple' requests are not anymore returning a Response. If somethng went wrong, an exception will be thrown.
>
> For instance, instead of doing :
>
> BindResponse bindResponse = connection.bing( "jdoe", secret" );
>
> if ( bindResponse.getResultCode() == ResultCodeEnum.SUCCESS )
> {
> // do something
> }
>
> we now do :
>
> try
> {
> connection.bing( "jdoe", secret" );
> }
> catch ( LdapException le )
> {
> // Deal with the issue
> }
>
> Note that if you do a connection.bind( BindRequest ), then you get back a BindResponse.
>
>
> 2) The search request is now returning a EntryCursor for 'simple' searches.
>
> The code now looks like :
>
> EntryCursor cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "*" );
>
> while ( cursor.next() )
> {
> Entry result = cursor.get();
> // do something with the Entry
>
> }
>
> instead of :
>
> Cursor<Response> cursor = connection.search( "ou=system", "(objectClass=*)", SearchScope.SUBTREE, "*" );
>
> while ( cursor.next() )
> {
> Entry result = ( ( SearchResultEntry ) cursor.get() ).getEntry();
> // do something with the Entry
> }
>
> Again, using a connection.search( SearchRequest ), you get back a Cursor<Response> as a result.
>
> This looks a lot cleaner. Great job Emmanuel.
>
> Thanks,
> Alex
Re: API evolution
Posted by Emmanuel Lécharny <el...@apache.org>.
On 5/11/11 6:40 PM, Alex Karasulu wrote:
> On Wed, May 11, 2011 at 7:25 PM, Emmanuel Lecharny<el...@gmail.com>wrote:
>
>> Again, using a connection.search( SearchRequest ), you get back a
>> Cursor<Response> as a result.
>
> This looks a lot cleaner. Great job Emmanuel.
Note that we have more to do, like handling referrals chasing. But this
can be done later.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com
Re: API evolution
Posted by Alex Karasulu <ak...@apache.org>.
On Wed, May 11, 2011 at 7:25 PM, Emmanuel Lecharny <el...@gmail.com>wrote:
> Hi guys,
>
> those last three days, I made some modifications in the API following the
> discussions we has 2 weeks ago. Namely :
> 1) The 'simple' requests are not anymore returning a Response. If somethng
> went wrong, an exception will be thrown.
>
> For instance, instead of doing :
>
> BindResponse bindResponse = connection.bing( "jdoe", secret" );
>
> if ( bindResponse.getResultCode() == ResultCodeEnum.SUCCESS )
> {
> // do something
> }
>
> we now do :
>
> try
> {
> connection.bing( "jdoe", secret" );
> }
> catch ( LdapException le )
> {
> // Deal with the issue
> }
>
> Note that if you do a connection.bind( BindRequest ), then you get back a
> BindResponse.
>
>
> 2) The search request is now returning a EntryCursor for 'simple' searches.
>
> The code now looks like :
>
> EntryCursor cursor = connection.search( "ou=system",
> "(objectClass=*)", SearchScope.SUBTREE, "*" );
>
> while ( cursor.next() )
> {
> Entry result = cursor.get();
> // do something with the Entry
>
> }
>
> instead of :
>
> Cursor<Response> cursor = connection.search( "ou=system",
> "(objectClass=*)", SearchScope.SUBTREE, "*" );
>
> while ( cursor.next() )
> {
> Entry result = ( ( SearchResultEntry ) cursor.get()
> ).getEntry();
> // do something with the Entry
> }
>
> Again, using a connection.search( SearchRequest ), you get back a
> Cursor<Response> as a result.
This looks a lot cleaner. Great job Emmanuel.
Thanks,
Alex