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.


Reply via email to