On Fri, Jul 26, 2013 at 8:57 AM, Richard Sand <rs...@idfconnect.com> wrote:
> Thanks Emmanuel! What is the criteria for isSchemaAware=true? Is it just > that a schema (any schema) was loaded, or that the objectclass of the > object has at least one value in one of the loaded schema? > > just loading the schema is enough(all received entries will become schema aware then) > -----Original Message----- > From: Emmanuel Lécharny [mailto:elecha...@gmail.com] > Sent: Thursday, July 25, 2013 7:11 PM > To: a...@directory.apache.org > Subject: Re: API behavior questions > > Le 7/26/13 12:01 AM, Richard Sand a écrit : > > Hi all - I've a couple of quick questions I wanted to bounce off the > list here, being new to the API, about the API behavior. Just want to make > sure I do the proper amount of defensive programming... > > > > 1) Does LdapConnection.search(..) ever return null? My understanding is > that if there are no results it'll still return a Cursor, but then > Cursor.next() will return false. > it should never return null. > > > > 2) Is there ever a condition where Entry.containsAttribute would return > true, but a call to Entry.get() returned null? > No. The thwo methdos are working on the same internal data structure (a > Map of Attributes) > > > > 3) Is there ever a condition where Entry.getAttributes() returns null, > as opposed to an empty collection? > When the AttributeType allows you to store null value, then you can get a > Value containing a null value. So, no, you can't get null. > > > > 4) Ditto for Attribute.iterator() - is it ever null, or will it always > exist but sometimes just be empty? > it's never null. But you can have no attribute to iterate on. > > > > 5) What needs to happen to have the results of calls to > LdapConnection.search(..) return entries for which isSchemaAware is true? > The LdapConnection must be schema aware itself. > > For that to happen, you just have to call the loadSchema() method : > > LdapConnection connection = new LdapNetworkConnection( "localhost", 389 ); > connection.loadSchema(); > > Here, we will load the default schemas. > > You can use some specific schema by using : > > connection.loadSchema(); > connection.addSchema( "MySchema.schema" ); > > where the "MySchema.schema" is a schema in OpenLDAP format. > > You can also use a SchemaLoader, but this get a bit too complex atm (and > sadly, the associated method is not yet in the LdapConnection interface) > > > > 6) I'm assuming that when an entry is schemaAware, calls to > isHumanReadable and getAttributeType will be populated per the schema? > > Yes, and all the controls on the Attribute values are done on the client > side. This is extremelly interesting for comparison of values, etc. > > > > Sorry if some of those response are not accurate, I'm giving them from the > top of my head. I hope I'm not too far from what the API is doing. > All those thing would need to be documented... > > -- > Regards, > Cordialement, > Emmanuel Lécharny > www.iktek.com > > > > -- Kiran Ayyagari http://keydap.com