directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: [DAS to LDAP Type Mapping] Am I thinking about this right?
Date Mon, 02 Apr 2007 22:42:10 GMT
Ole Ersoy a écrit :

> Hey Guys,
>
> Just wanted to see whether I'm thinking about this right.
> I want to store a DataObject in ADS.
> But before I can store it, I need to define its Schema.

Yes. And this will be tricky :)

>
> <snip/>
> So suppose I have a DataObject named
> dataObject that has a java type (Class) SomeClass
> with the following members.
>
> Member                  Java Type
> numberInt             : Integer
> someCharacterSequence : String

You already have :
Integer,
Boolean,
OctetString (= byte[]),
IA5 String,
Directory String,

all defined in 
http://cwiki.apache.org/confluence/display/DIRxSRVx11/Schema+Checking

>
> In order to store dataObject in ADS, I think I need
> to do the following:
>
> 1) Create the Syntaxes that correspond
>    to the Java Types Integer and String
>    (It's probably possible to use some already
>     defined syntax, like "Directory String", but
>     when I look up the syntax of an attribute,
>     I would like it to be named for example
>     java.lang.String so I don't have to do
>     type conversion in the DAS).

You can perfectly do that. AttributeType inheritance is allowed.

> 2) Create the attributeTypes numberInt
>    and someCharacterSequence and associate
>    them with their syntax.

idem.

> 3) Create the ObjectClass SomeClass
>    and add the attributeTypes
>    numberInt and someCharacterSequence

Not a pb.

>
> Then when all this is defined, I can go ahead
> and create an entry for dataObject containing
> its ObjectClass, SomeClass, and then add the values
> for the members numberInt and someCharacterSequence.
>
>
> Incidentally I'm also thinking that numberInt and someCharacterSequence
> need to be namespaced in order to
> avoid collisions when serializing another DataObject
> of a different type that also has a member
> someCharacterSequence.

Here, you will have to store 3 infos in 2 places :
1) The java member name
2) The member attribute
3) The member value

for instance,

package org.apache.test;

class MyClass {
java.lang.String myString = "my string";

The only way to do that will be to declare a new attribute :
AttributeType : ( 1.2.3.4.5 NAME "org-apache-test-MyClass-myString"
    DESC "myString member for class MyClass in package org.apache.test"
    SYNTAX "<IA5 String OID>"
    SINGLE-VALUE
    NO-USER-MODIFICATION )
Two points :
1) you will have to define a new OID for each attributeType, and the 
name *must* be unique in the server
2) you will have to replace the '.' by a '-'. '$' are not accepted, only 
|a-zA-zZ0-9-;], and the first char must be {a-zA-Z]

Now, you inject this entry into the server, and you are done, you can 
store the third info, the value, into the attribute type you just created.

The question is "how do I inject the attribute typ einto ADS ???". See 
below.

>
> So there could be attributeTypes:
> com.example.someCharacterSequence
> org.example.someCharacterSequence
>
> Does that make sense?

The previous sample should clarify the idea, I think.

>
> I'm starting to research how to add the
> syntaxes and attributeTypes right now,
> but if anyone has some quick boiler plate
> code for me, please do send :-)

Just use the existing syntaxes. Now, to inject the previously defined 
attributetype, it's easy (well, kindof) :
you can dynamically modify the schema, using meta schema elements :
http://cwiki.apache.org/confluence/display/DIRxSRVx11/MetaSchema+schema. 
In our case, for the attribute type we defined above :

dn: m-name=org-apache-test-MyClass-myString,ou=schema
objectclass: meta-attributeType
objectclass: meta-top
objectclass: top
m-oid:  1.2.3.4.5
m-name: org-apache-test-MyClass-myString
m-description: myString member for class MyClass in package org.apache.tes
m-syntax: IA5String
m-singleValue: true
m-noUserModification: true # because a String is immutable !

This is the ldif format, but this can also be defined as an entry, using 
JNDI, with BasicAttributes() and BasicAttribute() for each elements.

I wish you good luck, because you are very ambitious, but I don't really 
see anything that can forbid you to succeed.

Emmanuel

Mime
View raw message