directory-api mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lécharny <elecha...@gmail.com>
Subject Fwd: Re: [LDAP API] Schema aware connection
Date Tue, 15 Sep 2015 12:39:11 GMT
Forwarding this mail who deserves to be sent to API@directory.a.o...



Le 15/09/15 12:03, Emmanuel Lécharny a écrit :
> Hi,
>
> Radovan has added some way to support schemas that have some slight
> differences with the RFC, using the quirkmode flag. If you are using
> tehe NetworkLdapConnection, it works this way :
>
>                     SchemaLoader schemaLoader = new DefaultSchemaLoader(
> ldapConnection, true );
>                     ldapConnection.loadSchema( schemaLoader );
>
> Thats fine, except if you have declared your ldapConnection thsi way :
>
>                     LdapConnection ldapConnection = new
> LdapNetworkConnection( server.getServerName(), server.getPort() );
>
> because the LdapConnection interface does not expose the loadSchema(
> schemaLoader ) method.
>
> I suggest we expose it.
>
> I also think we should extend the ldapConnection.loadSchema() method, in
> order to spare the users from declaring a SchemaLoader on their own.
> That would make the code looks like :
>
>
>                     ldapConnection.loadSchemaRelaxed();
>
> which would replace
>
>                     SchemaLoader schemaLoader = new DefaultSchemaLoader(
> ldapConnection, true );
>                     ldapConnection.loadSchema( schemaLoader );

It's a bit more complex that just using the quirkmode (which just relax
the schema syntax). Sometime, we want to accept some inconsistencies in
the schema itself. The relaxed mode is there to accept such schema, but
it's not exposed.

Typically, the loadSchema() methods starts with :


    public void loadSchema( SchemaLoader loader ) throws LdapException
    {
        try
        {
            SchemaManager tmp = new DefaultSchemaManager( loader );
           
            tmp.loadAllEnabled();

            if ( !tmp.getErrors().isEmpty() )
            {
                String msg = "there are errors while loading the schema";
                LOG.error( msg + " {}", tmp.getErrors() );
                throw new LdapException( msg );
            }
            ...

which creates a SchemaManager in strict mode. Obviously, the
tmp.loadAllEnabled() will fail. We should propagate the 'relaxed' flag
down to the SchemaManager.





Mime
View raw message