|
Home > Archive > Apache Directory Project > March 2007 > [Schema] How do I write a new ObjectClass to ApacheDS
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
[Schema] How do I write a new ObjectClass to ApacheDS
|
|
| Ole Ersoy 2007-03-28, 7:11 pm |
| 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
| |
| Emmanuel Lecharny 2007-03-28, 7:11 pm |
| Hi Ole,
not sure I understand exactly what you want to do, but first, you should
read
http://cwiki.apache.org/confluence/...system+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
>
>
>
>
>
>
| |
| Ole Ersoy 2007-03-28, 7:11 pm |
| 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/...system+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 :
>
>
>
| |
| Emmanuel Lecharny 2007-03-28, 7:11 pm |
| Ole Ersoy a écrit :
> 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?
Alas, no. You have clear rules (explained in RFCs) :
- you can use attributes which are described as MAYin all the
objectClasses for this entry
- you *must* declare all the MUST attributes described in all the
objectClasses for this entry
- the attribute used in the RDN (here, it's cn=user1) *must* be present
as an attribute.
>
> 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.
Sorry, I don't understand what you mean.
>
> 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.
ah, maybe you are talking about a O/L mapping (Object/Ldap mapping,
Patent N° 5356886, owned by Emmanuel Lécharny 
>
> 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?
I don't understand ...
>
> 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?
Sorry, I must be dumb, but I don't understand.
What do you want to do exactly ?
Emmanuel
>
> Thanks,
> - Ole
>
>
>
> Emmanuel Lecharny wrote:
>
>
>
| |
| Stefan Seelmann 2007-03-28, 7:11 pm |
| Ole Ersoy schrieb:
> 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?
Yes, assumed that the attribute type is defined in the LDAP schema and
the DN/entry has the object classes that allow that attribute.
>
> 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?
Hm, JNDI defines a framework for doing such mappings between Java
objects and LDAP entries: State Factories and Object Factories. Please
see http://java.sun.com/products/jndi/tutorial/TOC.html, especially
chapter 'Java Objects and the Directory'.
>
> 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?
For such a simple case you could just reuse the standard object class
'person' with its attributes 'cn' and 'userPassword'. But note that the
userPassword attribute is defined as binary (Octet String) in RFC 4519.
If your User Java class additionally has an attribute (e.g. 'shoeSize')
that is not specified in an standard schema you could define an
additional (AUXILIARY) object class in LDAP, e.g. 'customPerson' and an
attribute type 'shoeSize' as may attribute. Then you could add this
object class to the entry and then you could store the attribute
'shoeSize' to the entry.
>
> Thanks,
> - Ole
Stefan
| |
| Ole Ersoy 2007-03-28, 7:11 pm |
| OK - I guess I could have shortened the question/understanding to:
If I have a series of attributes hanging off of a DN does at least one
of those attributes
have to be an structural ObjectClass?
And the answer is yes.
Emmanuel Lecharny wrote:
> Ole Ersoy a écrit :
>
>
> Alas, no. You have clear rules (explained in RFCs) :
> - you can use attributes which are described as MAYin all the
> objectClasses for this entry
> - you *must* declare all the MUST attributes described in all the
> objectClasses for this entry
> - the attribute used in the RDN (here, it's cn=user1) *must* be
> present as an attribute.
>
>
> Sorry, I don't understand what you mean.
Well, it's sort of a mute point now, but just in case it helps streamline
a common understanding, suppose I added the members of the above User
instance as attributes
handing off of the context:
DN: cn=user1 ou=users, ou=system
If you looked at this DN in JXPlorer, you would not see any ObjectClasses
associated with the context. You would only see two attributes, named
userName and userPassword.
These are the two members of the User class instance that I am storing.
Does that make sense? However I can't do this, since the RFCs make this
illegal.
Thus I have to create a User ObjectClass
Remember though, I'm just using User as an example here.
Stefan mentioned that I could just use Person instead.
And that's true in this case, but User could be any Java class modeling
something.
It could be a Car Class, with a door integer member, color, etc. that
does not have
any type of ObjectClass defined already.
So before I can store an instance of this I need to define an
ObjectClass for it,
then store it's members using that ObjectClass.
Does that make sense?
>
>
> ah, maybe you are talking about a O/L mapping (Object/Ldap mapping,
> Patent N° 5356886, owned by Emmanuel Lécharny 
>
Yeah - That sounds like it :-)
>
> I don't understand ...
>
Does it make more sense now?
>
> Sorry, I must be dumb, but I don't understand.
>
I think you got it already. The O/L mapping I think captured it. Does
it make sense?
> What do you want to do exactly ?
> Emmanuel
>
>
>
| |
| Ole Ersoy 2007-03-28, 7:11 pm |
| Stefan Seelmann wrote:
> Ole Ersoy schrieb:
>
>
> Yes, assumed that the attribute type is defined in the LDAP schema and
> the DN/entry has the object classes that allow that attribute.
>
>
Ah Right - I was hoping maybe there was a way to turn that off, so that
I can just
have any attribute I want without any Schema checking.
So that's why I need to generate the ObjectClass for the Java Class on
the fly / before
I write the object.
>
> Hm, JNDI defines a framework for doing such mappings between Java
> objects and LDAP entries: State Factories and Object Factories. Please
> see http://java.sun.com/products/jndi/tutorial/TOC.html, especially
> chapter 'Java Objects and the Directory'.
>
>
>
> For such a simple case you could just reuse the standard object class
> 'person' with its attributes 'cn' and 'userPassword'. But note that the
> userPassword attribute is defined as binary (Octet String) in RFC 4519.
>
> If your User Java class additionally has an attribute (e.g. 'shoeSize')
> that is not specified in an standard schema you could define an
> additional (AUXILIARY) object class in LDAP, e.g. 'customPerson' and an
> attribute type 'shoeSize' as may attribute. Then you could add this
> object class to the entry and then you could store the attribute
> 'shoeSize' to the entry.
>
Yes! Precisely. It could be that the Class I want to store is a
ShoeSizeGuesser class.
I want to store the following members of that class
weight: int
height: int
hairColor: String
But I don't have an ObjectClass for this in ADS, so first I need to
create one programmatically.
So the DAS first creates it, stores it in ADS, then
creates a context to store the attributes of ShoeSizeGuesser under
So the ShoeSizeGuesser would have these LDAP attributes:
ObjectClass: ShoeSizeGuesser
weight: int
height: int
hairColor: String
So my question is, how do I create the
ShoeSizeGuesser ObjectClass programmatically
at the client end, and then "bind" / "load" it into
ApacheDS?
I looked at the New Schema Subsystem material, but did not see a section
on how to do this...
Any ideas?
Thanks,
- Ole
>
>
> Stefan
>
>
| |
| Alex Karasulu 2007-03-29, 1:11 am |
| Hi Ole,
Looks like you got some good advice already. Let me just add one more
suggestion
while you're looking into creating a schema. Sometimes you'll find that the
attributeTypes and objectClasses you're looking for are already defined in
published
schemas.
For example for users you might want to take a look at something like
inetOrgPerson etc.
Second I suppose you're thinking of staying bleeding edge by using
1.5rather than using
1.0. I'd recommend this. And if so then merely adding the schema
description entry for
the objectClass in the ou=schema partition in the appropriate place should
work. The schema
is dynamic in 1.5 but I guess Emmanuel and Stephan already pointed this out.
I will try to back read this thread. As you can imagine I have a lot to
catch up on since
I've been on vacation fishing all week :D. Yeah I don't miss LDAP he he.
Regards,
Alex
On 3/28/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
> 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
>
>
>
>
>
>
| |
| Ole Ersoy 2007-03-29, 1:11 am |
| Hey Alex,
Yes - I think we're getting warmer!
Here's the thing. Suppose I want to store an object that has String members
shoeSize
weight
height
name
etc.
I probably have name on some ObjectClass already defined in ApacheDS.
However I still want to duplicate name on a completely different
ObjectClass.
The ObjectClass I want has a 1:1 correspondence with the Java Class I
want to store.
That way a simple convention can be used to store the object, and no
configuration file
or index searching is needed to include a preexisting ObjectClass that
has the name attribute on it.
I guess I could create an index with all the LDAP attributeTypes and
look to see whether a certain attribute
already exists, and use it, but I think it's simpler just to create a
brand new ObjectClass.
Which leads me to another question.
Can ObjectClass names have periods or underscores in them
For Instance there's inetOrgPerson?
Could it be
inet.org.person?
The reason I ask is because I want to create ObjectClasses on the fly
that are namespaced.
So if I have an Class with full namespace:
org.apache.directory.Configuration
that holds configuration data, I want to create an ObjectClass that has
the fully namespaced name of the corresponding Java Class.
This way we avoid name collisions when someone from
trucks.example.com
and
vans.example.com
want to store their objects in ADS, and they
both have a Car Java Class that has a corresponding ObjectClass.
Hope fishing was a blast. I'm sure you're really glad to out of the
Sun, blue clear water,
and cool breeze environment and be back in front of a monitor.
I was getting the shivers a little in Canada, but my Aunt "In law" had
DSL, so I managed to sneak a few injections.
Cheers,
- Ole
Alex Karasulu wrote:
> Hi Ole,
>
> Looks like you got some good advice already. Let me just add one more
> suggestion
> while you're looking into creating a schema. Sometimes you'll find
> that the
> attributeTypes and objectClasses you're looking for are already
> defined in published
> schemas.
>
> For example for users you might want to take a look at something like
> inetOrgPerson etc.
>
> Second I suppose you're thinking of staying bleeding edge by using 1.5
> rather than using
> 1.0. I'd recommend this. And if so then merely adding the schema
> description entry for
> the objectClass in the ou=schema partition in the appropriate place
> should work. The schema
> is dynamic in 1.5 but I guess Emmanuel and Stephan already pointed
> this out.
>
> I will try to back read this thread. As you can imagine I have a lot
> to catch up on since
> I've been on vacation fishing all week :D. Yeah I don't miss LDAP he he.
>
> Regards,
> Alex
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
> 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
>
>
>
>
>
>
| |
| Alex Karasulu 2007-03-29, 1:11 am |
| Hi Ole,
On 3/28/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hey Alex,
>
> Yes - I think we're getting warmer!
>
> Here's the thing. Suppose I want to store an object that has String
> members
>
> shoeSize
> weight
> height
> name
>
> etc.
>
> I probably have name on some ObjectClass already defined in ApacheDS.
>
> However I still want to duplicate name on a completely different
> ObjectClass.
No problem. Really it does not matter; you can create a new xyzName
attribute. Sometimes that's not so bad. Now I see that you want to
autogenerate a schema from the Class
metadata and creating the attributes for your objectClass with namespace
qualification might
be a good idea.
> The ObjectClass I want has a 1:1 correspondence with the Java Class I
> want to store.
> That way a simple convention can be used to store the object, and no
> configuration file
> or index searching is needed to include a preexisting ObjectClass that
> has the name attribute on it.
Yep I agree (now that I understand your motives more) just create all the
LDAP
metadata you need on the fly to establish the mapping.
> I guess I could create an index with all the LDAP attributeTypes and
> look to see whether a certain attribute
> already exists, and use it, but I think it's simpler just to create a
> brand new ObjectClass.
Nah don't bother.
> Which leads me to another question.
>
> Can ObjectClass names have periods or underscores in them
>
> For Instance there's inetOrgPerson?
>
> Could it be
> inet.org.person?
I think so.
> The reason I ask is because I want to create ObjectClasses on the fly
> that are namespaced.
Gotchya.
SNIP ...
Hope fishing was a blast. I'm sure you're really glad to out of the
Sun, blue clear water,
and cool breeze environment and be back in front of a monitor.
Hey I still have a few more days to go . It's not over yet.
Regards,
Alex
Alex Karasulu wrote:
> Hi Ole,
>
> Looks like you got some good advice already. Let me just add one more
> suggestion
> while you're looking into creating a schema. Sometimes you'll find
> that the
> attributeTypes and objectClasses you're looking for are already
> defined in published
> schemas.
>
> For example for users you might want to take a look at something like
> inetOrgPerson etc.
>
> Second I suppose you're thinking of staying bleeding edge by using 1.5
> rather than using
> 1.0. I'd recommend this. And if so then merely adding the schema
> description entry for
> the objectClass in the ou=schema partition in the appropriate place
> should work. The schema
> is dynamic in 1.5 but I guess Emmanuel and Stephan already pointed
> this out.
>
> I will try to back read this thread. As you can imagine I have a lot
> to catch up on since
> I've been on vacation fishing all week :D. Yeah I don't miss LDAP he he.
>
> Regards,
> Alex
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
> 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
>
>
>
>
>
>
| |
| Ole Ersoy 2007-03-29, 1:11 am |
| Ahhh - You are still out there - Lucky Dog!
Thanks for wading through all these "Books" while on vacation!
Man - You hit every nail right on the head, so I'm just going to write
at the
top of this mail.
I was just about to hit send on another mail, and then I saw you replied
to this one.
Anyways I'll send the other one too, just in case it helps others
following the discussion,
but my only question now is
how do I create an ObjectClass on the fly before storing a (Java Class
instance)?
On the wiki here:
http://cwiki.apache.org/confluence/...system+Redesign
It says:
The new design will enable dynamic yet persistent updates to schema
elements within the server.
So how do I do it using a JNDI Context?
I need something like:
ObjectClass objectClass = LDAPFactory.createObjectClass();
objectClass.setName(myJavaObjectInstance.class.getFullyQualifiedName()
); //Sets the name of the object class to the fully qualified name of
the Java class
ObjectClassAttribute objectClassNameAttribute =
LDAPFactory.createObjectClassAttribute();
objectClassNameAttribute.setName("name");
objectClassNameAttribute.setContainer(objectClass);
etc.
then
ctx.storeObjectClass(objectClass);
Does that make any sense?
Thanks again!
- Ole
Alex Karasulu wrote:
> Hi Ole,
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
> Hey Alex,
>
> Yes - I think we're getting warmer!
>
> Here's the thing. Suppose I want to store an object that has
> String members
>
> shoeSize
> weight
> height
> name
>
> etc.
>
> I probably have name on some ObjectClass already defined in ApacheDS.
>
> However I still want to duplicate name on a completely different
> ObjectClass.
>
>
> No problem. Really it does not matter; you can create a new xyzName
> attribute. Sometimes that's not so bad. Now I see that you want to
> autogenerate a schema from the Class
> metadata and creating the attributes for your objectClass with
> namespace qualification might
> be a good idea.
>
>
>
> The ObjectClass I want has a 1:1 correspondence with the Java Class I
> want to store.
> That way a simple convention can be used to store the object, and no
> configuration file
> or index searching is needed to include a preexisting ObjectClass that
> has the name attribute on it.
>
>
> Yep I agree (now that I understand your motives more) just create all
> the LDAP
> metadata you need on the fly to establish the mapping.
>
>
>
> I guess I could create an index with all the LDAP attributeTypes and
> look to see whether a certain attribute
> already exists, and use it, but I think it's simpler just to create a
> brand new ObjectClass.
>
>
> Nah don't bother.
>
>
>
> Which leads me to another question.
>
> Can ObjectClass names have periods or underscores in them
>
> For Instance there's inetOrgPerson?
>
> Could it be
> inet.org.person?
>
>
> I think so.
>
>
>
> The reason I ask is because I want to create ObjectClasses on the fly
> that are namespaced.
>
>
> Gotchya.
>
> SNIP ...
>
> Hope fishing was a blast. I'm sure you're really glad to out of the
> Sun, blue clear water,
> and cool breeze environment and be back in front of a monitor.
>
> Hey I still have a few more days to go . It's not over yet.
>
> Regards,
> Alex
>
> Alex Karasulu wrote:
> he he.
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> table
> entry,
>
>
>
| |
| Alex Karasulu 2007-03-29, 1:11 am |
| Ole,
On 3/28/07, Ole Ersoy <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Ahhh - You are still out there - Lucky Dog!
Yeah baby!
> Thanks for wading through all these "Books" while on vacation!
NP.
SNIP ...
> how do I create an ObjectClass on the fly before storing a (Java Class
> instance)?
Ahh that's way easy now. You're timing is great ... you would never have
been
able to do this with 1.0 without a restart which blows.
Anyways there's a special schema partition: ou=schema. Under that context
are a bunch of schema names like ..
cn=nis
cn=inetorgperson
cn=blah blah blan
Under these are container ou's that each store various schema entities for
that schema such as attributeTypes, syntaxes, objectClasses etc. I just
realized that if you read that document on the schema subsystem redesign you
can save me some typing brotha man .
So basically you can create your own schema object for the namespace. Then
under that schema object create teh containers. Then create the objects
according to that redesign document.
You basically create entries with the createSubcontext command and that
document tells you what those metadata entries describing schema objects
looks like in terms of the attributes they need to contain. It's pretty
simple stuff. If you create something that is not allowed or incorrect the
server will let you know.
> On the wiki here:
>
> http://cwiki.apache.org/confluence/...system+Redesign
Yeah this is the doco to read.
> It says:
> The new design will enable dynamic yet persistent updates to schema
> elements within the server.
yep.
> So how do I do it using a JNDI Context?
Easy just use JNDI to create objects. Take a look at the test classes we
have in the repository for testing the new dynamic schema capabilities.
It's got JNDI code for doing this that you can adapt to your needs. Here's
a link to one:
https://svn.apache.org/repos/asf/di...ndlerITest.java
Take a look at the testAddObjectClass() method. That should have the logic
in there that you
need to create a new objectClass in a schema in the server.
SNIP ...
HTH,
Alex
Alex Karasulu wrote:
> Hi Ole,
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto: ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> wrote:
>
> Hey Alex,
>
> Yes - I think we're getting warmer!
>
> Here's the thing. Suppose I want to store an object that has
> String members
>
> shoeSize
> weight
> height
> name
>
> etc.
>
> I probably have name on some ObjectClass already defined in ApacheDS.
>
> However I still want to duplicate name on a completely different
> ObjectClass.
>
>
> No problem. Really it does not matter; you can create a new xyzName
> attribute. Sometimes that's not so bad. Now I see that you want to
> autogenerate a schema from the Class
> metadata and creating the attributes for your objectClass with
> namespace qualification might
> be a good idea.
>
>
>
> The ObjectClass I want has a 1:1 correspondence with the Java Class I
> want to store.
> That way a simple convention can be used to store the object, and no
> configuration file
> or index searching is needed to include a preexisting ObjectClass that
> has the name attribute on it.
>
>
> Yep I agree (now that I understand your motives more) just create all
> the LDAP
> metadata you need on the fly to establish the mapping.
>
>
>
> I guess I could create an index with all the LDAP attributeTypes and
> look to see whether a certain attribute
> already exists, and use it, but I think it's simpler just to create a
> brand new ObjectClass.
>
>
> Nah don't bother.
>
>
>
> Which leads me to another question.
>
> Can ObjectClass names have periods or underscores in them
>
> For Instance there's inetOrgPerson?
>
> Could it be
> inet.org.person?
>
>
> I think so.
>
>
>
> The reason I ask is because I want to create ObjectClasses on the fly
> that are namespaced.
>
>
> Gotchya.
>
> SNIP ...
>
> Hope fishing was a blast. I'm sure you're really glad to out of the
> Sun, blue clear water,
> and cool breeze environment and be back in front of a monitor.
>
> Hey I still have a few more days to go . It's not over yet.
>
> Regards,
> Alex
>
> Alex Karasulu wrote:
> he he.
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
[vbcol=seagreen]
> table
> entry,
>
>
>
| |
| Ole Ersoy 2007-03-29, 1:11 pm |
| Awesome!!
I'm going to start playing right now.
Yeeehah!!
Thanks,
Ole
Alex Karasulu wrote:
> Ole,
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote:
>
> Ahhh - You are still out there - Lucky Dog!
>
>
> Yeah baby!
>
>
>
> Thanks for wading through all these "Books" while on vacation!
>
>
> NP.
>
>
> SNIP ...
>
>
>
>
> how do I create an ObjectClass on the fly before storing a (Java Class
> instance)?
>
>
> Ahh that's way easy now. You're timing is great ... you would never
> have been
> able to do this with 1.0 without a restart which blows.
>
> Anyways there's a special schema partition: ou=schema. Under that
> context are a bunch of schema names like ..
>
> cn=nis
> cn=inetorgperson
> cn=blah blah blan
>
> Under these are container ou's that each store various schema entities
> for that schema such as attributeTypes, syntaxes, objectClasses etc.
> I just realized that if you read that document on the schema subsystem
> redesign you can save me some typing brotha man .
>
> So basically you can create your own schema object for the namespace.
> Then under that schema object create teh containers. Then create the
> objects according to that redesign document.
>
> You basically create entries with the createSubcontext command and
> that document tells you what those metadata entries describing schema
> objects looks like in terms of the attributes they need to contain.
> It's pretty simple stuff. If you create something that is not allowed
> or incorrect the server will let you know.
>
>
>
> On the wiki here:
> http://cwiki.apache.org/confluence/...system+Redesign
>
>
> Yeah this is the doco to read.
>
>
>
> It says:
> The new design will enable dynamic yet persistent updates to schema
> elements within the server.
>
>
> yep.
>
>
>
> So how do I do it using a JNDI Context?
>
>
> Easy just use JNDI to create objects. Take a look at the test classes
> we have in the repository for testing the new dynamic schema
> capabilities. It's got JNDI code for doing this that you can adapt to
> your needs. Here's a link to one:
>
> https://svn.apache.org/repos/asf/di...ndlerITest.java
> <https://svn.apache.org/repos/asf/di...ndlerITest.java>
>
> Take a look at the testAddObjectClass() method. That should have the
> logic in there that you
> need to create a new objectClass in a schema in the server.
>
> SNIP ...
>
> HTH,
> Alex
>
> Alex Karasulu wrote:
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ApacheDS.
> Class I
> and no
> ObjectClass that
> create a
> the fly
> more
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org><mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>>>> wrote:
> thing?
> any
> will be
>
>
>
| |
| Ole Ersoy 2007-03-29, 1:11 pm |
| I'm just sending out some "Verification" questions as I'm going along
doing the design guide.
One recipe is for creating an ObjectClass with a class's fully qualified
name.
I think we just do this:
Attribute objectClass = new AttributeImpl(
SystemSchemaConstants.OBJECT_CLASS_AT, class.getFullyQualifiedName() );
oc.add( MetaSchemaConstants.META_TOP_OC );
oc.add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
Then we just add the objectClass attribute to a list of attributes
attrs.put( oc );
Then we add the attributes that are (Non-Complex-Object-Reference)
members of the
class as the attributes as well.
So for instance if the class has a String member "userName",
that is required, we add it like this:
attrs.put( MetaSchemaConstants.M_MUST_AT, "userName" );
Then at last we put it in ADS like this:
super.schemaRoot.createSubcontext( dn, attrs );
Sound about right?
Thanks,
- Ole
Alex Karasulu wrote:
> Ole,
>
> On 3/28/07, *Ole Ersoy* <ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote:
>
> Ahhh - You are still out there - Lucky Dog!
>
>
> Yeah baby!
>
>
>
> Thanks for wading through all these "Books" while on vacation!
>
>
> NP.
>
>
> SNIP ...
>
>
>
>
> how do I create an ObjectClass on the fly before storing a (Java Class
> instance)?
>
>
> Ahh that's way easy now. You're timing is great ... you would never
> have been
> able to do this with 1.0 without a restart which blows.
>
> Anyways there's a special schema partition: ou=schema. Under that
> context are a bunch of schema names like ..
>
> cn=nis
> cn=inetorgperson
> cn=blah blah blan
>
> Under these are container ou's that each store various schema entities
> for that schema such as attributeTypes, syntaxes, objectClasses etc.
> I just realized that if you read that document on the schema subsystem
> redesign you can save me some typing brotha man .
>
> So basically you can create your own schema object for the namespace.
> Then under that schema object create teh containers. Then create the
> objects according to that redesign document.
>
> You basically create entries with the createSubcontext command and
> that document tells you what those metadata entries describing schema
> objects looks like in terms of the attributes they need to contain.
> It's pretty simple stuff. If you create something that is not allowed
> or incorrect the server will let you know.
>
>
>
> On the wiki here:
> http://cwiki.apache.org/confluence/...system+Redesign
>
>
> Yeah this is the doco to read.
>
>
>
> It says:
> The new design will enable dynamic yet persistent updates to schema
> elements within the server.
>
>
> yep.
>
>
>
> So how do I do it using a JNDI Context?
>
>
> Easy just use JNDI to create objects. Take a look at the test classes
> we have in the repository for testing the new dynamic schema
> capabilities. It's got JNDI code for doing this that you can adapt to
> your needs. Here's a link to one:
>
> https://svn.apache.org/repos/asf/di...ndlerITest.java
> <https://svn.apache.org/repos/asf/di...ndlerITest.java>
>
> Take a look at the testAddObjectClass() method. That should have the
> logic in there that you
> need to create a new objectClass in a schema in the server.
>
> SNIP ...
>
> HTH,
> Alex
>
> Alex Karasulu wrote:
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ApacheDS.
> Class I
> and no
> ObjectClass that
> create a
> the fly
> more
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org><mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> <mailto:ole.ersoy-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>>>> wrote:
> thing?
> any
> will be
>
>
>
|
|
|
|
|