Return-Path: Delivered-To: apmail-directory-dev-archive@www.apache.org Received: (qmail 9309 invoked from network); 28 Mar 2007 23:34:22 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 28 Mar 2007 23:34:22 -0000 Received: (qmail 1016 invoked by uid 500); 28 Mar 2007 23:34:29 -0000 Delivered-To: apmail-directory-dev-archive@directory.apache.org Received: (qmail 987 invoked by uid 500); 28 Mar 2007 23:34:29 -0000 Mailing-List: contact dev-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Apache Directory Developers List" Delivered-To: mailing list dev@directory.apache.org Received: (qmail 976 invoked by uid 99); 28 Mar 2007 23:34:29 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Mar 2007 16:34:29 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of ole.ersoy@gmail.com designates 64.233.166.182 as permitted sender) Received: from [64.233.166.182] (HELO py-out-1112.google.com) (64.233.166.182) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 28 Mar 2007 16:34:21 -0700 Received: by py-out-1112.google.com with SMTP id a29so6316pyi for ; Wed, 28 Mar 2007 16:34:00 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=ERFkHvyZchgDBZjx8ZMXB67ea8/2D0NLS0k6AcpwGNPIBdVg7T7aXBVxWM2Nl8Xtjl1BGVaAgVqBbVdsIsNxU0zR2vbE8kZv6WC8D+Oh+yy8SBpeZy9iB/3geRE60PVhLTbuC5be3piR7McGfsu11JuLD/Rrq7GJ2SzGB1jhlZ0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=Kb5lxQA2dbInmriMGC5uVUiOSga4SqnPYjsSoWh6F3zaRO/uoRUEmpaytYk19Hw9SdWL+beavEw2SvPZE8TWA7TWAdFL85u7M303Cfr6QUB7jMixjPp23jGVzknZo0P70hBXwc1bzYxj2tidpW1w9eZrrjwgJe9DlTgSR3Lg7tg= Received: by 10.35.82.16 with SMTP id j16mr58792pyl.1175124840530; Wed, 28 Mar 2007 16:34:00 -0700 (PDT) Received: from ?192.168.1.24? ( [24.13.179.233]) by mx.google.com with ESMTP id a70sm35058pye.2007.03.28.16.33.59; Wed, 28 Mar 2007 16:33:59 -0700 (PDT) Message-ID: <460AFAC6.5060901@gmail.com> Date: Wed, 28 Mar 2007 18:31:18 -0500 From: Ole Ersoy User-Agent: Thunderbird 1.5.0.10 (X11/20070302) MIME-Version: 1.0 To: Apache Directory Developers List Subject: Re: [Schema] How do I write a new ObjectClass to ApacheDS References: <460AC99F.5030600@gmail.com> <460AD11F.6080103@gmail.com> <460ADFD2.1060402@gmail.com> <460AE60D.4090103@gmail.com> In-Reply-To: <460AE60D.4090103@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org 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 : > >> 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. 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? > >> >> 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 :) > Yeah - That sounds like it :-) >> >> 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 ... > Does it make more sense now? >> >> 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. > 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 > >> >> 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 >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >> >> > >