directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alex Karasulu" <akaras...@apache.org>
Subject Re: [Schema] How do I write a new ObjectClass to ApacheDS
Date Thu, 29 Mar 2007 05:32:56 GMT
Ole,

On 3/28/07, Ole Ersoy <ole.ersoy@gmail.com> 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/display/DIRxSRVx11/Schema+Subsystem+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/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerITest.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@gmail.com
> <mailto: ole.ersoy@gmail.com>> 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@gmail.com
> <mailto:ole.ersoy@gmail.com>
> > <mailto:ole.ersoy@gmail.com <mailto:ole.ersoy@gmail.com>>> 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
> >
> >
> >
> >
> >
> >
>
>
>

Mime
View raw message