directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ole Ersoy <ole.er...@gmail.com>
Subject Re: [Schema] How do I write a new ObjectClass to ApacheDS
Date Wed, 28 Mar 2007 21:36:18 GMT
OH - OK - I think the lights are turning on.

Suppose I have a
DN: cn=user1 ou=users, ou=system

I can hang any attribute I want on this DN right?

So if I want to store an instance of Java Class User (That has members 
[userName:String, userPassword:string]
I could simply add the member values of a User instance as attributes to 
the DN, and my object is effectively stored.

If I want to get an instance of that object later,
the DAS just creates a user instance, and fetches the attributes using the
DN: cn=user1 ou=users, ou=system       

context.

In other words I get the attributes assigned to this context and
the ones that have the same name as the User Class members, would be
be assigned used to initialize the state of a User instance?

So even thought userName has java type String,
I don't have to create  a corresponding
LDAP ObjectClass named User that says that
userName is of LDAP attribute type String....., and then map the java 
members
to the members of the User ObjectClass?

Thanks,
- Ole



Emmanuel Lecharny wrote:
> Hi Ole,
>
> not sure I understand exactly what you want to do, but first, you 
> should read 
> http://cwiki.apache.org/confluence/display/DIRxSRVx11/Schema+Subsystem+Redesign 
>
> and the children pages, they explain what is the current status of the 
> Schema system in ADS 1.5.
>
> Now, you have to know that ObjectClasses and AttributTypes are just 
> considered as normal entries by the server, so you can simply use 
> BasicAttributes() to store your newly created ObjectClass, wih all the 
> meta attributes needed to describe your objectclasses (see the xiki 
> pages above, there is an example of conversion for core.schema)
>
> Hope it helps.
>
> Ole Ersoy a écrit :
>
>> Hey Guys,
>>
>> I'm in the middle of designing the DAS and
>> decided that I can probably make it way more efficient
>> if I create an ObjectClass per Java Class that I want to write to
>> ADS.
>>
>> So how do I programmatically create a ObjectClass and store it
>> in ApacheDS?
>>
>> Do we have a description somewhere or is this a standard JNDI thing?
>>
>> Here's a little further elaboration on what I want to do for those 
>> interested.
>>
>> Keep in mind this is just an example.  The Class User could be any 
>> java class used in a model.
>>
>> I have a Java Class >> User
>>
>> The Class User has String members [firstName, lastName, password]
>>
>> So I want to create a Structural ObjectClass in ApacheDS so that
>> I can add it as an attribute to the DN where a User instance will be 
>> stored (The java object instance).
>>
>> If I were doing this in a relational database, I would create a table 
>> definition instead of a ObjectClass.
>>
>> So I'm looking for something like this:
>>
>> ObjectClass objectClass = LDAPSchemaFactory.createObjectClass();
>> objectClass.setName("User");
>> ObjectClassAttribute objectClassAttribute = 
>> LDAPSchemaFactory.createObjectClassAttribute();
>> objectClassAttribute.setName("firstName");
>> objectClassAttribute.setType(LDAP_STRING_ATTRIBUTE_TYPE);
>>
>> Then I would do something like:
>>
>> ctx.storeObjectClass(objectClass);
>>
>> The objectClass can now be assigned as an attribute to an ADS entry,
>> and if we were to look at all the ObjectClasses in ADS through 
>> JXPlorer or LDAP Studio,
>> we would see the User ObjectClass in the list.
>>
>> Does that make sense?
>>
>> Thanks,
>> - Ole
>>
>>
>>
>>
>>
>>
>
>


Mime
View raw message