directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r980961 - in /directory/apacheds/trunk: protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/ server-integ/src/test/java/org/apache/directory/server/operations/extended/ xdbm-partition/src/main/java/org/apache/directory/ser...
Date Fri, 30 Jul 2010 20:59:43 GMT
Author: elecharny
Date: Fri Jul 30 20:59:42 2010
New Revision: 980961

URL: http://svn.apache.org/viewvc?rev=980961&view=rev
Log:
o Merged the modifications made by Kiran in the dnFactoryExperient branch.
o DN is now immutable.
o We have a DN cache too.

Modified:
    directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
    directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java

Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java?rev=980961&r1=980960&r2=980961&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
(original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/handlers/SearchHandler.java
Fri Jul 30 20:59:42 2010
@@ -1416,10 +1416,11 @@ public class SearchHandler extends LdapR
             DN reqUnnormalizedDn = new DN( req.getBase().getName() );
             for ( int jj = 0; jj < diff; jj++ )
             {
-                extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size() + jj )
);
+                extra = extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size()
+ jj ) );
             }
 
-            ldapUrl.getDn().addAll( extra );
+            urlDn = urlDn.addAll( extra );
+            ldapUrl.setDn( urlDn );
             ldapUrl.setForceScopeRendering( true );
             ldapUrl.setAttributes( req.getAttributes() );
             ldapUrl.setScope( req.getScope().getScope() );
@@ -1503,10 +1504,10 @@ public class SearchHandler extends LdapR
             DN reqUnnormalizedDn = new DN( reqTargetDn.getName() );
             for ( int jj = 0; jj < diff; jj++ )
             {
-                extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size() + jj )
);
+                extra = extra.add( reqUnnormalizedDn.get( referralAncestor.getDn().size()
+ jj ) );
             }
 
-            urlDn.addAll( extra );
+            urlDn = urlDn.addAll( extra );
 
             StringBuilder buf = new StringBuilder();
             buf.append( ldapUrl.getScheme() );
@@ -1604,11 +1605,11 @@ public class SearchHandler extends LdapR
     {
         Entry entry;
         Entry farthestReferralAncestor = null;
-        DN dn = ( DN ) target.clone();
+        DN dn = target;
         
         try
         {
-            dn.remove( dn.size() - 1 );
+            dn = dn.remove( dn.size() - 1 );
         }
         catch ( LdapInvalidDnException e2 )
         {
@@ -1630,7 +1631,7 @@ public class SearchHandler extends LdapR
                     farthestReferralAncestor = entry;
                 }
 
-                dn.remove( dn.size() - 1 );
+                dn = dn.remove( dn.size() - 1 );
             }
             catch ( LdapException e )
             {
@@ -1639,7 +1640,7 @@ public class SearchHandler extends LdapR
                 // update the DN as we strip last component 
                 try
                 {
-                    dn.remove( dn.size() - 1 );
+                    dn = dn.remove( dn.size() - 1 );
                 }
                 catch ( LdapInvalidDnException e1 )
                 {

Modified: directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java?rev=980961&r1=980960&r2=980961&view=diff
==============================================================================
--- directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java
(original)
+++ directory/apacheds/trunk/server-integ/src/test/java/org/apache/directory/server/operations/extended/DITUtilitiesSP.java
Fri Jul 30 20:59:42 2010
@@ -56,7 +56,7 @@ public class DITUtilitiesSP
         {
             ClonedServerEntry result = results.get();
             DN childRdn = result.getDn();
-            childRdn.remove( 0 );
+            childRdn = childRdn.remove( 0 );
             deleteSubtree( session, childRdn );
         }
         

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=980961&r1=980960&r2=980961&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Fri Jul 30 20:59:42 2010
@@ -53,6 +53,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -1290,7 +1291,7 @@ public abstract class AbstractStore<E, I
             throw nse;
         }
         
-        DN newDn = ((DN)newSuperiorDn.clone()).add( newRdn );
+        DN newDn = newSuperiorDn.add( newRdn );
         
         // Now check that the new entry does not exist
         ID newId = getEntryId( newDn );
@@ -1427,10 +1428,12 @@ public abstract class AbstractStore<E, I
      */
     protected DN buildEntryDn( ID id ) throws Exception
     {
-        DN dn = new DN();
-
         ID parentId = id;
 
+        List<RDN> rdnList = new ArrayList<RDN>();
+        String upName = "";
+        String normName = "";
+        
         do
         {
             ParentIdAndRdn<ID> cur = rdnIdx.reverseLookup( parentId );
@@ -1438,13 +1441,26 @@ public abstract class AbstractStore<E, I
 
             for ( RDN rdn : rdns )
             {
-                dn.addNormalizedInOrder( rdn );
+                if ( rdnList.isEmpty() )
+                {
+                    normName = rdn.getNormName();
+                    upName = rdn.getName();
+                }
+                else
+                {
+                    normName = normName + "," + rdn.getNormName();
+                    upName = upName + "," + rdn.getName();
+                }
+                
+                rdnList.add( rdn );
             }
 
             parentId = cur.getParentId();
         }
         while ( !parentId.equals( getRootId() ) );
 
+        DN dn = new DN( upName, normName, StringTools.getBytesUtf8( normName ), rdnList );
+        
         return dn;
     }
 
@@ -1819,13 +1835,13 @@ public abstract class AbstractStore<E, I
          * index.  If the target is not a sibling of the alias then we add the
          * index entry maping the parent's id to the aliased target id.
          */
-        ancestorDn = ( DN ) aliasDn.clone();
-        ancestorDn.remove( aliasDn.size() - 1 );
+        ancestorDn = aliasDn;
+        ancestorDn = ancestorDn.remove( aliasDn.size() - 1 );
         ancestorId = getEntryId( ancestorDn );
 
         // check if alias parent and aliased entry are the same
-        DN normalizedAliasTargetParentDn = ( DN ) normalizedAliasTargetDn.clone();
-        normalizedAliasTargetParentDn.remove( normalizedAliasTargetDn.size() - 1 );
+        DN normalizedAliasTargetParentDn = normalizedAliasTargetDn;
+        normalizedAliasTargetParentDn = normalizedAliasTargetParentDn.remove( normalizedAliasTargetDn.size()
- 1 );
 
         if ( !aliasDn.isChildOf( normalizedAliasTargetParentDn ) )
         {
@@ -1849,7 +1865,7 @@ public abstract class AbstractStore<E, I
                 subAliasIdx.add( ancestorId, targetId );
             }
 
-            ancestorDn.remove( ancestorDn.size() - 1 );
+            ancestorDn = ancestorDn.remove( ancestorDn.size() - 1 );
             ancestorId = getEntryId( ancestorDn );
         }
     }
@@ -1878,8 +1894,8 @@ public abstract class AbstractStore<E, I
 
         DN aliasDN = getEntryDn( aliasId );
 
-        DN ancestorDn = ( DN ) aliasDN.clone();
-        ancestorDn.remove( aliasDN.size() - 1 );
+        DN ancestorDn = aliasDN;
+        ancestorDn = ancestorDn.remove( aliasDN.size() - 1 );
         ID ancestorId = getEntryId( ancestorDn );
 
         /*

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java?rev=980961&r1=980960&r2=980961&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
Fri Jul 30 20:59:42 2010
@@ -503,7 +503,7 @@ public class AvlStoreTest
 
         DN newParentDn = new DN( "ou=Board of Directors,o=Good Times Co.", schemaManager
);
 
-        DN newDn = ((DN)newParentDn.clone()).add( martinDn.getRdn() );
+        DN newDn = newParentDn.add( martinDn.getRdn() );
         store.move( martinDn, newParentDn, newDn, new ClonedServerEntry( entry ) );
 
         cursor = idx.forwardCursor( 3L );
@@ -530,7 +530,7 @@ public class AvlStoreTest
         entry.add( "entryUUID", UUID.randomUUID().toString() );
         store.add( entry );
 
-        newDn = ((DN)newParentDn.clone()).add( marketingDn.getRdn() );
+        newDn = newParentDn.add( marketingDn.getRdn() );
         store.move( marketingDn, newParentDn, newDn, new ClonedServerEntry( entry ) );
 
         cursor = idx.forwardCursor( 3L );
@@ -685,7 +685,7 @@ public class AvlStoreTest
 
         assertEquals( 3, store.getSubAliasIndex().count() );
 
-        DN newDn = ((DN)parentDn.clone()).add( childDn.getRdn() );
+        DN newDn = parentDn.add( childDn.getRdn() );
         store.move( childDn, parentDn, newDn, childEntry );
 
         assertEquals( 4, store.getSubAliasIndex().count() );



Mime
View raw message