directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1051970 - in /directory/shared/branches/shared-AP/ldap/src: main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java
Date Wed, 22 Dec 2010 16:21:34 GMT
Author: elecharny
Date: Wed Dec 22 16:21:34 2010
New Revision: 1051970

URL: http://svn.apache.org/viewvc?rev=1051970&view=rev
Log:
The getParentWithElement should return the element, not the DN

Modified:
    directory/shared/branches/shared-AP/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
    directory/shared/branches/shared-AP/ldap/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java

Modified: directory/shared/branches/shared-AP/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-AP/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java?rev=1051970&r1=1051969&r2=1051970&view=diff
==============================================================================
--- directory/shared/branches/shared-AP/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
(original)
+++ directory/shared/branches/shared-AP/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
Wed Dec 22 16:21:34 2010
@@ -791,12 +791,12 @@ public class DnNode<N> implements Clonea
      * @param dn the normalized distinguished name to resolve to a parent
      * @return the Node associated with the normalized dn
      */
-    public DN getParentWithElement( DN dn )
+    public N getParentWithElement( DN dn )
     {
         List<RDN> rdns = dn.getRdns();
 
         DnNode<N> currentNode = this;
-        int pos = 0;
+        N element = null;
 
         // Iterate through all the RDN until we find the associated partition
         for ( int i = rdns.size() - 1; i >= 1; i-- )
@@ -814,7 +814,7 @@ public class DnNode<N> implements Clonea
 
                 if ( currentNode.hasElement() )
                 {
-                    pos = i;
+                    element = currentNode.getElement();
                 }
 
                 parent = currentNode;
@@ -825,12 +825,7 @@ public class DnNode<N> implements Clonea
             }
         }
 
-        if ( pos == 0 )
-        {
-            return DN.EMPTY_DN;
-        }
-        
-        return dn.getPrefix( dn.size() - pos );
+        return element;
     }
 
     

Modified: directory/shared/branches/shared-AP/ldap/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-AP/ldap/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java?rev=1051970&r1=1051969&r2=1051970&view=diff
==============================================================================
--- directory/shared/branches/shared-AP/ldap/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java
(original)
+++ directory/shared/branches/shared-AP/ldap/src/test/java/org/apache/directory/shared/ldap/util/tree/TestDnNode.java
Wed Dec 22 16:21:34 2010
@@ -836,6 +836,6 @@ public class TestDnNode
         assertEquals( org, dnLookupTree.getParentWithElement( dn1 ) );
         assertEquals( org, dnLookupTree.getParentWithElement( apache ) );
         assertEquals( dn1, dnLookupTree.getParentWithElement( test ) );
-        assertEquals( DN.EMPTY_DN, dnLookupTree.getParentWithElement( org ) );
+        assertNull( dnLookupTree.getParentWithElement( org ) );
     }
 }



Mime
View raw message