You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/01/27 11:46:34 UTC

svn commit: r1655004 - /directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java

Author: elecharny
Date: Tue Jan 27 10:46:34 2015
New Revision: 1655004

URL: http://svn.apache.org/r1655004
Log:
Added a generic way to load the schema from rootDSE even if it's not an ApacheDS server.

If it fails, we currently throw an exception, but there is room for adding some other implementation here.

Modified:
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java?rev=1655004&r1=1655003&r2=1655004&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/DefaultSchemaLoader.java Tue Jan 27 10:46:34 2015
@@ -153,7 +153,26 @@ public class DefaultSchemaLoader extends
                 }
                 else
                 {
-                    // TODO Handle schema loading on other LDAP servers
+                    try
+                    {
+                        // No matter what, first try to search the schema from the rootDSE
+                        // Getting the subSchemaSubEntry attribute
+                        Attribute subschemaSubentryAttribute = rootDse.get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT );
+
+                        if ( ( subschemaSubentryAttribute != null ) && ( subschemaSubentryAttribute.size() > 0 ) )
+                        {
+                            subschemaSubentryDn = new Dn( connection.getSchemaManager(),
+                                subschemaSubentryAttribute.getString() );
+
+                            loadSchemas();
+                        }
+                    }
+                    catch ( LdapException le )
+                    {
+                        // TODO : if we can't read the schema from the rootDSE, just try to read the 
+                        // schema from cn=schema
+                        throw le;
+                    }
                 }
             }
         }