directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r1562004 - /directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java
Date Tue, 28 Jan 2014 08:43:42 GMT
Author: kayyagari
Date: Tue Jan 28 08:43:41 2014
New Revision: 1562004

URL: http://svn.apache.org/r1562004
Log:
sort based on the count of RDNs instead of relying on checks with Dn.isAncestorOf() (these
checks were not producing the correct sort order always)

Modified:
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java?rev=1562004&r1=1562003&r2=1562004&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java
(original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/comparators/DnComparator.java
Tue Jan 28 08:43:41 2014
@@ -41,7 +41,6 @@ public class DnComparator extends LdapCo
     /** A reference to the schema manager */
     private SchemaManager schemaManager;
 
-
     public DnComparator( String oid )
     {
         super( oid );
@@ -67,19 +66,22 @@ public class DnComparator extends LdapCo
             return -1;
         }
 
+        int dn0Size = dn0.getRdns().size();
+        int dn1Size = dn1.getRdns().size();
+        
         // check the equality first, cause
         // when both DNs are equal checking isAncestorOf() returns true
         if ( dn0.equals( dn1 ) )
         {
             return 0;
         }
-        else if( dn0.isAncestorOf( dn1 ) )
+        else if ( dn0Size > dn1Size )
         {
-            return 1;
+            return -1;
         }
-        else if( dn1.isAncestorOf( dn0 ) )
+        else if ( dn1Size > dn0Size )
         {
-            return -1;
+            return 1;
         }
 
         return dn0.getNormName().compareTo( dn1.getNormName() );



Mime
View raw message