You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Emmanuel Lecharny <el...@gmail.com> on 2007/04/12 18:30:16 UTC

SyntaxCheckers implementation

Hi,

Alex, I have implemented the piece of code supposed to check the attribute's
values syntax in SchemaService. This was really a piece of cake, up to the
point I realized that the SC weren't available in the registries. Here is a
fragment of the code :

    /**
     * Check the entry attributes syntax, using the syntaxCheckers
     */
    private void assertSyntaxes( Attributes entry ) throws NamingException
    {
        NamingEnumeration attributes = entry.getAll();

        // First, loop on all attributes
        while ( attributes.hasMoreElements() )
        {
            Attribute attribute = ( Attribute ) attributes.nextElement();

            AttributeType attributeType =
registries.getAttributeTypeRegistry().lookup( attribute.getID() );
            SyntaxChecker syntaxChecker =  attributeType.getSyntax
().getSyntaxChecker();

            if ( syntaxChecker instanceof AcceptAllSyntaxChecker )
            {
                // This is a speedup : no need to check the syntax of any
value
                // if all the sytanxes are accepted...
                continue;
            }
...

Here, all the SC are instances of AcceptAllSyntaxChecker. I guess that there
is something missing during the schema initialization, but I will need your
help, because you know this piece of code, and I don't (diving into it may
cost me hours ...)

I have committed the code as is, so you can perfectly try it and set a BP on
this method to see if I did something wrong. I may have missed something,
too (is the way I get the SC correct ???). The server is still running oc,
as all the SC are accepting every value.

Thanks !

-- 
Cordialement,
Emmanuel Lécharny
www.iktek.com

Re: SyntaxCheckers implementation

Posted by Alex Karasulu <ak...@apache.org>.
Yeah you basically have to look into the SyntaxCheckerProducers generated
for various schemas and remove the code that adds an accept all syntax
checker replacing it with one that correctly implements the syntax.

These objects are automatically registered into the registries.  As
producers produce their objects the bootstrap schema subsystem will build
the registries.  After adding these guys to the registries a maven run
should be used to rebuild the schema partition.  I think this will basically
make sure the proper syntax checker code is referrenced for the various
syntaxCheckers.

Alex

On 4/12/07, Emmanuel Lecharny <el...@gmail.com> wrote:
>
> Hi,
>
> Alex, I have implemented the piece of code supposed to check the
> attribute's values syntax in SchemaService. This was really a piece of cake,
> up to the point I realized that the SC weren't available in the registries.
> Here is a fragment of the code :
>
>     /**
>      * Check the entry attributes syntax, using the syntaxCheckers
>      */
>     private void assertSyntaxes( Attributes entry ) throws NamingException
>     {
>         NamingEnumeration attributes = entry.getAll();
>
>         // First, loop on all attributes
>         while ( attributes.hasMoreElements() )
>         {
>             Attribute attribute = ( Attribute ) attributes.nextElement();
>
>             AttributeType attributeType =
> registries.getAttributeTypeRegistry().lookup( attribute.getID() );
>             SyntaxChecker syntaxChecker =  attributeType.getSyntax
> ().getSyntaxChecker();
>
>             if ( syntaxChecker instanceof AcceptAllSyntaxChecker )
>             {
>                 // This is a speedup : no need to check the syntax of any
> value
>                 // if all the sytanxes are accepted...
>                 continue;
>             }
> ...
>
> Here, all the SC are instances of AcceptAllSyntaxChecker. I guess that
> there is something missing during the schema initialization, but I will need
> your help, because you know this piece of code, and I don't (diving into it
> may cost me hours ...)
>
> I have committed the code as is, so you can perfectly try it and set a BP
> on this method to see if I did something wrong. I may have missed something,
> too (is the way I get the SC correct ???). The server is still running oc,
> as all the SC are accepting every value.
>
> Thanks !
>
> --
> Cordialement,
> Emmanuel Lécharny
> www.iktek.com