directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seman...@apache.org
Subject svn commit: r1690876 - in /directory/shared/trunk/ldap: client/api/src/main/java/org/apache/directory/ldap/client/api/ model/src/main/java/org/apache/directory/api/ldap/model/schema/ schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/
Date Tue, 14 Jul 2015 08:41:53 GMT
Author: semancik
Date: Tue Jul 14 08:41:52 2015
New Revision: 1690876

URL: http://svn.apache.org/r1690876
Log:
Modifications needed to support 389 Directory Server in API

Modified:
    directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaManager.java
    directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java

Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1690876&r1=1690875&r2=1690876&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
(original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
Tue Jul 14 08:41:52 2015
@@ -3474,6 +3474,19 @@ public class LdapNetworkConnection exten
 
         Attribute attr = rootDse.get( SchemaConstants.SUPPORTED_CONTROL_AT );
 
+        if (attr == null) 
+        {
+            // Unlikely. Perhaps the server does not respond properly to "+" attribute query
+            // (such as 389ds server). So let's try again and let's be more explicit.
+            fetchRootDSE( SchemaConstants.ALL_USER_ATTRIBUTES, 
+                SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES, SchemaConstants.SUPPORTED_CONTROL_AT
);
+            attr = rootDse.get( SchemaConstants.SUPPORTED_CONTROL_AT );
+            if (attr == null) 
+            {
+                return supportedControls;
+            }
+        }
+        
         for ( Value<?> value : attr )
         {
             supportedControls.add( value.getString() );
@@ -3609,17 +3622,25 @@ public class LdapNetworkConnection exten
      * fetches the rootDSE from the server
      * @throws LdapException
      */
-    private void fetchRootDSE() throws LdapException
+    private void fetchRootDSE(String... explicitAttributes) throws LdapException
     {
         EntryCursor cursor = null;
 
+        String[] attributes = explicitAttributes;
+        if (attributes.length == 0) {
+            attributes = new String[] { SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES
};
+        }
+        
         try
         {
             cursor = search( "", LdapConstants.OBJECT_CLASS_STAR, SearchScope.OBJECT,
-                SchemaConstants.ALL_USER_ATTRIBUTES,
-                SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES );
-            cursor.next();
-            rootDse = cursor.get();
+            		attributes );
+            if ( cursor.next() ) 
+            {
+                rootDse = cursor.get();
+            } else {
+                throw new LdapException( "Search for root DSE returned no entry" );
+            }
         }
         catch ( Exception e )
         {

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaManager.java?rev=1690876&r1=1690875&r2=1690876&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaManager.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/SchemaManager.java
Tue Jul 14 08:41:52 2015
@@ -405,8 +405,22 @@ public interface SchemaManager
      */
     boolean isDisabled( Schema schema );
 
+    /**
+     * Tells if the SchemaManager is permissive or if it must be checked
+     * against inconsistencies.
+     *
+     * @return True if SchemaObjects can be added even if they break the consistency
+     */
+    boolean isRelaxed();
 
     /**
+     * Tells if the SchemaManager is strict.
+     *
+     * @return True if SchemaObjects cannot be added if they break the consistency
+     */
+    boolean isStrict();
+    
+    /**
      * Check that the Schemas are consistent regarding the current Registries.
      * 
      * @param schemas The schemas to check

Modified: directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java?rev=1690876&r1=1690875&r2=1690876&view=diff
==============================================================================
--- directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
(original)
+++ directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/api/ldap/schema/loader/SchemaEntityFactory.java
Tue Jul 14 08:41:52 2015
@@ -101,7 +101,7 @@ public class SchemaEntityFactory impleme
      * Get an OID from an entry. Handles the bad cases (null OID,
      * not a valid OID, ...)
      */
-    private String getOid( Entry entry, String objectType ) throws LdapInvalidAttributeValueException
+    private String getOid( Entry entry, String objectType, boolean strict ) throws LdapInvalidAttributeValueException
     {
         // The OID
         Attribute mOid = entry.get( MetaSchemaConstants.M_OID_AT );
@@ -115,7 +115,7 @@ public class SchemaEntityFactory impleme
 
         String oid = mOid.getString();
 
-        if ( !Oid.isOid( oid ) )
+        if ( strict && !Oid.isOid( oid ) )
         {
             String msg = I18n.err( I18n.ERR_10006, oid );
             LOG.warn( msg );
@@ -306,7 +306,7 @@ public class SchemaEntityFactory impleme
         checkEntry( entry, SchemaConstants.SYNTAX_CHECKER );
 
         // The SyntaxChecker OID
-        String oid = getOid( entry, SchemaConstants.SYNTAX_CHECKER );
+        String oid = getOid( entry, SchemaConstants.SYNTAX_CHECKER, schemaManager.isStrict()
);
 
         // Get the schema
         if ( !schemaManager.isSchemaLoaded( schemaName ) )
@@ -495,7 +495,7 @@ public class SchemaEntityFactory impleme
         checkEntry( entry, SchemaConstants.COMPARATOR );
 
         // The Comparator OID
-        String oid = getOid( entry, SchemaConstants.COMPARATOR );
+        String oid = getOid( entry, SchemaConstants.COMPARATOR, schemaManager.isStrict()
);
 
         // Get the schema
         if ( !schemaManager.isSchemaLoaded( schemaName ) )
@@ -626,7 +626,7 @@ public class SchemaEntityFactory impleme
         checkEntry( entry, SchemaConstants.NORMALIZER );
 
         // The Normalizer OID
-        String oid = getOid( entry, SchemaConstants.NORMALIZER );
+        String oid = getOid( entry, SchemaConstants.NORMALIZER, schemaManager.isStrict()
);
 
         // Get the schema
         if ( !schemaManager.isSchemaLoaded( schemaName ) )
@@ -682,7 +682,7 @@ public class SchemaEntityFactory impleme
         checkEntry( entry, SchemaConstants.SYNTAX );
 
         // The Syntax OID
-        String oid = getOid( entry, SchemaConstants.SYNTAX );
+        String oid = getOid( entry, SchemaConstants.SYNTAX, schemaManager.isStrict() );
 
         // Get the schema
         if ( !schemaManager.isSchemaLoaded( schemaName ) )
@@ -724,7 +724,7 @@ public class SchemaEntityFactory impleme
         checkEntry( entry, SchemaConstants.MATCHING_RULE );
 
         // The MatchingRule OID
-        String oid = getOid( entry, SchemaConstants.MATCHING_RULE );
+        String oid = getOid( entry, SchemaConstants.MATCHING_RULE, schemaManager.isStrict()
);
 
         // Get the schema
         if ( !schemaManager.isSchemaLoaded( schemaName ) )
@@ -795,7 +795,7 @@ public class SchemaEntityFactory impleme
         checkEntry( entry, SchemaConstants.OBJECT_CLASS );
 
         // The ObjectClass OID
-        String oid = getOid( entry, SchemaConstants.OBJECT_CLASS );
+        String oid = getOid( entry, SchemaConstants.OBJECT_CLASS, schemaManager.isStrict()
);
 
         // Get the schema
         if ( !schemaManager.isSchemaLoaded( schemaName ) )
@@ -870,7 +870,7 @@ public class SchemaEntityFactory impleme
         checkEntry( entry, SchemaConstants.ATTRIBUTE_TYPE );
 
         // The AttributeType OID
-        String oid = getOid( entry, SchemaConstants.ATTRIBUTE_TYPE );
+        String oid = getOid( entry, SchemaConstants.ATTRIBUTE_TYPE, schemaManager.isStrict()
);
 
         // Get the schema
         if ( !schemaManager.isSchemaLoaded( schemaName ) )



Mime
View raw message