directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r926660 - in /directory: apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ shared/trunk/ldap/src/main/antlr/ shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/ shared/trunk/ldap/src/main/java/...
Date Tue, 23 Mar 2010 16:56:02 GMT
Author: elecharny
Date: Tue Mar 23 16:56:02 2010
New Revision: 926660

URL: http://svn.apache.org/viewvc?rev=926660&view=rev
Log:
o Removed the DN.getAll() method
o Fixed a class cast issue

Modified:
    directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
    directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
    directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnBranchNode.java
    directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java

Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java?rev=926660&r1=926659&r2=926660&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
(original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerDirContext.java
Tue Mar 23 16:56:02 2010
@@ -235,14 +235,7 @@ public abstract class ServerDirContext e
 
         try
         {
-            if ( name instanceof DN )
-            {
-                doModifyOperation( buildTarget( (DN)name ), newMods );
-            }
-            else
-            {
-                doModifyOperation( buildTarget( DN.fromName( name ) ), newMods );
-            }
+            doModifyOperation( buildTarget( DN.fromName( name ) ), newMods );
         }
         catch( Exception e )
         {
@@ -776,7 +769,7 @@ public abstract class ServerDirContext e
                 try
                 {
                     EntryFilteringCursor cursor = doSearchOperation( target, aliasDerefMode,
node, ctls );
-                    return new NamingEnumerationAdapter ( cursor ); 
+                    return new NamingEnumerationAdapter( cursor ); 
                 }
                 catch ( Exception e )
                 {

Modified: directory/shared/trunk/ldap/src/main/antlr/ACIItem.g
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/antlr/ACIItem.g?rev=926660&r1=926659&r2=926660&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/ACIItem.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/ACIItem.g Tue Mar 23 16:56:02 2010
@@ -52,6 +52,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.util.NoDuplicateKeysMap;
 import org.apache.directory.shared.ldap.util.OptionalComponentsMonitor;
 import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.name.RDN;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.constants.AuthenticationLevel;
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
@@ -501,11 +502,9 @@ attributeValue
             attributeTypeAndValueSetAsDn.normalize( oidsMap );
         }
         
-        Enumeration attributeTypeAndValueSet = attributeTypeAndValueSetAsDn.getAll();
-        
-        while ( attributeTypeAndValueSet.hasMoreElements() )
+        for ( RDN rdn :attributeTypeAndValueSetAsDn.getRdns() )
         {
-            attributeTypeAndValue = ( String ) attributeTypeAndValueSet.nextElement();
+            attributeTypeAndValue = rdn.getNormName();
             attributeType = NamespaceTools.getRdnAttribute( attributeTypeAndValue );
             attributeValue = NamespaceTools.getRdnValue( attributeTypeAndValue );
             attributeSet.add( new BasicAttribute( attributeType, attributeValue ) );

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java?rev=926660&r1=926659&r2=926660&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
(original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DN.java
Tue Mar 23 16:56:02 2010
@@ -821,45 +821,6 @@ public class DN implements Cloneable, Se
 
 
     /**
-     * @return The list of all the RDN for this DN, as Strings. This method
-     * retruns a User Provided form of each RDN, not a normalized form.
-     */
-    public Enumeration<String> getAll()
-    {
-        /*
-         * Note that by accessing the name component using the get() method on
-         * the name rather than get() on the list we are reading components from
-         * right to left with increasing index values. LdapName.get() does the
-         * index translation on m_list for us.
-         */
-        return new Enumeration<String>()
-        {
-            private int pos;
-
-
-            public boolean hasMoreElements()
-            {
-                return pos < rdns.size();
-            }
-
-
-            public String nextElement()
-            {
-                if ( pos >= rdns.size() )
-                {
-                    LOG.error( I18n.err( I18n.ERR_04205 ) );
-                    throw new NoSuchElementException();
-                }
-
-                RDN rdn = rdns.get( rdns.size() - pos - 1 );
-                pos++;
-                return rdn.getNormName();
-            }
-        };
-    }
-
-
-    /**
      * Retrieves the components of this name as an enumeration of strings. The
      * effect on the enumeration of updates to this name is undefined. If the
      * name has zero components, an empty (non-null) enumeration is returned.

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=926660&r1=926659&r2=926660&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
Tue Mar 23 16:56:02 2010
@@ -22,6 +22,7 @@ package org.apache.directory.shared.ldap
 
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.directory.shared.i18n.I18n;
@@ -189,7 +190,7 @@ public class DnBranchNode<N> implements 
      */
     public N getParentElement( DN dn )
     {
-        Enumeration<String> rdns = dn.getAll();
+        List<RDN> rdns = dn.getRdns();
         
         // This is synchronized so that we can't read the
         // partitionList when it is modified.
@@ -198,9 +199,9 @@ public class DnBranchNode<N> implements 
             DnNode<N> currentNode = this;
 
             // Iterate through all the RDN until we find the associated partition
-            while ( rdns.hasMoreElements() )
+            for ( int i = rdns.size() - 1; i >= 0; i-- )
             {
-                String rdn = rdns.nextElement();
+                String rdnStr = rdns.get( i ).getNormName();
 
                 if ( currentNode == null )
                 {
@@ -214,9 +215,9 @@ public class DnBranchNode<N> implements 
 
                 DnBranchNode<N> currentBranch = ( DnBranchNode<N> ) currentNode;
                 
-                if ( currentBranch.contains( rdn ) )
+                if ( currentBranch.contains( rdnStr ) )
                 {
-                    currentNode = currentBranch.getChild( rdn );
+                    currentNode = currentBranch.getChild( rdnStr );
                     
                     if ( currentNode instanceof DnLeafNode )
                     {
@@ -241,7 +242,7 @@ public class DnBranchNode<N> implements 
      */
     public boolean hasParentElement( DN dn )
     {
-        Enumeration<RDN> rdns = dn.getAllRdn();
+        List<RDN> rdns = dn.getRdns();
         
         // This is synchronized so that we can't read the
         // partitionList when it is modified.
@@ -250,9 +251,9 @@ public class DnBranchNode<N> implements 
             DnNode<N> currentNode = this;
 
             // Iterate through all the RDN until we find the associated partition
-            while ( rdns.hasMoreElements() )
+            for ( int i = rdns.size() - 1; i >= 0; i-- )
             {
-                RDN rdn = rdns.nextElement();
+                String rdnStr = rdns.get( i ).getNormName();
 
                 if ( currentNode == null )
                 {
@@ -266,9 +267,9 @@ public class DnBranchNode<N> implements 
 
                 DnBranchNode<N> currentBranch = ( DnBranchNode<N> ) currentNode;
                 
-                if ( currentBranch.contains( rdn.getNormName() ) )
+                if ( currentBranch.contains( rdnStr ) )
                 {
-                    currentNode = currentBranch.getChild( rdn.getNormName() );
+                    currentNode = currentBranch.getChild( rdnStr );
                     
                     if ( currentNode instanceof DnLeafNode )
                     {

Modified: directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java?rev=926660&r1=926659&r2=926660&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
(original)
+++ directory/shared/trunk/ldap/src/test/java/org/apache/directory/shared/ldap/name/DNTest.java
Tue Mar 23 16:56:02 2010
@@ -35,7 +35,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.Comparator;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -1259,7 +1258,7 @@ public class DNTest
     // GET ALL operations
     /**
      * test a getAll operation on a null DN
-     */
+     *
     @Test
     public void testDnGetAllNull()
     {
@@ -1272,7 +1271,7 @@ public class DNTest
 
     /**
      * test a getAll operation on an empty DN
-     */
+     *
     @Test
     public void testDnGetAllEmpty() throws LdapException
     {
@@ -1285,7 +1284,7 @@ public class DNTest
 
     /**
      * test a getAll operation on a simple DN
-     */
+     *
     @Test
     public void testDnGetAllSimple() throws LdapException
     {
@@ -1300,7 +1299,7 @@ public class DNTest
 
     /**
      * test a getAll operation on a complex DN
-     */
+     *
     @Test
     public void testDnGetAllComplex() throws LdapException
     {
@@ -1319,7 +1318,7 @@ public class DNTest
 
     /**
      * test a getAll operation on a complex DN
-     */
+     *
     @Test
     public void testDnGetAllComplexOrdered() throws LdapException
     {
@@ -1776,7 +1775,7 @@ public class DNTest
      *
      * @throws Exception
      *             if anything goes wrong.
-     */
+     *
     @Test
     public void testGetAll() throws Exception
     {
@@ -1955,44 +1954,14 @@ public class DNTest
     @Test
     public void testGetAllRdn() throws Exception
     {
-        DN name = new DN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West"
);
-
-        Enumeration<RDN> rdns = name.getAllRdn();
-        assertEquals( true, rdns.hasMoreElements() );
-
-        for ( int i = 0; rdns.hasMoreElements(); i++ )
+        DN dn = new DN( "cn=Airline,cn=Website,cn=HomeDir,cn=John,ou=Marketing,ou=West" );
+        String[] expected = new String[]{ "cn=Airline", "cn=Website", "cn=HomeDir", "cn=John",
"ou=Marketing", "ou=West" };
+        int count = 0;
+        
+        for ( RDN rdn : dn )
         {
-            RDN element = ( RDN ) rdns.nextElement();
-
-            if ( i == 0 )
-            {
-                assertEquals( "ou=West", element.toString() );
-            }
-
-            if ( i == 1 )
-            {
-                assertEquals( "ou=Marketing", element.toString() );
-            }
-
-            if ( i == 2 )
-            {
-                assertEquals( "cn=John", element.toString() );
-            }
-
-            if ( i == 3 )
-            {
-                assertEquals( "cn=HomeDir", element.toString() );
-            }
-
-            if ( i == 4 )
-            {
-                assertEquals( "cn=Website", element.toString() );
-            }
-
-            if ( i == 5 )
-            {
-                assertEquals( "cn=Airline", element.toString() );
-            }
+            assertEquals( expected[count], rdn.toString() );
+            count++;
         }
     }
 
@@ -2827,7 +2796,7 @@ public class DNTest
 
     /**
      * Test for DIRSERVER-191
-     */
+     *
     @Test
     public void testGetAllName() throws LdapException, InvalidNameException
     {
@@ -2852,15 +2821,17 @@ public class DNTest
     public void testDoubleQuoteInNameDIRSERVER_642() throws LdapException, InvalidNameException
     {
         DN name1 = new DN( "cn=\"Kylie Minogue\",dc=example,dc=com" );
-        LdapName name2 = new LdapName( "cn=\"Kylie Minogue\",dc=example,dc=com" );
+        
+        String[] expected = new String[]{ "cn=\"Kylie Minogue\"", "dc=example", "dc=com"
};
 
-        Enumeration<String> j = name1.getAll();
-        Enumeration<String> a = name2.getAll();
+        List<RDN> j = name1.getRdns();
+        int count = 0;
+        
 
-        while ( j.hasMoreElements() )
+        for ( RDN rdn:j )
         {
-            assertTrue( j.hasMoreElements() );
-            assertEquals( j.nextElement(), a.nextElement() );
+            assertEquals( expected[count], rdn.getName() );
+            count++;
         }
     }
 



Mime
View raw message