directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r980965 [3/3] - in /directory/shared/trunk: all/ asn1-codec/ asn1/ cursor/ dsml-parser/ dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/ dsml-parser/src/main/java/org/apache/directory/shared/dsmlv2/engine/ dsml-parser/src/main/...
Date Fri, 30 Jul 2010 21:08:08 GMT
Propchange: directory/shared/trunk/dsml-parser/src/test/resources/org/apache/directory/shared/dsmlv2/searchResponse/searchResultReference/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -1,4 +1,7 @@
+/directory/shared/branches-dnfactory-experiment/dsml-parser/src/test/resources/org/apache/directory/shared/dsmlv2/searchResponse/searchResultReference:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/dsml-parser/src/test/resources/org/apache/directory/shared/dsmlv2/searchResponse/searchResultReference:980352-980933
 /directory/shared/branches/shared-replication/dsml-parser/src/test/resources/org/apache/directory/studio/dsmlv2/searchResponse/searchResultReference:749791-764113
 /directory/shared/branches/shared-schema/dsml-parser/src/test/resources/org/apache/directory/shared/dsmlv2/searchResponse/searchResultReference:806622-896441
 /directory/shared/branches/shared-subtree/dsml-parser/src/test/resources/org/apache/directory/shared/dsmlv2/searchResponse/searchResultReference:965208-965686
 /directory/shared/branches/xdbm-refactoring/dsml-parser/src/test/resources/org/apache/directory/shared/dsmlv2/searchResponse/searchResultReference:945830-946347
+/directory/shared/trunk/dsml-parser/src/test/resources/org/apache/directory/shared/dsmlv2/searchResponse/searchResultReference:980025-980349

Propchange: directory/shared/trunk/i18n/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,3 @@
+/directory/shared/branches-dnfactory-experiment/i18n:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/i18n:980352-980933
+/directory/shared/trunk/i18n:980025-980349

Propchange: directory/shared/trunk/ldap/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,2 @@
+/directory/shared/branches-dnfactory-experiment/ldap:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap:980352-980933

Propchange: directory/shared/trunk/ldap-constants/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,2 @@
+/directory/shared/branches-dnfactory-experiment/ldap-constants:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-constants:980352-980933

Propchange: directory/shared/trunk/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -1,3 +1,5 @@
 /directory/apacheds/branches/apacheds-replication/core-constants/src/main/java/org/apache/directory/server/constants/MetaSchemaConstants.java:749790-764110
+/directory/shared/branches-dnfactory-experiment/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java:980352-980933
 /directory/shared/branches/shared-subtree/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-constants/src/main/java/org/apache/directory/shared/ldap/constants/MetaSchemaConstants.java:945830-946347

Propchange: directory/shared/trunk/ldap-convert/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,3 @@
+/directory/shared/branches-dnfactory-experiment/ldap-convert:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-convert:980352-980933
+/directory/shared/trunk/ldap-convert:980025-980349

Propchange: directory/shared/trunk/ldap-jndi/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,3 @@
+/directory/shared/branches-dnfactory-experiment/ldap-jndi:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-jndi:980352-980933
+/directory/shared/trunk/ldap-jndi:980025-980349

Propchange: directory/shared/trunk/ldap-ldif/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,2 @@
+/directory/shared/branches-dnfactory-experiment/ldap-ldif:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-ldif:980352-980933

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java?rev=980965&r1=980964&r2=980965&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifEntry.java Fri Jul 30 21:08:04 2010
@@ -112,7 +112,7 @@ public class LdifEntry implements Clonea
      */
     public void setDn( DN dn )
     {
-        entry.setDn( (DN)dn.clone() );
+        entry.setDn( dn );
     }
 
     

Modified: directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java?rev=980965&r1=980964&r2=980965&view=diff
==============================================================================
--- directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java (original)
+++ directory/shared/trunk/ldap-ldif/src/main/java/org/apache/directory/shared/ldap/ldif/LdifRevertor.java Fri Jul 30 21:08:04 2010
@@ -268,12 +268,12 @@ public class LdifRevertor
             throw new IllegalArgumentException( I18n.err( I18n.ERR_12076 ) );
         }
 
-        currentParent = ( DN ) modifiedDn.clone();
+        currentParent = modifiedDn;
         currentRdn = currentParent.getRdn();
-        currentParent.remove( currentParent.size() - 1 );
+        currentParent = currentParent.remove( currentParent.size() - 1 );
 
-        newDn = ( DN ) newSuperiorDn.clone();
-        newDn.add( modifiedDn.getRdn() );
+        newDn = newSuperiorDn;
+        newDn = newDn.add( modifiedDn.getRdn() );
 
         entry.setChangeType( ChangeType.ModDn );
         entry.setDn( newDn );
@@ -298,7 +298,7 @@ public class LdifRevertor
         
         if ( newSuperior != null )
         {
-            DN restoredDn = (DN)((DN)newSuperior.clone()).add( newRdn ); 
+            DN restoredDn = newSuperior.add( newRdn ); 
             reverted.setDn( restoredDn );
         }
         else
@@ -317,9 +317,9 @@ public class LdifRevertor
         
         if ( newSuperior != null )
         {
-            DN oldSuperior = ( DN ) entry.getDn().clone();
+            DN oldSuperior = entry.getDn();
 
-            oldSuperior.remove( oldSuperior.size() - 1 );
+            oldSuperior = oldSuperior.remove( oldSuperior.size() - 1 );
             reverted.setNewSuperior( oldSuperior.getName() );
         }
 
@@ -371,7 +371,7 @@ public class LdifRevertor
 
         if ( newSuperior != null )
         {
-            DN restoredDn = (DN)((DN)newSuperior.clone()).add( newRdn ); 
+            DN restoredDn = newSuperior.add( newRdn ); 
             reverted.setDn( restoredDn );
         }
         else
@@ -383,9 +383,9 @@ public class LdifRevertor
         
         if ( newSuperior != null )
         {
-            DN oldSuperior = ( DN ) newDn.clone();
+            DN oldSuperior = newDn;
 
-            oldSuperior.remove( oldSuperior.size() - 1 );
+            oldSuperior = oldSuperior.remove( oldSuperior.size() - 1 );
             reverted.setNewSuperior( oldSuperior.getName() );
         }
         
@@ -445,12 +445,12 @@ public class LdifRevertor
             throw new IllegalArgumentException( I18n.err( I18n.ERR_12079 ) );
         }
 
-        parentDn = ( DN ) entry.getDn().clone();
+        parentDn = entry.getDn();
         RDN oldRdn = parentDn.getRdn();
 
-        newDn = ( DN ) parentDn.clone();
-        newDn.remove( newDn.size() - 1 );
-        newDn.add( newRdn );
+        newDn = parentDn;
+        newDn = newDn.remove( newDn.size() - 1 );
+        newDn = newDn.add( newRdn );
 
         List<LdifEntry> entries = new ArrayList<LdifEntry>( 1 );
         LdifEntry reverted = new LdifEntry();

Propchange: directory/shared/trunk/ldap-schema/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -1,5 +1,8 @@
 /directory/apacheds/branches/apacheds-replication/schema-data:749790-764110
+/directory/shared/branches-dnfactory-experiment/ldap-schema:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-schema:980352-980933
 /directory/shared/branches/shared-replication/ldap-schema:749791-764113
 /directory/shared/branches/shared-schema/ldap-schema:806622-896441
 /directory/shared/branches/shared-subtree/ldap-schema:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema:945830-946347
+/directory/shared/trunk/ldap-schema:980025-980349

Propchange: directory/shared/trunk/ldap-schema-loader/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -1,5 +1,8 @@
 /directory/apacheds/branches/apacheds-replication/schema-loader:749790-764110
+/directory/shared/branches-dnfactory-experiment/ldap-schema-loader:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-schema-loader:980352-980933
 /directory/shared/branches/shared-replication/ldap-schema-loader:749791-764113
 /directory/shared/branches/shared-schema/ldap-schema-loader:806622-896441
 /directory/shared/branches/shared-subtree/ldap-schema-loader:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema-loader:945830-946347
+/directory/shared/trunk/ldap-schema-loader:980025-980349

Propchange: directory/shared/trunk/ldap-schema-manager/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,3 @@
+/directory/shared/branches-dnfactory-experiment/ldap-schema-manager:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-schema-manager:980352-980933
+/directory/shared/trunk/ldap-schema-manager:980025-980349

Propchange: directory/shared/trunk/ldap-schema-manager-tests/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -0,0 +1,3 @@
+/directory/shared/branches-dnfactory-experiment/ldap-schema-manager-tests:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-schema-manager-tests:980352-980933
+/directory/shared/trunk/ldap-schema-manager-tests:980025-980349

Propchange: directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -1,5 +1,7 @@
+/directory/shared/branches-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:980352-980933
 /directory/shared/branches/shared-replication/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:749791-764113
 /directory/shared/branches/shared-schema/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:806622-893998
 /directory/shared/branches/shared-subtree/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:945830-946347
-/directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:806622-894844*
+/directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager:806622-894844*,980025-980349

Propchange: directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -1,5 +1,7 @@
+/directory/shared/branches-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:980352-980933
 /directory/shared/branches/shared-replication/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:749791-764113
 /directory/shared/branches/shared-schema/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:806622-893998
 /directory/shared/branches/shared-subtree/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:945830-946347
-/directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:806622-894844*
+/directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl:806622-894844*,980025-980349

Propchange: directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jul 30 21:08:04 2010
@@ -1,5 +1,7 @@
+/directory/shared/branches-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:980350-980351
+/directory/shared/branches/shared-dnfactory-experiment/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:980352-980933
 /directory/shared/branches/shared-replication/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:749791-764113
 /directory/shared/branches/shared-schema/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:806622-893998
 /directory/shared/branches/shared-subtree/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:965208-965686
 /directory/shared/branches/xdbm-refactoring/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:945830-946347
-/directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:806622-894844
+/directory/shared/trunk/ldap-schema-manager/src/main/java/org/apache/directory/shared/ldap/schema/manager/impl/DefaultSchemaManager.java:806622-894844,980025-980349

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java?rev=980965&r1=980964&r2=980965&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/entry/DefaultEntry.java Fri Jul 30 21:08:04 2010
@@ -199,7 +199,7 @@ public class DefaultEntry implements Ent
         // We will clone the existing entry, because it may be normalized
         if ( entry.getDn() != null )
         {
-            dn = ( DN ) entry.getDn().clone();
+            dn = entry.getDn();
         }
         else
         {
@@ -982,11 +982,7 @@ public class DefaultEntry implements Ent
             }
 
             // An Entry has a DN and many attributes.
-            // First, clone the DN, if not null.
-            if ( dn != null )
-            {
-                clone.dn = ( DN ) dn.clone();
-            }
+            clone.dn = dn; // note that DN is immutable now
 
             // then clone the ClientAttribute Map.
             clone.attributes = ( Map<String, EntryAttribute> ) ( ( ( HashMap<String, EntryAttribute> ) attributes )
@@ -2692,14 +2688,14 @@ public class DefaultEntry implements Ent
     public void deserialize( ObjectInput in ) throws IOException, ClassNotFoundException
     {
         // Read the DN
-        dn = new DN();
+        dn = DN.EMPTY_DN;
 
         byte b = in.readByte();
 
         if ( b == 1 )
         {
             RDN rdn = RdnSerializer.deserialize( in );
-            dn.add( rdn );
+            dn = new DN( rdn );
         }
 
         // Read the number of attributes

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=980965&r1=980964&r2=980965&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 Fri Jul 30 21:08:04 2010
@@ -50,7 +50,7 @@ import org.slf4j.LoggerFactory;
 
 
 /**
- * The DN class contains a DN (Distinguished Name).
+ * The DN class contains a DN (Distinguished Name). This class is immutable.
  *
  * Its specification can be found in RFC 2253,
  * "UTF-8 String Representation of Distinguished Names".
@@ -133,7 +133,7 @@ public class DN implements Cloneable, Se
     {
         this.schemaManager = schemaManger;
         upName = "";
-        normName = null;
+        normName = "";
         normalized = true;
     }
 
@@ -163,20 +163,39 @@ public class DN implements Cloneable, Se
             for ( int ii = 0; ii < dn.size(); ii++ )
             {
                 String nameComponent = dn.get( ii );
-                add( nameComponent );
+                
+                if ( nameComponent.length() > 0 )
+                {
+                    RDN newRdn = new RDN( nameComponent, schemaManager );
+                    
+                    rdns.add( 0, newRdn );
+                }
             }
         }
 
+        toUpName();
+        
         if( schemaManager != null )
         {
-            normalized = true;
+            normalize( schemaManager.getNormalizerMapping() );
         }
         else
         {
+            normalizeInternal();
             normalized = false;
         }
     }
 
+
+    /**
+     * @see #DN(String, SchemaManager)
+     */
+    public DN( String upName ) throws LdapInvalidDnException
+    {
+        this( upName, null );
+    }
+
+
     
     /**
      * Parse a String and checks that it is a valid DN <br>
@@ -188,15 +207,9 @@ public class DN implements Cloneable, Se
      * </p>
      *
      * @param upName The String that contains the DN.
+     * @param schemaManager the schema manager (optional)
      * @throws LdapInvalidNameException if the String does not contain a valid DN.
      */
-    public DN( String upName ) throws LdapInvalidDnException
-    {
-        this( upName, null );
-    }
-
-
-    
     public DN( String upName, SchemaManager schemaManager ) throws LdapInvalidDnException
     {
         if ( upName != null )
@@ -208,7 +221,6 @@ public class DN implements Cloneable, Se
         {
             this.schemaManager = schemaManager;
             normalize( schemaManager.getNormalizerMapping() );
-            normalized = true;
         }
         else
         {
@@ -222,6 +234,7 @@ public class DN implements Cloneable, Se
         this.upName = upName;
     }
 
+    
     /**
      * @see #DN(SchemaManager, String...)
      */
@@ -311,7 +324,7 @@ public class DN implements Cloneable, Se
     
 
     /**
-     * Create a DN when deserializing it.
+     * Create a DN while deserializing it.
      * 
      * Note : this constructor is used only by the deserialization method.
      * @param upName The user provided name
@@ -326,8 +339,51 @@ public class DN implements Cloneable, Se
         this.bytes = bytes;
     }
 
+    
+    /**
+     * Creates a DN.
+     * 
+     * Note: This is mostly used internally in the server 
+     * 
+     * @param upName The user provided name
+     * @param normName the normalized name
+     * @param bytes the name as a byte[]
+     * @param rdnList the list of RDNs present in the DN
+     */
+    public DN( String upName, String normName, byte[] bytes, List<RDN> rdnList )
+    {
+        this( upName, normName, bytes );
+        rdns.addAll( rdnList );
+    }
+
 
     /**
+     * 
+     * Creates a DN by based on the given RDN.
+     *
+     * @param rdn the RDN to be used in the DN
+     */
+    public DN( RDN rdn )
+    {
+        rdns.add( rdn );
+        
+        if( rdn.isNormalized() )
+        {
+            this.normName = rdn.getNormName();
+            this.upName = rdn.getName();
+            this.bytes = StringTools.getBytesUtf8( normName );
+            normalized = true;
+        }
+        else
+        {
+            normalizeInternal();
+            toUpName();
+            normalized = false;
+        }
+    }
+
+    
+    /**
      * Static factory which creates a normalized DN from a String and a Map of OIDs.
      *
      * @param name The DN as a String
@@ -1032,59 +1088,40 @@ public class DN implements Cloneable, Se
      *
      * @param posn the index in this name at which to add the new components.
      *            Must be in the range [0,size()]. Note this is from the opposite end as rnds.get(posn)
-     * @param name the components to add
-     * @return the updated name (not a new one)
+     * @param dn the components to add
+     * @return a cloned and updated DN of the original DN, if no changes were applied the original DN will be returned
      * @throws ArrayIndexOutOfBoundsException
      *             if posn is outside the specified range
      * @throws LdapInvalidDnException
      *             if <tt>n</tt> is not a valid name, or if the addition of
      *             the components would violate the syntax rules of this name
      */
-    public DN addAllNormalized( int posn, DN name ) throws LdapInvalidDnException
+    public DN addAllNormalized( int posn, DN dn ) throws LdapInvalidDnException
     {
-        if ( name instanceof DN )
+        if ( ( dn == null ) || ( dn.size() == 0 ) )
         {
-            DN dn = (DN)name;
-            
-            if ( ( dn == null ) || ( dn.size() == 0 ) )
-            {
-                return this;
-            }
-
-            // Concatenate the rdns
-            rdns.addAll( size() - posn, dn.rdns );
-
-            if ( StringTools.isEmpty( normName ) )
-            {
-                normName = dn.normName;
-                bytes = dn.bytes;
-                upName = dn.upName;
-            }
-            else
-            {
-                normName = dn.normName + "," + normName;
-                bytes = StringTools.getBytesUtf8( normName );
-                upName = dn.upName + "," + upName;
-            }
+            return this;
+        }
+        
+        DN clonedDn = ( DN ) clone();
+        
+        // Concatenate the rdns
+        clonedDn.rdns.addAll( clonedDn.size() - posn, dn.rdns );
+        
+        if ( StringTools.isEmpty( normName ) )
+        {
+            clonedDn.normName = dn.normName;
+            clonedDn.bytes = dn.bytes;
+            clonedDn.upName = dn.upName;
         }
         else
         {
-            if ( ( name == null ) || ( name.size() == 0 ) )
-            {
-                return this;
-            }
-
-            for ( int i = name.size() - 1; i >= 0; i-- )
-            {
-                RDN rdn = new RDN( name.get( i ) );
-                rdns.add( size() - posn, rdn );
-            }
-
-            normalizeInternal();
-            toUpName();
+            clonedDn.normName = dn.normName + "," + normName;
+            clonedDn.bytes = StringTools.getBytesUtf8( normName );
+            clonedDn.upName = dn.upName + "," + upName;
         }
 
-        return this;
+        return clonedDn;
     }
 
     /**
@@ -1092,14 +1129,9 @@ public class DN implements Cloneable, Se
      */
     public DN addAll( DN suffix ) throws LdapInvalidDnException
     {
-        addAll( rdns.size(), suffix );
-        //normalizeInternal();
-        //toUpName();
-
-        return this;
+        return addAll( rdns.size(), suffix );
     }
 
-
     /**
      * {@inheritDoc}
      */
@@ -1110,16 +1142,18 @@ public class DN implements Cloneable, Se
             return this;
         }
 
+        DN clonedDn = ( DN ) clone();
+        
         for ( int i = name.size() - 1; i >= 0; i-- )
         {
             RDN rdn = new RDN( name.get( i ) );
-            rdns.add( size() - posn, rdn );
+            clonedDn.rdns.add( clonedDn.size() - posn, rdn );
         }
 
-        normalizeInternal();
-        toUpName();
+        clonedDn.normalizeInternal();
+        clonedDn.toUpName();
 
-        return this;
+        return clonedDn;
     }
 
     
@@ -1133,26 +1167,28 @@ public class DN implements Cloneable, Se
             return this;
         }
 
+        DN clonedDn = ( DN ) clone();
+        
         // Concatenate the rdns
-        rdns.addAll( size() - posn, dn.rdns );
+        clonedDn.rdns.addAll( clonedDn.size() - posn, dn.rdns );
 
         // Regenerate the normalized name and the original string
-        if ( this.isNormalized() && dn.isNormalized() )
+        if ( clonedDn.isNormalized() && dn.isNormalized() )
         {
-            if ( this.size() != 0 )
+            if ( clonedDn.size() != 0 )
             {
-                normName = dn.getNormName() + "," + normName;
-                bytes = StringTools.getBytesUtf8( normName );
-                upName = dn.getName() + "," + upName;
+                clonedDn.normName = dn.getNormName() + "," + normName;
+                clonedDn.bytes = StringTools.getBytesUtf8( normName );
+                clonedDn.upName = dn.getName() + "," + upName;
             }
         }
         else
         {
-            normalizeInternal();
-            toUpName();
+            clonedDn.normalizeInternal();
+            clonedDn.toUpName();
         }
 
-        return this;
+        return clonedDn;
     }
 
 
@@ -1166,24 +1202,16 @@ public class DN implements Cloneable, Se
             return this;
         }
 
-        //FIXME this try-catch block is for the time being, during removal of
-        // java.naming.Name we have to remove this
-        try
-        {
-            // We have to parse the nameComponent which is given as an argument
-            RDN newRdn = new RDN( comp, schemaManager );
-            
-            rdns.add( 0, newRdn );
-        }
-        catch( LdapInvalidDnException le )
-        {
-            throw new LdapInvalidDnException( le.getMessage() );
-        }
+        DN clonedDn = ( DN ) clone();
+        // We have to parse the nameComponent which is given as an argument
+        RDN newRdn = new RDN( comp, schemaManager );
         
-        normalizeInternal();
-        toUpName();
+        clonedDn.rdns.add( 0, newRdn );
+        
+        clonedDn.normalizeInternal();
+        clonedDn.toUpName();
 
-        return this;
+        return clonedDn;
     }
 
 
@@ -1191,16 +1219,18 @@ public class DN implements Cloneable, Se
      * Adds a single RDN to the (leaf) end of this name.
      *
      * @param newRdn the RDN to add
-     * @return the updated name (not a new one)
+     * @return the updated cloned DN
      */
     public DN add( RDN newRdn )
     {
-        rdns.add( 0, newRdn );
+        DN clonedDn = ( DN ) clone();
         
-        normalizeInternal();
-        toUpName();
+        clonedDn.rdns.add( 0, newRdn );
+        
+        clonedDn.normalizeInternal();
+        clonedDn.toUpName();
 
-        return this;
+        return clonedDn;
     }
 
 
@@ -1213,72 +1243,47 @@ public class DN implements Cloneable, Se
      */
     public DN add( int pos, RDN newRdn )
     {
-        rdns.add( newRdn );
+        DN clonedDn = ( DN ) clone();
         
-        normalizeInternal();
-        toUpName();
-
-        return this;
-    }
-
-
-    /**
-     * Adds the RDNs in the left to right order
-     * i.e adding ou=users followed by ou=system forms the DN ou=users,ou=system 
-     * 
-     * @param newRdn the normalized RDN to be added
-     * @return the DN formed after adding the given RDN, this will already be in a normalized form
-     *         cause of adding normalized RDNs
-     */
-    public DN addNormalizedInOrder( RDN newRdn )
-    {
-        rdns.add( newRdn );
-
-        if (rdns.size() == 1 )
-        {
-            normName = newRdn.getNormName();
-            upName = newRdn.getName();
-        }
-        else
-        {
-            normName = normName + "," + newRdn.getNormName();
-            upName = upName + "," + newRdn.getName();
-        }
+        clonedDn.rdns.add( newRdn );
         
-        bytes = StringTools.getBytesUtf8( normName );
+        clonedDn.normalizeInternal();
+        clonedDn.toUpName();
 
-        return this;
+        return clonedDn;
     }
-    
+
     
     /**
      * Adds a single normalized RDN to the (leaf) end of this name.
      *
      * @param newRdn the RDN to add
-     * @return the updated name (not a new one)
+     * @return the cloned and updated DN
      */
     public DN addNormalized( RDN newRdn )
     {
-        rdns.add( 0, newRdn );
+        DN clonedDn = ( DN ) clone();
+        
+        clonedDn.rdns.add( 0, newRdn );
         
         // Avoid a call to the toNormName() method which
         // will iterate through all the rdns, when we only
         // have to build a new normName by using the current
         // RDN normalized name. The very same for upName.
-        if (rdns.size() == 1 )
+        if (clonedDn.rdns.size() == 1 )
         {
-            normName = newRdn.getNormName();
-            upName = newRdn.getName();
+            clonedDn.normName = newRdn.getNormName();
+            clonedDn.upName = newRdn.getName();
         }
         else
         {
-            normName = newRdn.getNormName() + "," + normName;
-            upName = newRdn.getName() + "," + upName;
+            clonedDn.normName = newRdn.getNormName() + "," + normName;
+            clonedDn.upName = newRdn.getName() + "," + upName;
         }
         
-        bytes = StringTools.getBytesUtf8( normName );
+        clonedDn.bytes = StringTools.getBytesUtf8( normName );
 
-        return this;
+        return clonedDn;
     }
 
 
@@ -1294,36 +1299,29 @@ public class DN implements Cloneable, Se
             throw new ArrayIndexOutOfBoundsException( message );
         }
 
-        //FIXME this try-catch block is for the time being, during removal of
-        // java.naming.Name we have to remove this
-        try
-        {
-            // We have to parse the nameComponent which is given as an argument
-            RDN newRdn = new RDN( comp );
-            
-            int realPos = size() - posn;
-            rdns.add( realPos, newRdn );
-        }
-        catch( LdapInvalidDnException le )
-        {
-            throw new LdapInvalidDnException( le.getMessage() );
-        }
+        // We have to parse the nameComponent which is given as an argument
+        RDN newRdn = new RDN( comp );
 
-        normalizeInternal();
-        toUpName();
+        DN clonedDn = ( DN ) clone();
+        
+        int realPos = clonedDn.size() - posn;
+        clonedDn.rdns.add( realPos, newRdn );
 
-        return this;
+        clonedDn.normalizeInternal();
+        clonedDn.toUpName();
+
+        return clonedDn;
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public RDN remove( int posn ) throws LdapInvalidDnException
+    public DN remove( int posn ) throws LdapInvalidDnException
     {
         if ( rdns.size() == 0 )
         {
-            return RDN.EMPTY_RDN;
+            return this;
         }
 
         if ( ( posn < 0 ) || ( posn >= rdns.size() ) )
@@ -1333,16 +1331,28 @@ public class DN implements Cloneable, Se
             throw new ArrayIndexOutOfBoundsException( message );
         }
 
+        DN clonedDn = ( DN ) clone();
+        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;
-        RDN rdn = rdns.remove( realPos );
+        rdns.remove( realPos );
 
         normalizeInternal();
         toUpName();
-
-        return rdn;
     }
-
-
+    
+    
     /**
      * Gets the parent DN of this DN. Null if this DN doesn't have a parent, i.e. because it
      * is the empty DN.
@@ -1363,7 +1373,7 @@ public class DN implements Cloneable, Se
     /**
      * {@inheritDoc}
      */
-    public Object clone()
+    protected Object clone()
     {
         try
         {

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java?rev=980965&r1=980964&r2=980965&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/name/DnSerializer.java Fri Jul 30 21:08:04 2010
@@ -22,6 +22,8 @@ package org.apache.directory.shared.ldap
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.util.StringTools;
@@ -134,14 +136,13 @@ public class DnSerializer
         // Read the RDNs. Is it's null, the number will be -1.
         int nbRdns = in.readInt();
         
-        DN dn = new DN( upName, normName, bytes );
-        
+        List<RDN> rdnList = new ArrayList<RDN>();
         for ( int i = 0; i < nbRdns; i++ )
         {
             RDN rdn = RdnSerializer.deserialize( in );
-            dn.add( 0, rdn );
+            rdnList.add( rdn );
         }
     
-        return dn;
+        return new DN( upName, normName, bytes, rdnList );
     }
 }

Modified: directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java?rev=980965&r1=980964&r2=980965&view=diff
==============================================================================
--- directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java (original)
+++ directory/shared/trunk/ldap/src/main/java/org/apache/directory/shared/ldap/util/NamespaceTools.java Fri Jul 30 21:08:04 2010
@@ -79,15 +79,13 @@ public class NamespaceTools
      */
     public static DN getRelativeName( DN ancestor, DN descendant ) throws LdapInvalidDnException
     {
-        DN rdn = null;
+        DN rdn = descendant;
         
-        rdn = ( DN ) descendant.clone();
-
         if ( rdn.isChildOf( ancestor ) )
         {
             for ( int ii = 0; ii < ancestor.size(); ii++ )
             {
-                rdn.remove( 0 );
+                rdn = rdn.remove( 0 );
             }
         }
         else

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=980965&r1=980964&r2=980965&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 Fri Jul 30 21:08:04 2010
@@ -53,6 +53,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
@@ -112,6 +113,7 @@ public class DNTest
     {
         DN dn = new DN();
         assertEquals( "", dn.getName() );
+        assertEquals( "", dn.getNormName() );
         assertTrue( dn.isEmpty() );
     }
 
@@ -252,7 +254,7 @@ public class DNTest
         DN target = new DN();
 
         assertTrue( DN.isValid( "cn=Kate Bush+sn=Bush,ou=system" ) );
-        target.addAll( target.size(), dn );
+        target = target.addAll( target.size(), dn );
         assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.toString() );
         assertEquals( "cn=Kate Bush+sn=Bush,ou=system", target.getName() );
     }
@@ -543,7 +545,8 @@ public class DNTest
         DN dn = new DN( "a=b, c=d, e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d, e=f" ) );
-        assertEquals( "e=f", dn.remove( 0 ).getNormName() );
+        // now remove method reurns a modified cloned DN
+        dn = dn.remove( 0 );
         assertEquals( "a=b,c=d", dn.getNormName() );
         assertEquals( "a=b, c=d", dn.getName() );
     }
@@ -558,8 +561,7 @@ public class DNTest
         DN dn = new DN( "a=b, c=d, e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d, e=f" ) );
-        assertEquals( "c=d", dn.remove( 1 ).getNormName() );
-        assertEquals( "a=b, e=f", dn.getName() );
+        assertEquals( "a=b, c=d, e=f", dn.getName() );
     }
 
 
@@ -572,7 +574,7 @@ public class DNTest
         DN dn = new DN( "a=b, c=d, e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d, e=f" ) );
-        assertEquals( "a=b", dn.remove( 2 ).toString() );
+        dn = dn.remove( 2 );
         assertEquals( " c=d, e=f", dn.getName() );
     }
 
@@ -586,7 +588,7 @@ public class DNTest
         DN dn = new DN( "a=b, c=d; e=f" );
 
         assertTrue( DN.isValid( "a=b, c=d; e=f" ) );
-        assertEquals( "c=d", dn.remove( 1 ).getNormName() );
+        dn = dn.remove( 1 );
         assertEquals( "a=b, e=f", dn.getName() );
     }
 
@@ -676,16 +678,16 @@ public class DNTest
         DN dn = new DN();
         assertEquals( 0, dn.size() );
 
-        dn.add( "e = f" );
+        dn = dn.add( "e = f" );
         assertEquals( 1, dn.size() );
 
-        dn.add( "c = d" );
+        dn = dn.add( "c = d" );
         assertEquals( 2, dn.size() );
 
-        dn.remove( 0 );
+        dn = dn.remove( 0 );
         assertEquals( 1, dn.size() );
 
-        dn.remove( 0 );
+        dn = dn.remove( 0 );
         assertEquals( 0, dn.size() );
     }
 
@@ -699,7 +701,7 @@ public class DNTest
     {
         DN dn = new DN();
 
-        dn.add( "e = f" );
+        dn = dn.add( "e = f" );
         assertEquals( "e=f", dn.getNormName() );
         assertEquals( "e = f", dn.getName() );
         assertEquals( 1, dn.size() );
@@ -714,7 +716,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( "e = f" );
+        dn = dn.add( "e = f" );
         assertEquals( "e=f,a=b,c=d", dn.getNormName() );
         assertEquals( "e = f,a=b, c=d", dn.getName() );
         assertEquals( 3, dn.size() );
@@ -729,7 +731,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( "e = f + g = h" );
+        dn = dn.add( "e = f + g = h" );
 
         // Warning ! The order of AVAs has changed during the parsing
         // This has no impact on the correctness of the DN, but the
@@ -747,7 +749,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( dn.size(), "e = f" );
+        dn = dn.add( dn.size(), "e = f" );
         assertEquals( "e = f,a=b, c=d", dn.getName() );
         assertEquals( 3, dn.size() );
     }
@@ -761,7 +763,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( 0, "e = f" );
+        dn = dn.add( 0, "e = f" );
         assertEquals( "a=b, c=d,e = f", dn.getName() );
         assertEquals( 3, dn.size() );
     }
@@ -775,7 +777,7 @@ public class DNTest
     {
         DN dn = new DN( "a=b, c=d" );
 
-        dn.add( 1, "e = f" );
+        dn = dn.add( 1, "e = f" );
         assertEquals( "a=b,e = f, c=d", dn.getName() );
         assertEquals( 3, dn.size() );
     }
@@ -792,7 +794,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN( "c = d" );
-        dn.addAll( dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "c = d,a = b", dn.getName() );
     }
 
@@ -807,7 +809,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN();
-        dn.addAll( dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "a=b", dn.getNormName() );
         assertEquals( "a = b", dn.getName() );
     }
@@ -823,7 +825,7 @@ public class DNTest
     {
         DN dn = new DN();
         DN dn2 = new DN( "a = b" );
-        dn.addAll( dn2 );
+        dn = dn.addAll( dn2 );
         assertEquals( "a = b", dn.getName() );
     }
 
@@ -838,7 +840,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN( "c = d" );
-        dn.addAll( 0, dn2 );
+        dn = dn.addAll( 0, dn2 );
         assertEquals( "a = b,c = d", dn.getName() );
     }
 
@@ -853,7 +855,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN( "c = d" );
-        dn.addAll( 1, dn2 );
+        dn = dn.addAll( 1, dn2 );
         assertEquals( "c = d,a = b", dn.getName() );
     }
 
@@ -868,7 +870,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b, c = d" );
         DN dn2 = new DN( "e = f" );
-        dn.addAll( 1, dn2 );
+        dn = dn.addAll( 1, dn2 );
         assertEquals( "a = b,e = f, c = d", dn.getName() );
     }
 
@@ -883,7 +885,7 @@ public class DNTest
     {
         DN dn = new DN( "a = b" );
         DN dn2 = new DN();
-        dn.addAll( 0, dn2 );
+        dn = dn.addAll( 0, dn2 );
         assertEquals( "a=b", dn.getNormName() );
         assertEquals( "a = b", dn.getName() );
     }
@@ -899,7 +901,7 @@ public class DNTest
     {
         DN dn = new DN();
         DN dn2 = new DN( "a = b" );
-        dn.addAll( 0, dn2 );
+        dn = dn.addAll( 0, dn2 );
         assertEquals( "a = b", dn.getName() );
     }
 
@@ -1098,10 +1100,13 @@ public class DNTest
     public void testDnRemoveIsEmpty() throws LdapException
     {
         DN dn = new DN( "a=b, c=d" );
-        dn.remove( 0 );
-        dn.remove( 0 );
+        DN clonedDn = dn.remove( 0 );
+        
+        assertFalse( dn == clonedDn );
+        
+        clonedDn = clonedDn.remove( 0 );
 
-        assertEquals( true, dn.isEmpty() );
+        assertEquals( true, clonedDn.isEmpty() );
     }
 
 
@@ -1467,12 +1472,14 @@ public class DNTest
         DN name = new DN( "cn=John,ou=People,ou=Marketing" );
 
         // Remove the second component from the head: ou=People
-        String out = name.remove( 1 ).toString();
+        name = name.remove( 1 );
+        String out = name.toString();
 
-        assertEquals( "ou=People", out );
+        assertEquals( "cn=John,ou=Marketing", out );
 
         // Add to the head (first): cn=John,ou=Marketing,ou=East
-        out = name.add( 0, "ou=East" ).toString();
+        name = name.add( 0, "ou=East" );
+        out = name.toString();
 
         assertEquals( "cn=John,ou=Marketing,ou=East", out );
 
@@ -2174,7 +2181,8 @@ public class DNTest
         DN name1 = new DN( "cn=HomeDir,cn=John" );
         DN name2 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name0.equals( name.addAll( name0 ) ) );
+        name = name.addAll( name0 );
+        assertTrue( name0.equals( name ) );
         assertTrue( name2.equals( name.addAll( name1 ) ) );
     }
 
@@ -2193,7 +2201,8 @@ public class DNTest
         DN name1 = new DN( "cn=HomeDir,cn=John" );
         DN name2 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name0.equals( name.addAll( name0 ) ) );
+        name = name.addAll( name0 );
+        assertTrue( name0.equals( name ) );
         assertTrue( name2.equals( name.addAll( 2, name1 ) ) );
     }
 
@@ -2212,13 +2221,17 @@ public class DNTest
         DN name1 = new DN( "cn=John" );
         DN name2 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name0.equals( name.addAll( name0 ) ) );
-        assertTrue( name2.equals( name.addAll( 2, name1 ) ) );
+        name = name.addAll( name0 );
+        assertTrue( name0.equals( name ) );
+        
+        name = name.addAll( 2, name1 );
+        assertTrue( name2.equals( name ) );
 
         DN name3 = new DN( "cn=Airport" );
         DN name4 = new DN( "cn=Airport,cn=HomeDir,cn=John,ou=Marketing,ou=East" );
 
-        assertTrue( name4.equals( name.addAll( 4, name3 ) ) );
+        name = name.addAll( 4, name3 );
+        assertTrue( name4.equals( name ) );
 
         DN name5 = new DN( "cn=ABC123" );
         DN name6 = new DN( "cn=Airport,cn=HomeDir,cn=ABC123,cn=John,ou=Marketing,ou=East" );
@@ -2240,19 +2253,19 @@ public class DNTest
         assertEquals( name, new DN( "" ) );
 
         DN name4 = new DN( "ou=East" );
-        name.add( "ou=East" );
+        name = name.add( "ou=East" );
         assertEquals( name4, name );
 
         DN name3 = new DN( "ou=Marketing,ou=East" );
-        name.add( "ou=Marketing" );
+        name = name.add( "ou=Marketing" );
         assertEquals( name3, name );
 
         DN name2 = new DN( "cn=John,ou=Marketing,ou=East" );
-        name.add( "cn=John" );
+        name = name.add( "cn=John" );
         assertEquals( name2, name );
 
         DN name0 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
-        name.add( "cn=HomeDir" );
+        name = name.add( "cn=HomeDir" );
         assertEquals( name0, name );
     }
 
@@ -2270,31 +2283,31 @@ public class DNTest
         assertEquals( name, new DN( "" ) );
 
         DN name4 = new DN( "ou=East" );
-        name.add( "ou=East" );
+        name = name.add( "ou=East" );
         assertEquals( name4, name );
 
         DN name3 = new DN( "ou=Marketing,ou=East" );
-        name.add( 1, "ou=Marketing" );
+        name = name.add( 1, "ou=Marketing" );
         assertEquals( name3, name );
 
         DN name2 = new DN( "cn=John,ou=Marketing,ou=East" );
-        name.add( 2, "cn=John" );
+        name = name.add( 2, "cn=John" );
         assertEquals( name2, name );
 
         DN name0 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East" );
-        name.add( 3, "cn=HomeDir" );
+        name = name.add( 3, "cn=HomeDir" );
         assertEquals( name0, name );
 
         DN name5 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East,o=LL " + "Bean Inc." );
-        name.add( 0, "o=LL Bean Inc." );
+        name = name.add( 0, "o=LL Bean Inc." );
         assertEquals( name5, name );
 
         DN name6 = new DN( "cn=HomeDir,cn=John,ou=Marketing,ou=East,c=US,o=LL " + "Bean Inc." );
-        name.add( 1, "c=US" );
+        name = name.add( 1, "c=US" );
         assertEquals( name6, name );
 
         DN name7 = new DN( "cn=HomeDir,cn=John,ou=Advertising,ou=Marketing," + "ou=East,c=US,o=LL " + "Bean Inc." );
-        name.add( 4, "ou=Advertising" );
+        name = name.add( 4, "ou=Advertising" );
         assertEquals( name7, name );
     }
 
@@ -2312,27 +2325,27 @@ public class DNTest
         assertEquals( new DN( "" ), name );
 
         DN name3 = new DN( "ou=Marketing" );
-        name.add( "ou=East" );
-        name.add( 1, "ou=Marketing" );
-        name.remove( 0 );
+        name = name.add( "ou=East" );
+        name = name.add( 1, "ou=Marketing" );
+        name = name.remove( 0 );
         assertEquals( name3, name );
 
         DN name2 = new DN( "cn=HomeDir,ou=Marketing,ou=East" );
-        name.add( 0, "ou=East" );
-        name.add( 2, "cn=John" );
-        name.add( "cn=HomeDir" );
-        name.remove( 2 );
+        name = name.add( 0, "ou=East" );
+        name = name.add( 2, "cn=John" );
+        name = name.add( "cn=HomeDir" );
+        name = name.remove( 2 );
         assertEquals( name2, name );
 
-        name.remove( 1 );
+        name = name.remove( 1 );
         DN name1 = new DN( "cn=HomeDir,ou=East" );
         assertEquals( name1, name );
 
-        name.remove( 1 );
+        name = name.remove( 1 );
         DN name0 = new DN( "ou=East" );
         assertEquals( name0, name );
 
-        name.remove( 0 );
+        name = name.remove( 0 );
         assertEquals( new DN( "" ), name );
     }
 
@@ -2349,16 +2362,16 @@ public class DNTest
         DN name = new DN();
         assertEquals( "", name.toString() );
 
-        name.add( "ou=East" );
+        name = name.add( "ou=East" );
         assertEquals( "ou=East", name.toString() );
 
-        name.add( 1, "ou=Marketing" );
+        name = name.add( 1, "ou=Marketing" );
         assertEquals( "ou=Marketing,ou=East", name.toString() );
 
-        name.add( "cn=John" );
+        name = name.add( "cn=John" );
         assertEquals( "cn=John,ou=Marketing,ou=East", name.toString() );
 
-        name.add( "cn=HomeDir" );
+        name = name.add( "cn=HomeDir" );
         assertEquals( "cn=HomeDir,cn=John,ou=Marketing,ou=East", name.toString() );
     }
 
@@ -2628,6 +2641,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddStringName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2643,6 +2657,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddIntString() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2666,6 +2681,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddAllName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2681,6 +2697,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testAddAllIntName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -2754,6 +2771,7 @@ public class DNTest
      * Test for DIRSERVER-191
      */
     @Test
+    @Ignore( "from now onwards DN is not mutable" )
     public void testRemoveName() throws LdapException, InvalidNameException
     {
         LdapName jName = new LdapName( "cn=four,cn=three,cn=two,cn=one" );
@@ -3006,13 +3024,13 @@ public class DNTest
 
         CompoundName name = new CompoundName( "cn=blah,dc=example,dc=com", props );
         DN dn = new DN();
-        dn.addAll( 0, name );
+        dn = dn.addAll( 0, name );
 
         assertEquals( "cn=blah,dc=example,dc=com", dn.toString() );
 
         name = new CompoundName( "cn=blah,dc=example,dc=com", props );
         dn = new DN( "cn=xyz" );
-        dn.addAll( 0, name );
+        dn = dn.addAll( 0, name );
 
         assertEquals( "cn=xyz,cn=blah,dc=example,dc=com", dn.toString() );
     }



Mime
View raw message