directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r982648 [3/3] - in /directory: apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ apacheds/trunk/jdbm-partition/src/test/java/org/ap...
Date Thu, 05 Aug 2010 14:55:10 GMT
Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxHandlerIT.java Thu Aug  5 14:55:09 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.server.core.schema;
 
@@ -46,6 +46,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.exception.LdapUnwillingToPerformException;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
@@ -94,92 +95,92 @@ public class MetaSyntaxHandlerIT extends
     @Test
     public void testAddSyntaxToEnabledSchema() throws Exception
     {
-        Attributes attrs = LdifUtils.createAttributes( 
+        Attributes attrs = LdifUtils.createAttributes(
             "objectClass: top",
             "objectClass: metaTop",
             "objectClass: metaSyntax",
             "m-oid", OID,
             "m-description", DESCRIPTION0 );
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
-        
+
         createDummySyntaxChecker( OID, "apachemeta" );
-        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-        
+        getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
         assertTrue( schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         assertEquals( schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
         assertTrue( isOnDisk( dn ) );
     }
-    
-    
+
+
     @Test
     public void testAddSyntaxToDisabledSchema() throws Exception
     {
-        Attributes attrs = LdifUtils.createAttributes( 
+        Attributes attrs = LdifUtils.createAttributes(
             "objectClass: top",
             "objectClass: metaTop",
             "objectClass: metaSyntax",
             "m-oid", OID,
             "m-description", DESCRIPTION0 );
-        
+
         // nis is by default inactive
         DN dn = getSyntaxContainer( "nis" );
         dn = dn.add( "m-oid" + "=" + OID );
         createDummySyntaxChecker( OID, "nis" );
-        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-        
-        assertFalse( "adding new syntax to disabled schema should not register it into the registries", 
+        getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
+        assertFalse( "adding new syntax to disabled schema should not register it into the registries",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         assertTrue( isOnDisk( dn ) );
     }
 
-    
+
     @Test
     public void testAddSyntaxToUnloadedSchema() throws Exception
     {
-        Attributes attrs = LdifUtils.createAttributes( 
+        Attributes attrs = LdifUtils.createAttributes(
             "objectClass: top",
             "objectClass: metaTop",
             "objectClass: metaSyntax",
             "m-oid", OID,
             "m-description", DESCRIPTION0 );
-        
+
         // nis is by default inactive
         DN dn = getSyntaxContainer( "notloaded" );
         dn = dn.add( "m-oid" + "=" + OID );
         createDummySyntaxChecker( OID, "nis" );
-        
+
         try
         {
-            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
+            getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
             fail( "Should not be there" );
         }
         catch( NameNotFoundException nnfe )
         {
             // Expected result.
         }
-        
-        assertFalse( "adding new syntax to disabled schema should not register it into the registries", 
+
+        assertFalse( "adding new syntax to disabled schema should not register it into the registries",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
         assertFalse( isOnDisk( dn ) );
     }
-    
-    
+
+
     @Test
     public void testDeleteSyntaxFromEnabledSchema() throws Exception
     {
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
         testAddSyntaxToEnabledSchema();
-        
+
         assertTrue( isOnDisk( dn ) );
-        assertTrue( "syntax should be removed from the registry after being deleted", 
+        assertTrue( "syntax should be removed from the registry after being deleted",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
-        
-        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
 
-        assertFalse( "syntax should be removed from the registry after being deleted", 
+        getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
+
+        assertFalse( "syntax should be removed from the registry after being deleted",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
         try
@@ -203,12 +204,12 @@ public class MetaSyntaxHandlerIT extends
         testAddSyntaxToDisabledSchema();
 
         assertTrue( isOnDisk( dn ) );
-        assertFalse( "syntax should be removed from the registry after being deleted", 
+        assertFalse( "syntax should be removed from the registry after being deleted",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
-        getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
+        getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
 
-        assertFalse( "syntax should be removed from the registry after being deleted", 
+        assertFalse( "syntax should be removed from the registry after being deleted",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
         try
@@ -219,7 +220,7 @@ public class MetaSyntaxHandlerIT extends
         catch( LdapException e )
         {
         }
-        
+
         assertFalse( isOnDisk( dn ) );
     }
 
@@ -231,12 +232,12 @@ public class MetaSyntaxHandlerIT extends
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
         testAddSyntaxToEnabledSchema();
-        
+
         DN newdn = getSyntaxContainer( "apachemeta" );
         newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+        getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
 
-        assertFalse( "old syntax OID should be removed from the registry after being renamed", 
+        assertFalse( "old syntax OID should be removed from the registry after being renamed",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
         //noinspection EmptyCatchBlock
@@ -258,19 +259,19 @@ public class MetaSyntaxHandlerIT extends
     public void testMoveSyntax() throws Exception
     {
         testAddSyntaxToEnabledSchema();
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
 
         DN newdn = getSyntaxContainer( "apache" );
         newdn = newdn.add( "m-oid" + "=" + OID );
-        
-        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
-        assertTrue( "syntax OID should still be present", 
+        getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+        assertTrue( "syntax OID should still be present",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
-        
-        assertEquals( "syntax schema should be set to apache not apachemeta", 
+
+        assertEquals( "syntax schema should be set to apache not apachemeta",
             schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apache" );
     }
 
@@ -280,86 +281,86 @@ public class MetaSyntaxHandlerIT extends
     public void testMoveSyntaxAndChangeRdn() throws Exception
     {
         testAddSyntaxToEnabledSchema();
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
 
         DN newdn = getSyntaxContainer( "apache" );
         newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-        
-        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
-        assertFalse( "old syntax OID should NOT be present", 
+        getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+        assertFalse( "old syntax OID should NOT be present",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
-        
-        assertTrue( "new syntax OID should be present", 
+
+        assertTrue( "new syntax OID should be present",
             schemaManager.getLdapSyntaxRegistry().contains( NEW_OID ) );
-        
-        assertEquals( "syntax with new oid should have schema set to apache NOT apachemeta", 
+
+        assertEquals( "syntax with new oid should have schema set to apache NOT apachemeta",
             schemaManager.getLdapSyntaxRegistry().getSchemaName( NEW_OID ), "apache" );
     }
 
-    
+
     @Test
     @Ignore
     public void testModifySyntaxWithModificationItems() throws Exception
     {
         testAddSyntaxToEnabledSchema();
-        
+
         LdapSyntax syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION0 );
 
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
-        
+
         ModificationItem[] mods = new ModificationItem[1];
         Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
         mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), mods );
+        getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
 
-        assertTrue( "syntax OID should still be present", 
+        assertTrue( "syntax OID should still be present",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
-        
-        assertEquals( "syntax schema should be set to apachemeta", 
+
+        assertEquals( "syntax schema should be set to apachemeta",
             schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
-        
+
         syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION1 );
     }
 
-    
+
     @Test
     @Ignore
     public void testModifySyntaxWithAttributes() throws Exception
     {
         testAddSyntaxToEnabledSchema();
-        
+
         LdapSyntax syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION0 );
 
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
-        
+
         Attributes mods = new BasicAttributes( true );
         mods.put( "m-description", DESCRIPTION1 );
-        getSchemaContext( service ).modifyAttributes( DN.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
+        getSchemaContext( service ).modifyAttributes( JndiUtils.toName( dn ), DirContext.REPLACE_ATTRIBUTE, mods );
 
-        assertTrue( "syntax OID should still be present", 
+        assertTrue( "syntax OID should still be present",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
-        
-        assertEquals( "syntax schema should be set to apachemeta", 
+
+        assertEquals( "syntax schema should be set to apachemeta",
             schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
 
         syntax = schemaManager.getLdapSyntaxRegistry().lookup( OID );
         assertEquals( syntax.getDescription(), DESCRIPTION1 );
     }
-    
+
 
     // ----------------------------------------------------------------------
     // Test move, rename, and delete when a MR exists and uses the Normalizer
     // ----------------------------------------------------------------------
 
-    
+
     @Test
     public void testDeleteSyntaxWhenInUse() throws Exception
     {
@@ -367,45 +368,45 @@ public class MetaSyntaxHandlerIT extends
         dn = dn.add( "m-oid" + "=" + OID );
         testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
-        
+
         try
         {
-            getSchemaContext( service ).destroySubcontext( DN.toName( dn ) );
+            getSchemaContext( service ).destroySubcontext( JndiUtils.toName( dn ) );
             fail( "should not be able to delete a syntax in use" );
         }
-        catch( OperationNotSupportedException e ) 
+        catch( OperationNotSupportedException e )
         {
         }
 
-        assertTrue( "syntax should still be in the registry after delete failure", 
+        assertTrue( "syntax should still be in the registry after delete failure",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
-    
-    
+
+
     @Test
     @Ignore
     public void testMoveSyntaxWhenInUse() throws Exception
     {
         testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
 
         DN newdn = getSyntaxContainer( "apache" );
         newdn = newdn.add( "m-oid" + "=" + OID );
-        
+
         try
         {
-            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+            getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
             fail( "should not be able to move a syntax in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( LdapUnwillingToPerformException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "syntax should still be in the registry after move failure", 
+        assertTrue( "syntax should still be in the registry after move failure",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
@@ -416,47 +417,47 @@ public class MetaSyntaxHandlerIT extends
     {
         testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
 
         DN newdn = getSyntaxContainer( "apache" );
         newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-        
+
         try
         {
-            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+            getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
             fail( "should not be able to move a syntax in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( LdapUnwillingToPerformException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "syntax should still be in the registry after move failure", 
+        assertTrue( "syntax should still be in the registry after move failure",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
-    
+
     private void addDependeeMatchingRule( String oid ) throws Exception
     {
-        Attributes attrs = LdifUtils.createAttributes( 
+        Attributes attrs = LdifUtils.createAttributes(
             "objectClass: top",
             "objectClass: metaTop",
             "objectClass: metaMatchingRule",
             "m-oid", MR_OID,
             "m-syntax", OID,
             "m-description", MR_DESCRIPTION );
-        
+
         DN dn = getMatchingRuleContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + MR_OID );
-        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attrs );
-        
+        getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attrs );
+
         assertTrue( schemaManager.getMatchingRuleRegistry().contains( MR_OID ) );
         assertEquals( schemaManager.getMatchingRuleRegistry().getSchemaName( MR_OID ), "apachemeta" );
     }
 
-    
+
     @Test
     @Ignore
     public void testRenameNormalizerWhenInUse() throws Exception
@@ -465,21 +466,21 @@ public class MetaSyntaxHandlerIT extends
         dn = dn.add( "m-oid" + "=" + OID );
         testAddSyntaxToEnabledSchema();
         addDependeeMatchingRule( OID );
-        
+
         DN newdn = getSyntaxContainer( "apachemeta" );
         newdn = newdn.add( "m-oid" + "=" + NEW_OID );
-        
+
         try
         {
-            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+            getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
             fail( "should not be able to rename a syntax in use" );
         }
-        catch( LdapUnwillingToPerformException e ) 
+        catch( LdapUnwillingToPerformException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
 
-        assertTrue( "syntax should still be in the registry after rename failure", 
+        assertTrue( "syntax should still be in the registry after rename failure",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
@@ -494,24 +495,24 @@ public class MetaSyntaxHandlerIT extends
     public void testMoveSyntaxToTop() throws Exception
     {
         testAddSyntaxToEnabledSchema();
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
 
         DN top = new DN();
         top.add( "m-oid" + "=" + OID );
-        
+
         try
         {
-            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( top ) );
+            getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( top ) );
             fail( "should not be able to move a syntax up to ou=schema" );
         }
-        catch( LdapInvalidDnException e ) 
+        catch( LdapInvalidDnException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
-        assertTrue( "syntax should still be in the registry after move failure", 
+        assertTrue( "syntax should still be in the registry after move failure",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
@@ -521,44 +522,44 @@ public class MetaSyntaxHandlerIT extends
     public void testMoveSyntaxToComparatorContainer() throws Exception
     {
         testAddSyntaxToEnabledSchema();
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
 
         DN newdn = new DN( "ou=comparators,cn=apachemeta" );
         newdn = newdn.add( "m-oid" + "=" + OID );
-        
+
         try
         {
-            getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
+            getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
             fail( "should not be able to move a syntax into comparators container" );
         }
-        catch( LdapInvalidDnException e ) 
+        catch( LdapInvalidDnException e )
         {
             assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
         }
 
-        assertTrue( "syntax should still be in the registry after move failure", 
+        assertTrue( "syntax should still be in the registry after move failure",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
-    
-    
+
+
     @Test
     @Ignore
     public void testMoveSyntaxToDisabledSchema() throws Exception
     {
         testAddSyntaxToEnabledSchema();
-        
+
         DN dn = getSyntaxContainer( "apachemeta" );
         dn = dn.add( "m-oid" + "=" + OID );
 
         // nis is inactive by default
         DN newdn = getSyntaxContainer( "nis" );
         newdn = newdn.add( "m-oid" + "=" + OID );
-        
-        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
-        assertFalse( "syntax OID should no longer be present", 
+        getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+        assertFalse( "syntax OID should no longer be present",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
     }
 
@@ -568,23 +569,23 @@ public class MetaSyntaxHandlerIT extends
     public void testMoveSyntaxToEnabledSchema() throws Exception
     {
         testAddSyntaxToDisabledSchema();
-        
+
         // nis is inactive by default
         DN dn = getSyntaxContainer( "nis" );
         dn = dn.add( "m-oid" + "=" + OID );
 
-        assertFalse( "syntax OID should NOT be present when added to disabled nis schema", 
+        assertFalse( "syntax OID should NOT be present when added to disabled nis schema",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
 
         DN newdn = getSyntaxContainer( "apachemeta" );
         newdn = newdn.add( "m-oid" + "=" + OID );
-        
-        getSchemaContext( service ).rename( DN.toName( dn ), DN.toName( newdn ) );
 
-        assertTrue( "syntax OID should be present when moved to enabled schema", 
+        getSchemaContext( service ).rename( JndiUtils.toName( dn ), JndiUtils.toName( newdn ) );
+
+        assertTrue( "syntax OID should be present when moved to enabled schema",
             schemaManager.getLdapSyntaxRegistry().contains( OID ) );
-        
-        assertEquals( "syntax should be in apachemeta schema after move", 
+
+        assertEquals( "syntax should be in apachemeta schema after move",
             schemaManager.getLdapSyntaxRegistry().getSchemaName( OID ), "apachemeta" );
     }
 
@@ -592,32 +593,32 @@ public class MetaSyntaxHandlerIT extends
     private void createDummySyntaxChecker( String oid, String schema ) throws Exception
     {
         List<String> descriptions = new ArrayList<String>();
-        descriptions.add( "( " + oid + " DESC 'bogus desc' FQCN " + OctetStringSyntaxChecker.class.getName() 
+        descriptions.add( "( " + oid + " DESC 'bogus desc' FQCN " + OctetStringSyntaxChecker.class.getName()
             + " X-SCHEMA '" + schema + "' )" );
         modify( DirContext.ADD_ATTRIBUTE, descriptions, "syntaxCheckers" );
     }
-    
-    
+
+
     private void modify( int op, List<String> descriptions, String opAttr ) throws Exception
     {
         DN dn = new DN( getSubschemaSubentryDN(), service.getSchemaManager() );
         Attribute attr = new BasicAttribute( opAttr );
-        
+
         for ( String description : descriptions )
         {
             attr.add( description );
         }
-        
+
         Attributes mods = new BasicAttributes( true );
         mods.put( attr );
-        
-        getRootContext( service ).modifyAttributes( DN.toName( dn ), op, mods );
+
+        getRootContext( service ).modifyAttributes( JndiUtils.toName( dn ), op, mods );
     }
-    
-    
+
+
     /**
      * Get's the subschemaSubentry attribute value from the rootDSE.
-     * 
+     *
      * @return the subschemaSubentry distinguished name
      * @throws Exception if there are problems accessing the RootDSE
      */
@@ -626,7 +627,7 @@ public class MetaSyntaxHandlerIT extends
         SearchControls controls = new SearchControls();
         controls.setSearchScope( SearchControls.OBJECT_SCOPE );
         controls.setReturningAttributes( new String[]{ SUBSCHEMA_SUBENTRY } );
-        
+
         NamingEnumeration<SearchResult> results = getRootContext( service ).search(
                 "", "(objectClass=*)", controls );
         SearchResult result = results.next();

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/ObjectClassCreateIT.java Thu Aug  5 14:55:09 2010
@@ -41,6 +41,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
 import org.apache.directory.shared.ldap.name.DN;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -59,39 +60,39 @@ public class ObjectClassCreateIT extends
         //--------------------------------------------------------------------
         Attributes attributes = new BasicAttributes( true );
         Attribute  objectClassAttribute = new BasicAttribute( "objectClass" );
-        
+
         objectClassAttribute.add( "top" );
         objectClassAttribute.add( "metaTop" );
         objectClassAttribute.add( "metaAttributeType" );
-        
+
         attributes.put( objectClassAttribute );
-        
+
         attributes.put( "m-oid", "2.16.840.1.113730.3.2.22.249" );
-        
+
         // The name
         attributes.put( "m-name", "accountStatus" );
-        
+
         // The Obsolete flag
         attributes.put( "m-obsolete", "FALSE" );
-        
+
         // The single value flag
         attributes.put( "m-singleValue", "TRUE" );
-        
+
         // The collective flag
         attributes.put( "m-collective", "FALSE" );
-        
+
         // The noUserModification flag
         attributes.put( "m-noUserModification", "FALSE" );
 
         // The usage
         attributes.put( "m-usage", "USER_APPLICATIONS" );
-        
+
         // The equality matching rule
         attributes.put( "m-equality", "caseIgnoreMatch" );
-        
+
         // The substr matching rule
         attributes.put( "m-substr", "caseIgnoreSubstringsMatch" );
-        
+
         // The syntax
         attributes.put( "m-syntax", "1.3.6.1.4.1.1466.115.121.1.15" );
 
@@ -100,33 +101,33 @@ public class ObjectClassCreateIT extends
 
         // The description
         attributes.put( "m-description", "Account Status" );
-        
+
         // Inject the AT
         DN dn = new DN( "ou=attributeTypes,cn=apachemeta" );
         dn = dn.add( MetaSchemaConstants.M_OID_AT + "=2.16.840.1.113730.3.2.22.249" );
-        
-        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attributes );
-        
+
+        getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attributes );
+
         //--------------------------------------------------------------------
         // The extendPerson OC
         //--------------------------------------------------------------------
         attributes = new BasicAttributes( true );
          objectClassAttribute = new BasicAttribute( "objectClass" );
-        
+
         objectClassAttribute.add( "top" );
         objectClassAttribute.add( "metaTop" );
         objectClassAttribute.add( "metaObjectClass" );
-        
+
         attributes.put( objectClassAttribute );
-        
+
         attributes.put( "m-oid", "2.16.840.1.113730.3.2.22" );
-        
+
         // The name
         attributes.put( "m-name", "extendPerson" );
-        
+
         // The Obsolete flag
         attributes.put( "m-obsolete", "FALSE" );
-        
+
         // The Type list
         attributes.put( "m-typeObjectClass", "STRUCTURAL" );
 
@@ -135,15 +136,15 @@ public class ObjectClassCreateIT extends
 
         // The description
         attributes.put( "m-description", "Extended InetOrgPerson" );
-        
+
         // The MAY list
         attributes.put( "m-may", "accountStatus" );
-        
+
         // Inject the OC
         dn = new DN( "ou=objectClasses,cn=apachemeta" );
         dn = dn.add( MetaSchemaConstants.M_OID_AT + "=2.16.840.1.113730.3.2.22" );
-        
-        getSchemaContext( service ).createSubcontext( DN.toName( dn ), attributes );
+
+        getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attributes );
     }
 
     /**
@@ -167,24 +168,24 @@ public class ObjectClassCreateIT extends
     {
         Attributes attributes = new BasicAttributes( true );
         Attribute  objectClassAttribute = new BasicAttribute( "objectClass" );
-        
+
         objectClassAttribute.add( "top" );
         objectClassAttribute.add( "metaTop" );
         objectClassAttribute.add( "metaObjectClass" );
-        
+
         attributes.put( objectClassAttribute );
-        
+
         attributes.put( "m-oid", "testOID" );
-        
+
         // This name is invalid
         attributes.put( "m-name", "http://example.com/users/accounts/L0" );
-        
+
         DN dn = getObjectClassContainer( "apachemeta" );
         dn = dn.add( MetaSchemaConstants.M_OID_AT + "=" + testOID );
-        
+
         try
         {
-            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attributes );
+            getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attributes );
             fail(); // Should not reach this point
         }
         catch ( NamingException ne )
@@ -201,25 +202,25 @@ public class ObjectClassCreateIT extends
     {
         Attributes attributes = new BasicAttributes( true );
         Attribute  objectClassAttribute = new BasicAttribute( "objectClass" );
-        
+
         objectClassAttribute.add( "top" );
         objectClassAttribute.add( "metaTop" );
         objectClassAttribute.add( "metaObjectClass" );
-        
+
         // Don't put the objectclasses in the entry : this is on purpose !
         // attributes.put( objectClassAttribute );
-        
+
         attributes.put( "m-oid", "testOID" );
-        
+
         // This name is invalid
         attributes.put( "m-name", "no-objectClasses" );
-        
+
         DN dn = getObjectClassContainer( "apachemeta" );
         dn = dn.add( MetaSchemaConstants.M_OID_AT + "=" + testOID );
-        
+
         try
         {
-            getSchemaContext( service ).createSubcontext( DN.toName( dn ), attributes );
+            getSchemaContext( service ).createSubcontext( JndiUtils.toName( dn ), attributes );
             fail(); // Should not reach this point
         }
         catch ( NamingException ne )
@@ -227,8 +228,8 @@ public class ObjectClassCreateIT extends
             assertTrue( true );
         }
     }
-    
-    
+
+
     /**
      * Test that if we create an OC with a superior OC then the AT are correctly
      * inherited.
@@ -237,29 +238,29 @@ public class ObjectClassCreateIT extends
     public void testCreateOCWithSuperior() throws Exception
     {
         injectSchema();
-        
+
         // Now, check that we can add entries with this new OC
         Attributes entry = new BasicAttributes( true );
         Attribute objectClassAttribute = new BasicAttribute( "objectClass" );
-        
+
         // The ObjectClass
         objectClassAttribute.add( "top" );
         objectClassAttribute.add( "extendPerson" );
-        
+
         entry.put( objectClassAttribute );
-        
+
         // Mandatory attributes -- required in MUST list
         entry.put( "uid", "test" );
-        entry.put( "sn", "test" ); 
+        entry.put( "sn", "test" );
         entry.put( "givenName", "test" );
-        entry.put( "cn", "test" ); 
+        entry.put( "cn", "test" );
         entry.put( "displayName", "test-test" );
         entry.put( "initials", "tt" );
         entry.put(  "accountStatus", "test" );
-        
+
         // Create the context
         DirContext system = getSystemContext( service );
-        
+
         try
         {
             system.createSubcontext( "cn=test", entry );
@@ -268,41 +269,41 @@ public class ObjectClassCreateIT extends
         {
             fail();
         }
-        
+
     }
-    
-    
+
+
     /**
-     * Test that if we create an AT with an ancestor, we can search and 
+     * Test that if we create an AT with an ancestor, we can search and
      * get back the entry using its ancestor
      */
     @Test
     public void testCreateATWithSuperior() throws Exception
     {
         injectSchema();
-        
+
         // Now, check that we can add entries with this new AT
         Attributes entry = new BasicAttributes( true );
         Attribute objectClassAttribute = new BasicAttribute( "objectClass" );
-        
+
         // The ObjectClass
         objectClassAttribute.add( "top" );
         objectClassAttribute.add( "extendPerson" );
-        
+
         entry.put( objectClassAttribute );
-        
+
         // Mandatory attributes -- required in MUST list
         entry.put( "uid", "test" );
-        entry.put( "sn", "test" ); 
+        entry.put( "sn", "test" );
         entry.put( "givenName", "test" );
-        entry.put( "cn", "test" ); 
+        entry.put( "cn", "test" );
         entry.put( "displayName", "test-test" );
         entry.put( "initials", "tt" );
         entry.put( "accountStatus", "accountStatusValue" );
-        
+
         // Create the context
         DirContext system = getSystemContext( service );
-        
+
         try
         {
             system.createSubcontext( "cn=test", entry );
@@ -311,12 +312,12 @@ public class ObjectClassCreateIT extends
         {
             fail();
         }
-        
+
         SearchControls sc = new SearchControls();
         NamingEnumeration<SearchResult> result = system.search( "", "(name=accountStatusValue)", sc );
 
         boolean found = false;
-        
+
         while ( result.hasMore() )
         {
             assertFalse( found );

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SchemaPersistenceIT.java Thu Aug  5 14:55:09 2010
@@ -46,6 +46,7 @@ import javax.naming.directory.SearchResu
 import org.apache.directory.server.core.annotations.CreateDS;
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.parsers.AttributeTypeDescriptionSchemaParser;
@@ -147,7 +148,7 @@ public class SchemaPersistenceIT extends
         Attributes mods = new BasicAttributes( true );
         mods.put( attr );
 
-        getRootContext( service ).modifyAttributes( DN.toName( dn ), op, mods );
+        getRootContext( service ).modifyAttributes( JndiUtils.toName( dn ), op, mods );
     }
 
 

Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java (original)
+++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryIT.java Thu Aug  5 14:55:09 2010
@@ -66,6 +66,7 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.integ.AbstractLdapTestUnit;
 import org.apache.directory.server.core.integ.FrameworkRunner;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.jndi.JndiUtils;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
@@ -1411,7 +1412,7 @@ public class SubschemaSubentryIT extends
         mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE,
             new BasicAttribute( "attributeTypes", substrate ) );
 
-        getRootContext( service ).modifyAttributes( DN.toName( dn ), mods );
+        getRootContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
 
         Attributes attrs = getSubschemaSubentryAttributes();
         Attribute attrTypes = attrs.get( "attributeTypes" );
@@ -1465,7 +1466,7 @@ public class SubschemaSubentryIT extends
         mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE,
             new BasicAttribute( "attributeTypes", substrate ) );
 
-        getRootContext( service ).modifyAttributes( DN.toName( dn ), mods );
+        getRootContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
 
         Attributes attrs = getSubschemaSubentryAttributes();
         Attribute attrTypes = attrs.get( "attributeTypes" );
@@ -1898,7 +1899,7 @@ public class SubschemaSubentryIT extends
         mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE,
             new BasicAttribute( "attributeTypes", substrate ) );
 
-        getRootContext( service ).modifyAttributes( DN.toName( dn ), mods );
+        getRootContext( service ).modifyAttributes( JndiUtils.toName( dn ), mods );
 
         // now check the modification timestamp and the modifiers name
 
@@ -1952,7 +1953,7 @@ public class SubschemaSubentryIT extends
             "DESC 'bogus description' SUP name SINGLE-VALUE X-SCHEMA 'nis' )";
         mods[0] = new ModificationItem( DirContext.ADD_ATTRIBUTE,
             new BasicAttribute( "attributeTypes", substrate ) );
-        ctx.modifyAttributes( DN.toName( dn ), mods );
+        ctx.modifyAttributes( JndiUtils.toName( dn ), mods );
 
         // now let's verify the new values for the modification attributes
 
@@ -1997,7 +1998,7 @@ public class SubschemaSubentryIT extends
             modifications[i++] = new ModificationItem( op, new BasicAttribute( opAttr, description ) );
         }
 
-        getRootContext( service ).modifyAttributes( DN.toName( dn ), modifications );
+        getRootContext( service ).modifyAttributes( JndiUtils.toName( dn ), modifications );
     }
 
 

Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerContext.java Thu Aug  5 14:55:09 2010
@@ -202,7 +202,7 @@ public abstract class ServerContext impl
     public ServerContext( DirectoryService service, LdapPrincipal principal, Name name ) throws Exception
     {
         this.service = service;
-        this.dn = DN.fromName( name );
+        this.dn = JndiUtils.fromName( name );
 
         this.env = new Hashtable<String, Object>();
         this.env.put( PROVIDER_URL, dn.toString() );
@@ -225,7 +225,7 @@ public abstract class ServerContext impl
     public ServerContext( DirectoryService service, CoreSession session, Name name ) throws Exception
     {
         this.service = service;
-        this.dn = DN.fromName( name );
+        this.dn = JndiUtils.fromName( name );
         this.env = new Hashtable<String, Object>();
         this.env.put( PROVIDER_URL, dn.toString() );
         this.env.put( DirectoryService.JNDI_KEY, service );
@@ -730,7 +730,7 @@ public abstract class ServerContext impl
      */
     public Context createSubcontext( Name name ) throws NamingException
     {
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
         Entry serverEntry = null;
 
         try
@@ -792,7 +792,7 @@ public abstract class ServerContext impl
 
         try
         {
-            ctx = new ServerLdapContext( service, session.getEffectivePrincipal(), DN.toName( target ) );
+            ctx = new ServerLdapContext( service, session.getEffectivePrincipal(), JndiUtils.toName( target ) );
         }
         catch ( Exception e )
         {
@@ -817,7 +817,7 @@ public abstract class ServerContext impl
      */
     public void destroySubcontext( Name name ) throws NamingException
     {
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
 
         if ( target.size() == 0 )
         {
@@ -871,7 +871,7 @@ public abstract class ServerContext impl
         // First, use state factories to do a transformation
         DirStateFactory.Result res = DirectoryManager.getStateToBind( obj, name, this, env, null );
 
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
 
         // let's be sure that the Attributes is case insensitive
         Entry outServerEntry = null;
@@ -1033,8 +1033,8 @@ public abstract class ServerContext impl
      */
     public void rename( Name oldName, Name newName ) throws NamingException
     {
-        DN oldDn = buildTarget( DN.fromName( oldName ) );
-        DN newDn = buildTarget( DN.fromName( newName ) );
+        DN oldDn = buildTarget( JndiUtils.fromName( oldName ) );
+        DN newDn = buildTarget( JndiUtils.fromName( newName ) );
 
         if ( oldDn.size() == 0 )
         {
@@ -1141,7 +1141,7 @@ public abstract class ServerContext impl
      */
     public void rebind( Name name, Object obj ) throws NamingException
     {
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
         OperationManager operationManager = service.getOperationManager();
 
         try
@@ -1176,7 +1176,7 @@ public abstract class ServerContext impl
     {
         try
         {
-            doDeleteOperation( buildTarget( DN.fromName( name ) ) );
+            doDeleteOperation( buildTarget( JndiUtils.fromName( name ) ) );
         }
         catch ( Exception e )
         {
@@ -1207,7 +1207,7 @@ public abstract class ServerContext impl
     public Object lookup( Name name ) throws NamingException
     {
         Object obj;
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
 
         Entry serverEntry = null;
 
@@ -1257,7 +1257,7 @@ public abstract class ServerContext impl
 
         try
         {
-            ctx = new ServerLdapContext( service, session.getEffectivePrincipal(), DN.toName( target ) );
+            ctx = new ServerLdapContext( service, session.getEffectivePrincipal(), JndiUtils.toName( target ) );
         }
         catch ( Exception e )
         {
@@ -1302,7 +1302,7 @@ public abstract class ServerContext impl
             {
                 try
                 {
-                    return DN.toName( new DN( name ) );
+                    return JndiUtils.toName( new DN( name ) );
                 }
                 catch ( LdapInvalidDnException lide )
                 {
@@ -1329,7 +1329,7 @@ public abstract class ServerContext impl
             {
                 try
                 {
-                    return DN.toName( new DN( name.toString() ) );
+                    return JndiUtils.toName( new DN( name.toString() ) );
                 }
                 catch ( LdapInvalidDnException lide )
                 {
@@ -1360,7 +1360,7 @@ public abstract class ServerContext impl
     {
         try
         {
-            return new NamingEnumerationAdapter( doListOperation( buildTarget( DN.fromName( name ) ) ) );
+            return new NamingEnumerationAdapter( doListOperation( buildTarget( JndiUtils.fromName( name ) ) ) );
         }
         catch ( Exception e )
         {
@@ -1389,7 +1389,7 @@ public abstract class ServerContext impl
     public NamingEnumeration listBindings( Name name ) throws NamingException
     {
         // Conduct a special one level search at base for all objects
-        DN base = buildTarget( DN.fromName( name ) );
+        DN base = buildTarget( JndiUtils.fromName( name ) );
         PresenceNode filter = new PresenceNode( OBJECT_CLASS_AT );
         SearchControls ctls = new SearchControls();
         ctls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
@@ -1443,7 +1443,7 @@ public abstract class ServerContext impl
          */
 
         // 1). Find the Dn for name and walk it from the head to tail
-        DN fqn = buildTarget( DN.fromName( name ) );
+        DN fqn = buildTarget( JndiUtils.fromName( name ) );
         String head = prefix.get( 0 );
 
         // 2). Walk the fqn trying to match for the head of the prefix
@@ -1452,7 +1452,7 @@ public abstract class ServerContext impl
             // match found end loop
             if ( fqn.get( 0 ).equalsIgnoreCase( head ) )
             {
-                return DN.toName( fqn );
+                return JndiUtils.toName( fqn );
             }
             else
             // 2). Remove name components from the Dn until a match
@@ -1488,7 +1488,7 @@ public abstract class ServerContext impl
             criteria.setFilter( filter );
             criteria.setScope( SearchScope.getSearchScope( scope ) );
             criteria.setAliasDerefMode( AliasDerefMode.getEnum( env ) );
-            criteria.setBase( buildTarget( DN.fromName( name ) ) );
+            criteria.setBase( buildTarget( JndiUtils.fromName( name ) ) );
 
             service.getEventService().addListener( listener );
             listeners.put( namingListener, listener );

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=982648&r1=982647&r2=982648&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 Thu Aug  5 14:55:09 2010
@@ -149,7 +149,7 @@ public abstract class ServerDirContext e
 
         try
         {
-            attrs = ServerEntryUtils.toBasicAttributes( doLookupOperation( buildTarget( DN.fromName( name ) ) ) );
+            attrs = ServerEntryUtils.toBasicAttributes( doLookupOperation( buildTarget( JndiUtils.fromName( name ) ) ) );
         }
         catch ( Exception e )
         {
@@ -179,7 +179,7 @@ public abstract class ServerDirContext e
         Attributes attrs = null;
         try
         {
-            attrs = ServerEntryUtils.toBasicAttributes( doLookupOperation( buildTarget( DN.fromName( name ) ), attrIds ) );
+            attrs = ServerEntryUtils.toBasicAttributes( doLookupOperation( buildTarget( JndiUtils.fromName( name ) ), attrIds ) );
         }
         catch ( Exception e )
         {
@@ -238,7 +238,7 @@ public abstract class ServerDirContext e
 
         try
         {
-            doModifyOperation( buildTarget( DN.fromName( name ) ), newMods );
+            doModifyOperation( buildTarget( JndiUtils.fromName( name ) ), newMods );
         }
         catch( Exception e )
         {
@@ -277,7 +277,7 @@ public abstract class ServerDirContext e
 
         try
         {
-            doModifyOperation( buildTarget( DN.fromName( name ) ), newMods );
+            doModifyOperation( buildTarget( JndiUtils.fromName( name ) ), newMods );
         }
         catch ( Exception e )
         {
@@ -306,7 +306,7 @@ public abstract class ServerDirContext e
 
         try
         {
-            doModifyOperation( buildTarget( DN.fromName( name ) ), newMods );
+            doModifyOperation( buildTarget( JndiUtils.fromName( name ) ), newMods );
         }
         catch ( Exception e )
         {
@@ -343,7 +343,7 @@ public abstract class ServerDirContext e
             return;
         }
 
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
 
         Entry serverEntry = null;
 
@@ -526,7 +526,7 @@ public abstract class ServerDirContext e
      */
     public void rebind( Name name, Object obj, Attributes attrs ) throws NamingException
     {
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
 
         try
         {
@@ -566,7 +566,7 @@ public abstract class ServerDirContext e
             return ( DirContext ) super.createSubcontext( name );
         }
 
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
         RDN rdn = target.getRdn( target.size() - 1 );
 
         attrs = AttributeUtils.toCaseInsensitive( attrs );
@@ -626,7 +626,7 @@ public abstract class ServerDirContext e
 
         try
         {
-            ctx = new ServerLdapContext( getService(), getSession().getEffectivePrincipal(), DN.toName( target ) );
+            ctx = new ServerLdapContext( getService(), getSession().getEffectivePrincipal(), JndiUtils.toName( target ) );
         }
         catch ( Exception e )
         {
@@ -717,7 +717,7 @@ public abstract class ServerDirContext e
         throws NamingException
     {
         SearchControls ctls = new SearchControls();
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
 
         // If we need to return specific attributes add em to the SearchControls
         if ( null != attributesToReturn )
@@ -861,7 +861,7 @@ public abstract class ServerDirContext e
     public NamingEnumeration<SearchResult> search( Name name, ExprNode filter, SearchControls cons )
         throws NamingException
     {
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
         AliasDerefMode aliasDerefMode = AliasDerefMode.getEnum( getEnvironment() );
         try
         {
@@ -883,7 +883,7 @@ public abstract class ServerDirContext e
         throws NamingException
     {
         ExprNode filterNode;
-        DN target = buildTarget( DN.fromName( name ) );
+        DN target = buildTarget( JndiUtils.fromName( name ) );
 
         try
         {
@@ -1020,7 +1020,7 @@ public abstract class ServerDirContext e
             criteria.setFilter( filter );
             criteria.setScope( SearchScope.getSearchScope( searchControls.getSearchScope() ) );
             criteria.setAliasDerefMode( AliasDerefMode.getEnum( getEnvironment() ) );
-            criteria.setBase( buildTarget( DN.fromName( name ) ) );
+            criteria.setBase( buildTarget( JndiUtils.fromName( name ) ) );
 
             getDirectoryService().getEventService().addListener( listener );
             getListeners().put( namingListener, listener );

Modified: directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java (original)
+++ directory/apacheds/trunk/core-jndi/src/main/java/org/apache/directory/server/core/jndi/ServerLdapContext.java Thu Aug  5 14:55:09 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.server.core.jndi;
 
@@ -75,7 +75,7 @@ public class ServerLdapContext extends S
      * @param principal the directory user principal that is propagated
      * @param dn the distinguished name of this context
      * @param service the directory service core
-     * @throws NamingException if there are problems instantiating 
+     * @throws NamingException if there are problems instantiating
      */
     public ServerLdapContext( DirectoryService service, LdapPrincipal principal, Name dn ) throws Exception
     {
@@ -106,16 +106,16 @@ public class ServerLdapContext extends S
     public LdapContext newInstance( Control[] requestControls ) throws NamingException
     {
         ServerLdapContext ctx = null;
-        
+
         try
         {
-            ctx = new ServerLdapContext( getService(), getSession().getEffectivePrincipal(), DN.toName( getDn() ) );
+            ctx = new ServerLdapContext( getService(), getSession().getEffectivePrincipal(), JndiUtils.toName( getDn() ) );
         }
         catch ( Exception e )
         {
             JndiUtils.wrap( e );
         }
-        
+
         ctx.setRequestControls( requestControls );
         return ctx;
     }
@@ -187,9 +187,9 @@ public class ServerLdapContext extends S
     public boolean compare( DN name, String oid, Object value ) throws NamingException
     {
         Value<?> val = null;
-        
+
         AttributeType attributeType = null;
-        
+
         try
         {
             attributeType = getService().getSchemaManager().lookupAttributeTypeRegistry( oid );
@@ -198,7 +198,7 @@ public class ServerLdapContext extends S
         {
             throw new InvalidAttributeIdentifierException( le.getMessage() );
         }
-        
+
         // make sure we add the request controls to operation
         if ( attributeType.getSyntax().isHumanReadable() )
         {
@@ -230,11 +230,11 @@ public class ServerLdapContext extends S
                 throw new NamingException( I18n.err( I18n.ERR_309, oid ) );
             }
         }
-        
-        
+
+
         CompareOperationContext opCtx = new CompareOperationContext( getSession(), name, oid, val );
         opCtx.addRequestControls( JndiUtils.fromJndiControls( requestControls ) );
-        
+
         // Inject the Referral flag
         injectReferralControl( opCtx );
 
@@ -248,7 +248,7 @@ public class ServerLdapContext extends S
         {
             JndiUtils.wrap( e );
         }
-        
+
         // extract the response controls from the operation and return
         responseControls = getResponseControls();
         requestControls = EMPTY_CONTROLS;
@@ -257,11 +257,11 @@ public class ServerLdapContext extends S
 
 
     /**
-     * Calling this method tunnels an unbind call down into the partition holding 
+     * Calling this method tunnels an unbind call down into the partition holding
      * the bindDn.  The bind() counter part is not exposed because it is automatically
-     * called when you create a new initial context for a new connection (on wire) or 
+     * called when you create a new initial context for a new connection (on wire) or
      * (programatic) caller.
-     * 
+     *
      * @throws NamingException if there are failures encountered while unbinding
      */
     public void ldapUnbind() throws NamingException
@@ -277,7 +277,7 @@ public class ServerLdapContext extends S
         {
             JndiUtils.wrap( e );
         }
-        
+
         responseControls = JndiUtils.toJndiControls( opCtx.getResponseControls() );
         requestControls = EMPTY_CONTROLS;
     }
@@ -286,7 +286,7 @@ public class ServerLdapContext extends S
     public ServerContext getRootContext() throws NamingException
     {
         ServerContext ctx = null;
-        
+
         try
         {
             ctx = new ServerLdapContext( getService(), getSession().getEffectivePrincipal(), new LdapName( "" ) );
@@ -295,7 +295,7 @@ public class ServerLdapContext extends S
         {
             JndiUtils.wrap( e );
         }
-        
+
         return ctx;
     }
 }

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Thu Aug  5 14:55:09 2010
@@ -6,16 +6,16 @@
  *  to you under the Apache License, Version 2.0 (the
  *  "License"); you may not use this file except in compliance
  *  with the License.  You may obtain a copy of the License at
- *  
+ *
  *    http://www.apache.org/licenses/LICENSE-2.0
- *  
+ *
  *  Unless required by applicable law or agreed to in writing,
  *  software distributed under the License is distributed on an
  *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  *  KIND, either express or implied.  See the License for the
  *  specific language governing permissions and limitations
- *  under the License. 
- *  
+ *  under the License.
+ *
  */
 package org.apache.directory.server.core.partition.impl.btree.jdbm;
 
@@ -87,7 +87,7 @@ public class JdbmStoreTest
     private static SchemaManager schemaManager = null;
     private static LdifSchemaLoader loader;
     private static DN EXAMPLE_COM;
-    
+
     /** The OU AttributeType instance */
     private static AttributeType OU_AT;
 
@@ -127,7 +127,7 @@ public class JdbmStoreTest
         }
 
         EXAMPLE_COM = new DN( "dc=example,dc=com", schemaManager );
-        
+
         OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT );
         DC_AT = schemaManager.getAttributeType( SchemaConstants.DC_AT );
         SN_AT = schemaManager.getAttributeType( SchemaConstants.SN_AT );
@@ -216,7 +216,7 @@ public class JdbmStoreTest
         // lookup the context entry
         Long id = store2.getEntryId( suffixDn );
         Entry lookup = store2.lookup( id );
-        assertEquals( 2, lookup.getDn().getRdns().size() );
+        assertEquals( 2, lookup.getDn().size() );
     }
 
 
@@ -400,7 +400,7 @@ public class JdbmStoreTest
 
         assertFalse( systemIndices.hasNext() );
         assertNotNull( store.getSystemIndex( APACHE_ALIAS_AT ) );
-        
+
         try
         {
             store.getSystemIndex( "bogus" );
@@ -574,7 +574,7 @@ public class JdbmStoreTest
         assertEquals( 12, ( long ) cursor.get().getId() );
 
         DN newParentDn = new DN( "ou=Board of Directors,o=Good Times Co.", schemaManager );
-        
+
         DN newDn = newParentDn.add( martinDn.getRdn() );
 
         store.move( martinDn, newParentDn, newDn, entry );
@@ -641,7 +641,7 @@ public class JdbmStoreTest
         // so this gets cleaned up automatically
         File testSpecificDir = new File( wkdir, "testConvertIndex" );
         testSpecificDir.mkdirs();
-        
+
         Index nonJdbmIndex = new GenericIndex( "ou", 10,  testSpecificDir );
 
         Method convertIndex = store.getClass().getDeclaredMethod( "convertAndInit", Index.class );
@@ -756,7 +756,7 @@ public class JdbmStoreTest
 
         store.moveAndRename( childDn, parentDn, rdn, childEntry, true );
 
-        // to drop the alias indices   
+        // to drop the alias indices
         childDn = new DN( "commonName=Jim Bean,ou=Apache,ou=Board of Directors,o=Good Times Co.", schemaManager );
 
         parentDn = new DN( "ou=Engineering,o=Good Times Co.", schemaManager );
@@ -764,7 +764,7 @@ public class JdbmStoreTest
         assertEquals( 3, store.getSubAliasIndex().count() );
 
         DN newDn = parentDn.add( childDn.getRdn() );
-        
+
         store.move( childDn, parentDn, newDn, childEntry );
 
         assertEquals( 4, store.getSubAliasIndex().count() );
@@ -891,8 +891,8 @@ public class JdbmStoreTest
         store.modify( dn, mods );
         assertEquals( attribVal, lookedup.get( "ou" ).get().getString() );
     }
-    
-    
+
+
     @Test
     public void testDeleteUnusedIndexFiles() throws Exception
     {
@@ -900,22 +900,22 @@ public class JdbmStoreTest
         File ouIndexTxtFile = new File( wkdir, SchemaConstants.OU_AT_OID + "-ou.txt" );
         File uuidIndexDbFile = new File( wkdir, SchemaConstants.ENTRY_UUID_AT_OID + ".db" );
         File uuidIndexTxtFile = new File( wkdir, SchemaConstants.ENTRY_UUID_AT_OID + "-entryUUID.txt" );
-        
+
         assertTrue( ouIndexDbFile.exists() );
         assertTrue( ouIndexTxtFile.exists() );
         assertTrue( uuidIndexDbFile.exists() );
         assertTrue( uuidIndexTxtFile.exists() );
-        
+
         // destroy the store to manually start the init phase
         // by keeping the same work dir
         store.destroy();
-        
+
         // just assert again that ou and entryUUID files exist even after destroying the store
         assertTrue( ouIndexDbFile.exists() );
         assertTrue( ouIndexTxtFile.exists() );
         assertTrue( uuidIndexDbFile.exists() );
         assertTrue( uuidIndexTxtFile.exists() );
-        
+
         store = new JdbmStore<Entry>();
         store.setId( "example" );
         store.setCacheSize( 10 );
@@ -924,7 +924,7 @@ public class JdbmStoreTest
         // do not add ou index this time
         store.addIndex( new JdbmIndex( SchemaConstants.UID_AT_OID ) );
 
-        
+
         DN suffixDn = new DN( "o=Good Times Co.", schemaManager );
         store.setSuffixDn( suffixDn );
         // init the store to call deleteUnusedIndexFiles() method
@@ -936,5 +936,5 @@ public class JdbmStoreTest
         assertTrue( uuidIndexDbFile.exists() );
         assertTrue( uuidIndexTxtFile.exists() );
     }
-    
+
 }

Modified: directory/shared/trunk/ldap-jndi/src/main/java/org/apache/directory/shared/ldap/jndi/JndiUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-jndi/src/main/java/org/apache/directory/shared/ldap/jndi/JndiUtils.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/shared/trunk/ldap-jndi/src/main/java/org/apache/directory/shared/ldap/jndi/JndiUtils.java (original)
+++ directory/shared/trunk/ldap-jndi/src/main/java/org/apache/directory/shared/ldap/jndi/JndiUtils.java Thu Aug  5 14:55:09 2010
@@ -44,6 +44,7 @@ import javax.naming.directory.InvalidSea
 import javax.naming.directory.NoSuchAttributeException;
 import javax.naming.directory.SchemaViolationException;
 import javax.naming.ldap.BasicControl;
+import javax.naming.ldap.LdapName;
 
 import org.apache.directory.shared.ldap.codec.controls.ControlImpl;
 import org.apache.directory.shared.ldap.exception.LdapAffectMultipleDsaException;
@@ -86,23 +87,23 @@ public class JndiUtils
     {
         byte[] value = control.getValue();
         javax.naming.ldap.Control jndiControl = new BasicControl( control.getOid(), control.isCritical(), value );
-        
+
         return jndiControl;
     }
-    
-    
+
+
     public static javax.naming.ldap.Control[] toJndiControls( Control... controls )
     {
         if ( controls != null )
         {
             javax.naming.ldap.Control[] jndiControls = new javax.naming.ldap.Control[controls.length];
             int i = 0;
-            
+
             for ( Control control : controls )
             {
                 jndiControls[i++] = toJndiControl( control );
             }
-            
+
             return jndiControls;
         }
         else
@@ -110,30 +111,30 @@ public class JndiUtils
             return null;
         }
     }
-    
-    
+
+
     public static Control fromJndiControl( javax.naming.ldap.Control jndiControl )
     {
         Control control = new ControlImpl( jndiControl.getID() );
-        
+
         control.setValue( jndiControl.getEncodedValue() );
 
         return control;
     }
-    
-    
+
+
     public static Control[] fromJndiControls( javax.naming.ldap.Control... jndiControls )
     {
         if ( jndiControls != null )
         {
             Control[] controls = new Control[jndiControls.length];
             int i = 0;
-            
+
             for ( javax.naming.ldap.Control jndiControl : jndiControls )
             {
                 controls[i++] = fromJndiControl( jndiControl );
             }
-            
+
             return controls;
         }
         else
@@ -141,17 +142,17 @@ public class JndiUtils
             return null;
         }
     }
-    
-    
+
+
     public static void wrap( Throwable t ) throws NamingException
     {
         if ( t instanceof NamingException )
         {
             throw ( NamingException ) t;
         }
-        
+
         NamingException ne = null;
-        
+
         if ( t instanceof LdapAffectMultipleDsaException )
         {
             ne = new NamingException( t.getLocalizedMessage() );
@@ -256,111 +257,156 @@ public class JndiUtils
         {
             ne = new NamingException( t.getLocalizedMessage() );
         }
-        
+
         ne.setRootCause( t );
-        
+
         throw ne;
     }
+
+
+    /**
+     * Convert a DN to a {@link javax.naming.Name}
+     *
+     * @param name The DN to convert
+     * @return A Name
+     */
+    public static Name toName( DN dn )
+    {
+        try
+        {
+            Name name = new LdapName( dn.toString() );
+
+            return name;
+        }
+        catch ( InvalidNameException ine )
+        {
+            // TODO : check if we must throw an exception.
+            // Logically, the DN must be valid.
+            return null;
+        }
+    }
+
+
+    /**
+     * Convert a {@link javax.naming.Name} to a DN
+     *
+     * @param name The Name to convert
+     * @return A DN
+     */
+    public static DN fromName( Name name )
+    {
+        try
+        {
+            DN dn = new DN( name.toString() );
+
+            return dn;
+        }
+        catch ( LdapInvalidDnException lide )
+        {
+            // TODO : check if we must throw an exception.
+            // Logically, the Name must be valid.
+            return null;
+        }
+    }
 }
 
-// a ReferralException around the LdapReferralException to be used in tests 
+// a ReferralException around the LdapReferralException to be used in tests
 class WrappedReferralException extends ReferralException
 {
     private static final long serialVersionUID = 1L;
-    
+
     private LdapReferralException lre;
-    
+
     public WrappedReferralException( LdapReferralException lre )
     {
         this.lre = lre;
     }
-    
+
     @Override
     public boolean skipReferral()
     {
         return lre.skipReferral();
     }
-    
+
 
     @Override
     public void retryReferral()
     {
         lre.retryReferral();
     }
-    
+
 
     @Override
     public Object getReferralInfo()
     {
         return lre.getReferralInfo();
     }
-    
+
 
     @Override
     public Context getReferralContext( Hashtable<?, ?> env ) throws NamingException
     {
         return lre.getReferralContext( env );
     }
-    
+
 
     @Override
     public Context getReferralContext() throws NamingException
     {
         return lre.getReferralContext();
     }
-    
+
     @Override
     public Name getRemainingName()
     {
-        return DN.toName( lre.getRemainingDn() );
+        return JndiUtils.toName( lre.getRemainingDn() );
     }
-    
-    
+
+
     @Override
     public Object getResolvedObj()
     {
         return lre.getResolvedObject();
     }
-    
-    
+
+
     @Override
     public Name getResolvedName()
     {
-        // TODO Auto-generated method stub
-        return DN.toName( lre.getResolvedDn() );
+        return JndiUtils.toName( lre.getResolvedDn() );
     }
 }
 
 
-// a PartialResultException around the LdapPartialResultException to be used in tests 
+// a PartialResultException around the LdapPartialResultException to be used in tests
 class WrappedPartialResultException extends PartialResultException
 {
     private static final long serialVersionUID = 1L;
- 
+
     private LdapPartialResultException lpre;
-     
+
     public WrappedPartialResultException( LdapPartialResultException lpre )
     {
         this.lpre = lpre;
     }
-     
+
     @Override
     public Name getRemainingName()
     {
-        return DN.toName( lpre.getRemainingDn() );
+        return JndiUtils.toName( lpre.getRemainingDn() );
     }
-     
-     
+
+
     @Override
     public Object getResolvedObj()
     {
         return lpre.getResolvedObject();
     }
-     
-     
+
+
     @Override
     public Name getResolvedName()
     {
-        return DN.toName( lpre.getResolvedDn() );
+        return JndiUtils.toName( lpre.getResolvedDn() );
     }
 }
\ No newline at end of file

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=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/antlr/ACIItem.g (original)
+++ directory/shared/trunk/ldap/src/main/antlr/ACIItem.g Thu Aug  5 14:55:09 2010
@@ -502,7 +502,7 @@ attributeValue
           attributeTypeAndValueSetAsDn.normalize( schemaManager );
         }
         
-        for ( RDN rdn :attributeTypeAndValueSetAsDn.getRdns() )
+        for ( RDN rdn : attributeTypeAndValueSetAsDn )
         {
             attributeTypeAndValue = rdn.getNormName();
             attributeType = NamespaceTools.getRdnAttribute( attributeTypeAndValue );

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=982648&r1=982647&r2=982648&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 Thu Aug  5 14:55:09 2010
@@ -23,17 +23,12 @@ package org.apache.directory.shared.ldap
 
 import java.io.Serializable;
 import java.util.ArrayList;
-import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.NoSuchElementException;
 import java.util.concurrent.atomic.AtomicBoolean;
 
-import javax.naming.InvalidNameException;
-import javax.naming.Name;
-import javax.naming.ldap.LdapName;
-
+import org.apache.commons.collections.list.UnmodifiableList;
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
@@ -92,6 +87,11 @@ public class DN implements Cloneable, Se
      *  The RDNs that are elements of the DN
      * NOTE THAT THESE ARE IN THE OPPOSITE ORDER FROM THAT IMPLIED BY THE JAVADOC!
      * Rdn[0] is rdns.get(n) and Rdn[n] is rdns.get(0)
+     * <br>
+     * For instance,if the DN is "dc=c, dc=b, dc=a", then the RDNs are stored as :
+     * [0] : dc=c
+     * [1] : dc=b
+     * [2] : dc=a
      */
     protected List<RDN> rdns = new ArrayList<RDN>( 5 );
 
@@ -110,6 +110,44 @@ public class DN implements Cloneable, Se
     /** the schema manager */
     private transient SchemaManager schemaManager;
 
+    /**
+     * An iterator over RDNs
+     */
+    private class RdnIterator implements Iterator<RDN>
+    {
+        // The current index
+        int index;
+
+        private RdnIterator()
+        {
+            index = rdns != null ? rdns.size() - 1 : -1;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public boolean hasNext()
+        {
+            return index >= 0;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public RDN next()
+        {
+            return index >= 0 ? rdns.get( index-- ) : null;
+        }
+
+        /**
+         * {@inheritDoc}
+         */
+        public void remove()
+        {
+            // Not implemented
+        }
+    }
+
     // ~ Methods
     // ------------------------------------------------------------------------------------
 
@@ -386,6 +424,9 @@ public class DN implements Cloneable, Se
 
     /**
      * Static factory which creates a normalized DN from a String and a Map of OIDs.
+     * <br>
+     * This method is for test purpose only, and as it's package protected, won't be usable
+     * out of this scope.
      *
      * @param name The DN as a String
      * @param oidsMap The OID mapping
@@ -393,7 +434,7 @@ public class DN implements Cloneable, Se
      * @throws LdapInvalidNameException If the DN is invalid.
      * @throws LdapInvalidDnException If something went wrong.
      */
-    public static DN normalize( String name, Map<String, OidNormalizer> oidsMap ) throws LdapInvalidDnException
+    /* No qualifier */ static DN normalize( String name, Map<String, OidNormalizer> oidsMap ) throws LdapInvalidDnException
     {
         if ( ( name == null ) || ( name.length() == 0 ) || ( oidsMap == null ) || ( oidsMap.isEmpty() ) )
         {
@@ -402,12 +443,8 @@ public class DN implements Cloneable, Se
 
         DN newDn = new DN( name );
 
-        Enumeration<RDN> rdns = newDn.getAllRdn();
-
-        // Loop on all RDNs
-        while ( rdns.hasMoreElements() )
+        for ( RDN rdn : newDn.rdns )
         {
-            RDN rdn = rdns.nextElement();
             String upName = rdn.getName();
             rdnOidToName( rdn, oidsMap );
             rdn.normalize();
@@ -962,58 +999,7 @@ public class DN implements Cloneable, Se
      */
     public List<RDN> getRdns()
     {
-        List<RDN> newRdns = new ArrayList<RDN>();
-
-        // We will clone the list, to avoid user modifications
-        for ( RDN rdn : rdns )
-        {
-            newRdns.add( ( RDN ) rdn.clone() );
-        }
-
-        return newRdns;
-    }
-
-
-    /**
-     * 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.
-     * This starts at the root (rightmost) rdn.
-     *
-     * @return an enumeration of the components of this name, as Rdn
-     */
-    public Enumeration<RDN> getAllRdn()
-    {
-        /*
-         * 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<RDN>()
-        {
-            private int pos;
-
-
-            public boolean hasMoreElements()
-            {
-                return pos < rdns.size();
-            }
-
-
-            public RDN 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;
-            }
-        };
+        return UnmodifiableList.decorate( rdns );
     }
 
 
@@ -1545,12 +1531,8 @@ public class DN implements Cloneable, Se
             return dn;
         }
 
-        Enumeration<RDN> rdns = dn.getAllRdn();
-
-        // Loop on all RDNs
-        while ( rdns.hasMoreElements() )
+        for ( RDN rdn : dn.rdns )
         {
-            RDN rdn = rdns.nextElement();
             String upName = rdn.getName();
             rdnOidToName( rdn, oidsMap );
             rdn.normalize();
@@ -1601,13 +1583,8 @@ public class DN implements Cloneable, Se
                 return this;
             }
 
-            Enumeration<RDN> localRdns = getAllRdn();
-
-            // Loop on all RDNs
-            while ( localRdns.hasMoreElements() )
+            for ( RDN rdn : rdns )
             {
-                RDN rdn = localRdns.nextElement();
-
                 rdn.normalize( oidsMap );
             }
 
@@ -1672,56 +1649,10 @@ public class DN implements Cloneable, Se
 
 
     /**
-     * Convert a {@link javax.naming.Name} to a DN
-     *
-     * @param name The Name to convert
-     * @return A DN
-     */
-    public static DN fromName( Name name )
-    {
-        try
-        {
-            DN dn = new DN( name.toString() );
-
-            return dn;
-        }
-        catch ( LdapInvalidDnException lide )
-        {
-            // TODO : check if we must throw an exception.
-            // Logically, the Name must be valid.
-            return null;
-        }
-    }
-
-
-    /**
-     * Convert a DN to a {@link javax.naming.Name}
-     *
-     * @param name The DN to convert
-     * @return A Name
-     */
-    public static Name toName( DN dn )
-    {
-        try
-        {
-            Name name = new LdapName( dn.toString() );
-
-            return name;
-        }
-        catch ( InvalidNameException ine )
-        {
-            // TODO : check if we must throw an exception.
-            // Logically, the DN must be valid.
-            return null;
-        }
-    }
-
-
-    /**
      * {@inheritDoc}
      */
     public Iterator<RDN> iterator()
     {
-        return rdns.iterator();
+        return new RdnIterator();
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java?rev=982648&r1=982647&r2=982648&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/tree/DnNode.java Thu Aug  5 14:55:09 2010
@@ -92,7 +92,7 @@ public class DnNode<N>
         DnNode<N> rootNode = null;
 
         // No parent : add from the current position
-        for ( RDN rdn : dn )
+        for ( RDN rdn : dn.getRdns() )
         {
             if ( nbRdns == 0 )
             {
@@ -478,7 +478,7 @@ public class DnNode<N>
         // Ok, no children, same DN, let's remove what we can.
         parent = parent.getParent();
 
-        for ( RDN rdn : dn )
+        for ( RDN rdn : dn.getRdns() )
         {
             parent.children.remove( rdn );
 

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=982648&r1=982647&r2=982648&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 Thu Aug  5 14:55:09 2010
@@ -1963,10 +1963,10 @@ public class DNTest
      *             if anything goes wrong.
      */
     @Test
-    public void testGetAllRdn() throws Exception
+    public void testIterator() throws Exception
     {
         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" };
+        String[] expected = new String[]{ "ou=West", "ou=Marketing", "cn=John", "cn=HomeDir", "cn=Website", "cn=Airline" };
         int count = 0;
 
         for ( RDN rdn : dn )
@@ -2017,7 +2017,7 @@ public class DNTest
 
         int i = 0;
 
-        for ( RDN rdn : dn )
+        for ( RDN rdn : dn.getRdns() )
         {
             assertEquals( expected[i], rdn.getName() );
             i++;
@@ -2272,13 +2272,13 @@ public class DNTest
         assertEquals( name, new DN( "" ) );
 
         DN name4 = new DN( "ou=East" );
-        
+
         assertTrue( name.isNormalized() );
 
         name = name.add( "ou=East" );
-        
+
         assertFalse( name.isNormalized() );
-        
+
         assertEquals( name4, name );
 
         DN name3 = new DN( "ou=Marketing,ou=East" );
@@ -3671,7 +3671,7 @@ public class DNTest
 
         String[] expected = new String[]{ "sn=joe+cn=doe", "dc=apache", "dc=org" };
 
-        for ( RDN rdn : dn )
+        for ( RDN rdn : dn.getRdns() )
         {
             assertEquals( expected[count], rdn.getName() );
             count++;
@@ -3711,17 +3711,17 @@ public class DNTest
         assertTrue( dn.isChildOf( parent3 ) );
         assertFalse( notParent.isChildOf( dn ) );
     }
-    
-    
+
+
     @Test
     public void testNormalize() throws Exception
     {
         DN dn = new DN( "ou=system" );
         assertFalse( dn.isNormalized() );
-        
+
         dn = dn.add( "ou=users" );
         assertFalse( dn.isNormalized() );
-        
+
         dn.normalize( oidOids );
         assertTrue( dn.isNormalized() );
 
@@ -3730,29 +3730,29 @@ public class DNTest
 
         assertEquals( "ou=x,2.5.4.11=users,2.5.4.11=system", dn.getNormName() );
         assertEquals( "ou=x,ou=users,ou=system", dn.getName() );
-        
+
         dn.normalize( oidOids );
         assertEquals( "2.5.4.11=x,2.5.4.11=users,2.5.4.11=system", dn.getNormName() );
         assertEquals( "ou=x,ou=users,ou=system", dn.getName() );
-        
+
         RDN rdn = new RDN( "ou=system" );
         dn = new DN();
         assertTrue( dn.isNormalized() );
-        
+
         dn = dn.add( rdn );
         assertFalse( dn.isNormalized() );
-        
+
         dn.normalize( oidOids );
         assertTrue( dn.isNormalized() );
-        
+
         DN anotherDn = new DN( "ou=x,ou=users" );
-        
+
         dn = dn.addAll( anotherDn );
         assertFalse( dn.isNormalized() );
-        
+
         dn.normalize( oidOids );
         assertTrue( dn.isNormalized() );
-        
+
         dn = dn.remove( 0 );
         assertTrue( dn.isNormalized() );
     }



Mime
View raw message