directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r697766 - in /directory: apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnBranchNode.java
Date Mon, 22 Sep 2008 09:58:40 GMT
Author: elecharny
Date: Mon Sep 22 02:58:40 2008
New Revision: 697766

URL: http://svn.apache.org/viewvc?rev=697766&view=rev
Log:
Moved the Partition lookup code to the DnBranchNode class

Modified:
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnBranchNode.java

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java?rev=697766&r1=697765&r2=697766&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/partition/DefaultPartitionNexus.java
Mon Sep 22 02:58:40 2008
@@ -83,8 +83,6 @@
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.apache.directory.shared.ldap.util.tree.DnBranchNode;
-import org.apache.directory.shared.ldap.util.tree.DnLeafNode;
-import org.apache.directory.shared.ldap.util.tree.DnNode;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -97,7 +95,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -1059,44 +1056,7 @@
      */
     public Partition getPartition( LdapDN dn ) throws Exception
     {
-        Enumeration<String> rdns = dn.getAll();
-        
-        // This is synchronized so that we can't read the
-        // partitionList when it is modified.
-        synchronized ( partitionLookupTree )
-        {
-            DnNode<Partition> currentNode = partitionLookupTree;
-
-            // Iterate through all the RDN until we find the associated partition
-            while ( rdns.hasMoreElements() )
-            {
-                String rdn = rdns.nextElement();
-
-                if ( currentNode == null )
-                {
-                    break;
-                }
-
-                if ( currentNode instanceof DnLeafNode )
-                {
-                    return ( ( DnLeafNode<Partition> ) currentNode ).getElement();
-                }
-
-                DnBranchNode<Partition> currentBranch = ( DnBranchNode<Partition>
) currentNode;
-                
-                if ( currentBranch.contains( rdn ) )
-                {
-                    currentNode = currentBranch.getChild( rdn );
-                    
-                    if ( currentNode instanceof DnLeafNode )
-                    {
-                        return ( ( DnLeafNode<Partition> ) currentNode ).getElement();
-                    }
-                }
-            }
-        }
-        
-        throw new LdapNameNotFoundException( dn.getUpName() );
+        return partitionLookupTree.getElement( dn );
     }
 
 

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnBranchNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnBranchNode.java?rev=697766&r1=697765&r2=697766&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnBranchNode.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnBranchNode.java
Mon Sep 22 02:58:40 2008
@@ -194,15 +194,15 @@
      * @return the backend partition associated with the normalized dn
      * @throws Exception if the name cannot be resolved to a partition
      */
-    public N getElement( DnBranchNode<N> tree, LdapDN dn ) throws Exception
+    public N getElement( LdapDN dn ) throws Exception
     {
         Enumeration<String> rdns = dn.getAll();
         
         // This is synchronized so that we can't read the
         // partitionList when it is modified.
-        synchronized ( tree )
+        synchronized ( this )
         {
-            DnNode<N> currentNode = tree;
+            DnNode<N> currentNode = this;
 
             // Iterate through all the RDN until we find the associated partition
             while ( rdns.hasMoreElements() )



Mime
View raw message