directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1071993 - in /directory: apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/ shared/branches/m1/ldap-model/src/main/java/org/apac...
Date Fri, 18 Feb 2011 13:29:34 GMT
Author: elecharny
Date: Fri Feb 18 13:29:34 2011
New Revision: 1071993

URL: http://svn.apache.org/viewvc?rev=1071993&view=rev
Log:
o Removed the Dn.remove( int ) method
o Removed the DnUtils.getRelativeName() method
o Fixed the tests and code accordingly

Modified:
    directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
    directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
    directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
    directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnUtils.java
    directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnUtilsTest.java

Modified: directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=1071993&r1=1071992&r2=1071993&view=diff
==============================================================================
--- directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
(original)
+++ directory/apacheds/branches/m1/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
Fri Feb 18 13:29:34 2011
@@ -1611,32 +1611,8 @@ public abstract class ServerContext impl
 
         // 1). Find the Dn for name and walk it from the head to tail
         Dn fqn = buildTarget( JndiUtils.fromName( name ) );
-        String head = prefix.get( 0 );
-
-        // 2). Walk the fqn trying to match for the head of the prefix
-        while ( fqn.size() > 0 )
-        {
-            // match found end loop
-            if ( fqn.get( 0 ).equalsIgnoreCase( head ) )
-            {
-                return JndiUtils.toName( fqn );
-            }
-            else
-            // 2). Remove name components from the Dn until a match
-            {
-                try
-                {
-                    fqn = fqn.remove( 0 );
-                }
-                catch ( LdapInvalidDnException lide )
-                {
-                    throw new NamingException( lide.getMessage() );
-                }
-            }
-        }
-
-        String msg = I18n.err( I18n.ERR_498, prefix, dn );
-        throw new NamingException( msg );
+        
+        return JndiUtils.toName( JndiUtils.fromName( prefix ).addAll( fqn ) );
     }
 
 

Modified: directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java?rev=1071993&r1=1071992&r2=1071993&view=diff
==============================================================================
--- directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
(original)
+++ directory/shared/branches/m1/integ/src/test/java/org/apache/directory/shared/ldap/name/DnTest.java
Fri Feb 18 13:29:34 2011
@@ -514,7 +514,7 @@ public class DnTest
 
     /**
      * test a remove from position 0
-     */
+     *
     @Test
     public void testDnRemove0() throws LdapException
     {
@@ -530,7 +530,7 @@ public class DnTest
 
     /**
      * test a remove from position 1
-     */
+     *
     @Test
     public void testDnRemove1() throws LdapException
     {
@@ -543,7 +543,7 @@ public class DnTest
 
     /**
      * test a remove from position 2
-     */
+     *
     @Test
     public void testDnRemove2() throws LdapException
     {
@@ -557,7 +557,7 @@ public class DnTest
 
     /**
      * test a remove from position 1 whith semi colon
-     */
+     *
     @Test
     public void testDnRemove1WithSemiColon() throws LdapException
     {
@@ -571,7 +571,7 @@ public class DnTest
 
     /**
      * test a remove out of bound
-     */
+     *
     @Test
     public void testDnRemoveOutOfBound() throws LdapException
     {
@@ -660,10 +660,10 @@ public class DnTest
         dn = dn.add( "c = d" );
         assertEquals( 2, dn.size() );
 
-        dn = dn.remove( 0 );
+        dn = dn.getParent();
         assertEquals( 1, dn.size() );
 
-        dn = dn.remove( 0 );
+        dn = dn.getParent();
         assertEquals( 0, dn.size() );
     }
 
@@ -1034,7 +1034,7 @@ public class DnTest
 
     /**
      * Test that a Dn is empty
-     */
+     *
     @Test
     public void testDnRemoveIsEmpty() throws LdapException
     {
@@ -1337,7 +1337,7 @@ public class DnTest
      *
      * @throws Exception
      *             if anything goes wrong
-     */
+     *
     @Test
     public void testJNDITutorialExample() throws Exception
     {
@@ -2455,7 +2455,7 @@ public class DnTest
 
     /**
      * Test for DIRSERVER-191
-     */
+     *
     @Test
     public void testRemoveName() throws LdapException, InvalidNameException
     {
@@ -2467,7 +2467,7 @@ public class DnTest
         assertNotSame( jName.toString(), aName.toString() );
 
         jName.remove( jName.size() - 1 );
-        assertEquals( jName.toString(), aName.remove( aName.size() - 1 ).remove( 0 ).toString()
);
+        assertEquals( jName.toString(), aName.getParent().remove( 0 ).toString() );
         assertNotSame( jName.toString(), aName.toString() );
     }
 
@@ -3330,9 +3330,6 @@ public class DnTest
 
         dn.normalize( schemaManager );
         assertTrue( dn.isNormalized() );
-
-        dn = dn.remove( 0 );
-        assertTrue( dn.isNormalized() );
     }
 
 

Modified: directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java?rev=1071993&r1=1071992&r2=1071993&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
(original)
+++ directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/Dn.java
Fri Feb 18 13:29:34 2011
@@ -1375,45 +1375,6 @@ public final class Dn implements Iterabl
 
 
     /**
-     * {@inheritDoc}
-     */
-    public Dn remove( int posn ) throws LdapInvalidDnException
-    {
-        if ( rdns.size() == 0 )
-        {
-            return this;
-        }
-
-        if ( ( posn < 0 ) || ( posn >= rdns.size() ) )
-        {
-            String message = I18n.err( I18n.ERR_04206, posn, rdns.size() );
-            LOG.error( message );
-            throw new ArrayIndexOutOfBoundsException( message );
-        }
-
-        Dn clonedDn = copy();
-        clonedDn._removeChild( posn );
-
-        return clonedDn;
-    }
-
-
-    /**
-     * removes a child (Rdn) present at the given position
-     *
-     * @param posn the index of the child's position
-     */
-    private void _removeChild( int posn )
-    {
-        int realPos = size() - posn - 1;
-        rdns.remove( realPos );
-
-        normalizeInternal();
-        toUpName();
-    }
-
-
-    /**
      * Gets the parent Dn of this Dn. Null if this Dn doesn't have a parent, i.e. because
it
      * is the empty Dn.
      *

Modified: directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnUtils.java?rev=1071993&r1=1071992&r2=1071993&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnUtils.java
(original)
+++ directory/shared/branches/m1/ldap-model/src/main/java/org/apache/directory/shared/ldap/model/name/DnUtils.java
Fri Feb 18 13:29:34 2011
@@ -763,37 +763,6 @@ public final class DnUtils
         return rdn.substring( index + 1, rdn.length() );
     }
 
-    /**
-     * Gets the relative name between an ancestor and a potential descendant.
-     * Both name arguments must be normalized. The returned name is also
-     * normalized.
-     *
-     * @param ancestor the normalized distinguished name of the ancestor context
-     * @param descendant the normalized distinguished name of the descendant context
-     * @return the relative normalized name between the ancestor and the
-     *         descendant contexts
-     * @throws org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException if
the contexts are not related in the ancestual sense
-     */
-    public static Dn getRelativeName( Dn ancestor, Dn descendant ) throws LdapInvalidDnException
-    {
-        Dn rdn = descendant;
-
-        if ( rdn.isDescendantOf( ancestor ) )
-        {
-            for ( int ii = 0; ii < ancestor.size(); ii++ )
-            {
-                rdn = rdn.remove( 0 );
-            }
-        }
-        else
-        {
-            LdapInvalidDnException e = new LdapInvalidDnException( I18n.err(I18n.ERR_04417,
descendant, ancestor) );
-
-            throw e;
-        }
-
-        return rdn;
-    }
 
     /**
      * Gets the '+' appended components of a composite name component.

Modified: directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnUtilsTest.java?rev=1071993&r1=1071992&r2=1071993&view=diff
==============================================================================
--- directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnUtilsTest.java
(original)
+++ directory/shared/branches/m1/ldap-model/src/test/java/org/apache/directory/shared/ldap/model/name/DnUtilsTest.java
Fri Feb 18 13:29:34 2011
@@ -22,16 +22,14 @@ package org.apache.directory.shared.ldap
 
 import static org.junit.Assert.assertEquals;
 
-import com.mycila.junit.concurrent.Concurrency;
-import com.mycila.junit.concurrent.ConcurrentJunitRunner;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
-import org.apache.directory.shared.ldap.model.name.Dn;
-import org.apache.directory.shared.ldap.model.name.DnUtils;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
+import com.mycila.junit.concurrent.Concurrency;
+import com.mycila.junit.concurrent.ConcurrentJunitRunner;
+
 
 
 /**
@@ -194,20 +192,4 @@ public class DnUtilsTest
         assertEquals( "expecting one part : ", 1, args.length );
         assertEquals( "cn=Alex", args[0] );
     }
-
-
-    @Test
-    public void testGetRelativeName() throws LdapInvalidDnException
-    {
-        // test the basis case first with the root
-        Dn ancestor = new Dn( "" );
-        Dn descendant = new Dn( "ou=system" );
-        Dn relativeName = DnUtils.getRelativeName(ancestor, descendant);
-        assertEquals( relativeName.toString(), "ou=system" );
-
-        ancestor = new Dn( "ou=system" );
-        descendant = new Dn( "ou=users,ou=system" );
-        relativeName = DnUtils.getRelativeName(ancestor, descendant);
-        assertEquals( relativeName.toString(), "ou=users" );
-    }
 }



Mime
View raw message