directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r604361 [3/4] - in /directory/sandbox/akarasulu/bigbang: apacheds/btree-base/src/main/java/org/apache/directory/server/core/partition/impl/btree/ apacheds/core-entry/src/main/java/org/apache/directory/server/core/entry/ apacheds/core-integ/...
Date Sat, 15 Dec 2007 00:58:49 GMT
Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Fri Dec 14 16:58:40 2007
@@ -573,7 +573,14 @@
         // Sync all user defined userIndices
         for ( Index idx:array )
         {
-            idx.sync();
+            try
+            {
+                idx.sync();
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         master.sync();
@@ -800,45 +807,108 @@
 
     public Long getEntryId( String dn ) throws NamingException
     {
-        return ndnIdx.forwardLookup( dn );
+        try
+        {
+            return ndnIdx.forwardLookup( dn );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
     public String getEntryDn( Long id ) throws NamingException
     {
-        return ( String ) ndnIdx.reverseLookup( id );
+        try
+        {
+            return ( String ) ndnIdx.reverseLookup( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
     public Long getParentId( String dn ) throws NamingException
     {
-        Long childId = ndnIdx.forwardLookup( dn );
-        return ( Long ) hierarchyIdx.reverseLookup( childId );
+        try
+        {
+            Long childId = ndnIdx.forwardLookup( dn );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            return ( Long ) hierarchyIdx.reverseLookup( childId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
     public Long getParentId( Long childId ) throws NamingException
     {
-        return ( Long ) hierarchyIdx.reverseLookup( childId );
+        try
+        {
+            return ( Long ) hierarchyIdx.reverseLookup( childId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
     public String getEntryUpdn( Long id ) throws NamingException
     {
-        return ( String ) updnIdx.reverseLookup( id );
+        try
+        {
+            return ( String ) updnIdx.reverseLookup( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
     public String getEntryUpdn( String dn ) throws NamingException
     {
-        Long id = ndnIdx.forwardLookup( dn );
-        return ( String ) updnIdx.reverseLookup( id );
+        try
+        {
+            Long id = ndnIdx.forwardLookup( dn );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            return ( String ) updnIdx.reverseLookup( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
     public int count() throws NamingException
     {
-        return master.count();
+        try
+        {
+            return master.count();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
@@ -852,7 +922,14 @@
      */
     private void dropAliasIndices( Long aliasId ) throws NamingException
     {
-        String targetDn = ( String ) aliasIdx.reverseLookup( aliasId );
+        try
+        {
+            String targetDn = ( String ) aliasIdx.reverseLookup( aliasId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
         Long targetId = getEntryId( targetDn );
         String aliasDn = getEntryDn( aliasId );
         LdapDN ancestorDn = ( LdapDN ) new LdapDN( aliasDn ).getPrefix( 1 );
@@ -869,19 +946,47 @@
          * subtree scope alias.  We only need to do this for the direct parent
          * of the alias on the one level subtree.
          */
-        oneAliasIdx.drop( ancestorId, targetId );
-        subAliasIdx.drop( ancestorId, targetId );
+        try
+        {
+            oneAliasIdx.drop( ancestorId, targetId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            subAliasIdx.drop( ancestorId, targetId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         while ( !ancestorDn.equals( normSuffix ) )
         {
             ancestorDn = ( LdapDN ) ancestorDn.getPrefix( 1 );
             ancestorId = getEntryId( ancestorDn.toString() );
 
-            subAliasIdx.drop( ancestorId, targetId );
+            try
+            {
+                subAliasIdx.drop( ancestorId, targetId );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         // Drops all alias tuples pointing to the id of the alias to be deleted
-        aliasIdx.drop( aliasId );
+        try
+        {
+            aliasIdx.drop( aliasId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
@@ -945,7 +1050,14 @@
         }
 
         // L O O K U P   T A R G E T   I D
-        targetId = ndnIdx.forwardLookup( normalizedAliasTargetDn.toNormName() );
+        try
+        {
+            targetId = ndnIdx.forwardLookup( normalizedAliasTargetDn.toNormName() );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         /*
          * Check For Target Existance
@@ -971,15 +1083,29 @@
          * then we have a situation where an alias chain is being created.  
          * Alias chaining is not allowed so we throw and exception. 
          */
-        if ( null != aliasIdx.reverseLookup( targetId ) )
+        try
         {
-            // Complain about illegal alias chain
-            throw new NamingException( "[36] aliasDereferencingProblem -"
-                + " the alias points to another alias.  Alias chaining is" + " not supported by this backend." );
+            if ( null != aliasIdx.reverseLookup( targetId ) )
+            {
+                // Complain about illegal alias chain
+                throw new NamingException( "[36] aliasDereferencingProblem -"
+                    + " the alias points to another alias.  Alias chaining is" + " not supported by this backend." );
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
 
         // Add the alias to the simple alias index
-        aliasIdx.add( normalizedAliasTargetDn.getNormName(), aliasId );
+        try
+        {
+            aliasIdx.add( normalizedAliasTargetDn.getNormName(), aliasId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         /*
          * Handle One Level Scope Alias Index
@@ -994,7 +1120,14 @@
 
         if ( !NamespaceTools.isSibling( normalizedAliasTargetDn, aliasDn ) )
         {
-            oneAliasIdx.add( ancestorId, targetId );
+            try
+            {
+                oneAliasIdx.add( ancestorId, targetId );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         /*
@@ -1011,7 +1144,14 @@
         {
             if ( !NamespaceTools.isDescendant( ancestorDn, normalizedAliasTargetDn ) )
             {
-                subAliasIdx.add( ancestorId, targetId );
+                try
+                {
+                    subAliasIdx.add( ancestorId, targetId );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
             }
 
             ancestorDn.remove( ancestorDn.size() - 1 );
@@ -1076,9 +1216,30 @@
         }
 
 
-        ndnIdx.add( normName.toNormName(), id );
-        updnIdx.add( normName.getUpName(), id );
-        hierarchyIdx.add( parentId, id );
+        try
+        {
+            ndnIdx.add( normName.toNormName(), id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            updnIdx.add( normName.getUpName(), id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            hierarchyIdx.add( parentId, id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         // Now work on the user defined userIndices
         NamingEnumeration<String> list = entry.getIDs();
@@ -1098,11 +1259,25 @@
 
                 while ( values.hasMore() )
                 {
-                    idx.add( values.next(), id );
+                    try
+                    {
+                        idx.add( values.next(), id );
+                    }
+                    catch ( IOException e )
+                    {
+                        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                    }
                 }
 
                 // Adds only those attributes that are indexed
-                existanceIdx.add( attributeOid, id );
+                try
+                {
+                    existanceIdx.add( attributeOid, id );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
             }
         }
 
@@ -1117,7 +1292,14 @@
 
     public Attributes lookup( Long id ) throws NamingException
     {
-        return master.get( id );
+        try
+        {
+            return master.get( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
@@ -1134,14 +1316,42 @@
             dropAliasIndices( id );
         }
 
-        ndnIdx.drop( id );
-        updnIdx.drop( id );
-        hierarchyIdx.drop( id );
+        try
+        {
+            ndnIdx.drop( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            updnIdx.drop( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            hierarchyIdx.drop( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         // Remove parent's reference to entry only if entry is not the upSuffix
         if ( !parentId.equals( 0L ) )
         {
-            hierarchyIdx.drop( parentId, id );
+            try
+            {
+                hierarchyIdx.drop( parentId, id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
         while ( attrs.hasMore() )
@@ -1159,10 +1369,24 @@
 
                 while ( values.hasMore() )
                 {
-                    index.drop( values.next(), id );
+                    try
+                    {
+                        index.drop( values.next(), id );
+                    }
+                    catch ( IOException e )
+                    {
+                        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                    }
                 }
 
-                existanceIdx.drop( attributeOid, id );
+                try
+                {
+                    existanceIdx.drop( attributeOid, id );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
             }
         }
 
@@ -1177,13 +1401,27 @@
 
     public NamingEnumeration<?> list( Long id ) throws NamingException
     {
-        return hierarchyIdx.listIndices( id );
+        try
+        {
+            return hierarchyIdx.listIndices( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
     public int getChildCount( Long id ) throws NamingException
     {
-        return hierarchyIdx.count( id );
+        try
+        {
+            return hierarchyIdx.count( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
     }
 
 
@@ -1235,8 +1473,15 @@
         // Get all standard index attribute to value mappings
         for ( Index index:this.userIndices.values() )
         {
-            NamingEnumeration<IndexRecord> list = index.listReverseIndices( id );
-            
+            try
+            {
+                NamingEnumeration<IndexRecord> list = index.listReverseIndices( id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+
             while ( list.hasMore() )
             {
                 IndexRecord rec = list.next();
@@ -1256,7 +1501,14 @@
 
         // Get all existance mappings for this id creating a special key
         // that looks like so 'existance[attribute]' and the value is set to id
-        NamingEnumeration<IndexRecord> list = existanceIdx.listReverseIndices( id );
+        try
+        {
+            NamingEnumeration<IndexRecord> list = existanceIdx.listReverseIndices( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
         StringBuffer val = new StringBuffer();
         
         while ( list.hasMore() )
@@ -1281,7 +1533,14 @@
 
         // Get all parent child mappings for this entry as the parent using the
         // key 'child' with many entries following it.
-        list = hierarchyIdx.listIndices( id );
+        try
+        {
+            list = hierarchyIdx.listIndices( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
         Attribute childAttr = new AttributeImpl( "_child" );
         attributes.put( childAttr );
         
@@ -1313,12 +1572,33 @@
         if ( hasUserIndexOn( modsOid ) )
         {
             Index idx = getUserIndex( modsOid );
-            idx.add( mods, id );
+            try
+            {
+                idx.add( mods, id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             // If the attr didn't exist for this id add it to existance index
-            if ( !existanceIdx.hasValue( modsOid, id ) )
+            try
+            {
+                if ( !existanceIdx.hasValue( modsOid, id ) )
+                {
+                    try
+                    {
+                        existanceIdx.add( modsOid, id );
+                    }
+                    catch ( IOException e )
+                    {
+                        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                    }
+                }
+            }
+            catch ( IOException e )
             {
-                existanceIdx.add( modsOid, id );
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
         }
 
@@ -1339,7 +1619,14 @@
 
         if ( modsOid.equals( oidRegistry.getOid( SchemaConstants.ALIASED_OBJECT_NAME_AT ) ) )
         {
-            String ndnStr = ( String ) ndnIdx.reverseLookup( id );
+            try
+            {
+                String ndnStr = ( String ) ndnIdx.reverseLookup( id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
             addAliasIndices( id, new LdapDN( ndnStr ), ( String ) mods.get() );
         }
     }
@@ -1366,15 +1653,29 @@
         if ( hasUserIndexOn( modsOid ) )
         {
             Index idx = getUserIndex( modsOid );
-            idx.drop( mods, id );
+            try
+            {
+                idx.drop( mods, id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             /* 
              * If no attribute values exist for this entryId in the index then
              * we remove the existance index entry for the removed attribute.
              */
-            if ( null == idx.reverseLookup( id ) )
+            try
             {
-                existanceIdx.drop( modsOid, id );
+                if ( null == idx.reverseLookup( id ) )
+                {
+                    existanceIdx.drop( modsOid, id );
+                }
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
         }
 
@@ -1435,16 +1736,37 @@
             Index idx = getUserIndex( modsOid );
 
             // Drop all existing attribute value index entries and add new ones
-            idx.drop( id );
-            idx.add( mods, id );
+            try
+            {
+                idx.drop( id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+            try
+            {
+                idx.add( mods, id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             /* 
              * If no attribute values exist for this entryId in the index then
              * we remove the existance index entry for the removed attribute.
              */
-            if ( null == idx.reverseLookup( id ) )
+            try
+            {
+                if ( null == idx.reverseLookup( id ) )
+                {
+                    existanceIdx.drop( modsOid, id );
+                }
+            }
+            catch ( IOException e )
             {
-                existanceIdx.drop( modsOid, id );
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
         }
 
@@ -1467,7 +1789,14 @@
 
         if ( modsOid.equals( aliasAttributeOid ) && mods.size() > 0 )
         {
-            String ndnStr = ( String ) ndnIdx.reverseLookup( id );
+            try
+            {
+                String ndnStr = ( String ) ndnIdx.reverseLookup( id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
             addAliasIndices( id, new LdapDN( ndnStr ), ( String ) mods.get() );
         }
     }
@@ -1477,7 +1806,14 @@
     {
         NamingEnumeration<String> attrs;
         Long id = getEntryId( dn.toString() );
-        Attributes entry = master.get( id );
+        try
+        {
+            Attributes entry = master.get( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         switch ( modOp )
         {
@@ -1533,7 +1869,14 @@
     public void modify( LdapDN dn, List<ModificationItemImpl> mods ) throws NamingException
     {
         Long id = getEntryId( dn.toString() );
-        Attributes entry = master.get( id );
+        try
+        {
+            Attributes entry = master.get( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         for ( ModificationItem mod : mods )
         {
@@ -1620,12 +1963,33 @@
         if ( hasUserIndexOn( newRdn.getNormType() ) )
         {
             Index idx = getUserIndex( newRdn.getNormType() );
-            idx.add( newRdnValue, id );
+            try
+            {
+                idx.add( newRdnValue, id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             // Make sure the altered entry shows the existance of the new attrib
-            if ( !existanceIdx.hasValue( newRdn.getNormType(), id ) )
+            try
+            {
+                if ( !existanceIdx.hasValue( newRdn.getNormType(), id ) )
+                {
+                    try
+                    {
+                        existanceIdx.add( newRdn.getNormType(), id );
+                    }
+                    catch ( IOException e )
+                    {
+                        e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                    }
+                }
+            }
+            catch ( IOException e )
             {
-                existanceIdx.add( newRdn.getNormType(), id );
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
             }
         }
 
@@ -1654,15 +2018,29 @@
             if ( hasUserIndexOn( oldRdn.getNormType() ) )
             {
                 Index idx = getUserIndex( oldRdn.getNormType() );
-                idx.drop( oldRdn.getValue(), id );
+                try
+                {
+                    idx.drop( oldRdn.getValue(), id );
+                }
+                catch ( IOException e )
+                {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
 
                 /*
                  * If there is no value for id in this index due to our
                  * drop above we remove the oldRdnAttr from the existance idx
                  */
-                if ( null == idx.reverseLookup( id ) )
+                try
+                {
+                    if ( null == idx.reverseLookup( id ) )
+                    {
+                        existanceIdx.drop( oldRdn.getNormType(), id );
+                    }
+                }
+                catch ( IOException e )
                 {
-                    existanceIdx.drop( oldRdn.getNormType(), id );
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                 }
             }
         }
@@ -1716,17 +2094,45 @@
         String aliasTarget;
 
         // Now we can handle the appropriate name userIndices for all cases
-        ndnIdx.drop( id );
+        try
+        {
+            ndnIdx.drop( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         if ( ! updn.isNormalized() )
         {
             updn.normalize( attributeTypeRegistry.getNormalizerMapping() );
         }
 
-        ndnIdx.add( ndnIdx.getNormalized( updn.toNormName() ), id );
+        try
+        {
+            ndnIdx.add( ndnIdx.getNormalized( updn.toNormName() ), id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
-        updnIdx.drop( id );
-        updnIdx.add( updn.getUpName(), id );
+        try
+        {
+            updnIdx.drop( id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            updnIdx.add( updn.getUpName(), id );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         /* 
          * Read Alias Index Tuples
@@ -1740,7 +2146,14 @@
          */
         if ( isMove )
         {
-            aliasTarget = ( String ) aliasIdx.reverseLookup( id );
+            try
+            {
+                aliasTarget = ( String ) aliasIdx.reverseLookup( id );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
 
             if ( null != aliasTarget )
             {
@@ -1832,8 +2245,22 @@
          * Drop the old parent child relationship and add the new one
          * Set the new parent id for the child replacing the old parent id
          */
-        hierarchyIdx.drop( oldParentId, childId );
-        hierarchyIdx.add( newParentId, childId );
+        try
+        {
+            hierarchyIdx.drop( oldParentId, childId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        try
+        {
+            hierarchyIdx.add( newParentId, childId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         /*
          * Build the new user provided DN (updn) for the child using the child's
@@ -1871,15 +2298,29 @@
         };
 
         Long movedBaseId = getEntryId( movedBase.toString() );
-        
-        if ( aliasIdx.reverseLookup( movedBaseId ) != null )
+
+        try
+        {
+            if ( aliasIdx.reverseLookup( movedBaseId ) != null )
+            {
+                dropAliasIndices( movedBaseId, movedBase );
+            }
+        }
+        catch ( IOException e )
         {
-            dropAliasIndices( movedBaseId, movedBase );
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+
+        try
+        {
+            NamingEnumeration<IndexRecord> aliases = new IndexAssertionEnumeration( aliasIdx.listIndices( movedBase.toString(), true ),
+                isBaseDescendant );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
         }
 
-        NamingEnumeration<IndexRecord> aliases = new IndexAssertionEnumeration( aliasIdx.listIndices( movedBase.toString(), true ),
-            isBaseDescendant );
-        
         while ( aliases.hasMore() )
         {
             IndexRecord entry = aliases.next();
@@ -1898,7 +2339,14 @@
      */
     private void dropAliasIndices( Long aliasId, LdapDN movedBase ) throws NamingException
     {
-        String targetDn = ( String ) aliasIdx.reverseLookup( aliasId );
+        try
+        {
+            String targetDn = ( String ) aliasIdx.reverseLookup( aliasId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
         Long targetId = getEntryId( targetDn );
         String aliasDn = getEntryDn( aliasId );
 
@@ -1923,17 +2371,38 @@
          */
         if ( aliasDn.equals( movedBase.toString() ) )
         {
-            oneAliasIdx.drop( ancestorId, targetId );
+            try
+            {
+                oneAliasIdx.drop( ancestorId, targetId );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
 
-        subAliasIdx.drop( ancestorId, targetId );
+        try
+        {
+            subAliasIdx.drop( ancestorId, targetId );
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
 
         while ( !ancestorDn.equals( upSuffix ) )
         {
             ancestorDn = ( LdapDN ) ancestorDn.getPrefix( 1 );
             ancestorId = getEntryId( ancestorDn.toString() );
 
-            subAliasIdx.drop( ancestorId, targetId );
+            try
+            {
+                subAliasIdx.drop( ancestorId, targetId );
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
         }
     }
 

Modified: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Fri Dec 14 16:58:40 2007
@@ -25,31 +25,17 @@
 import jdbm.helper.Serializer;
 import jdbm.helper.TupleBrowser;
 import org.apache.commons.collections.iterators.ArrayIterator;
-import org.apache.directory.server.core.partition.impl.btree.KeyOnlyComparator;
-import org.apache.directory.server.core.partition.impl.btree.NoDupsEnumeration;
-import org.apache.directory.server.core.partition.impl.btree.Table;
-import org.apache.directory.server.core.partition.impl.btree.Tuple;
-import org.apache.directory.server.core.partition.impl.btree.TupleComparator;
-import org.apache.directory.server.core.partition.impl.btree.TupleEnumeration;
-import org.apache.directory.server.core.partition.impl.btree.TupleRenderer;
+import org.apache.directory.server.core.cursor.Cursor;
+import org.apache.directory.server.core.cursor.EmptyCursor;
+import org.apache.directory.server.core.cursor.IteratorCursor;
+import org.apache.directory.server.core.cursor.SingletonCursor;
+import org.apache.directory.server.core.partition.impl.btree.*;
 import org.apache.directory.server.schema.SerializableComparator;
-import org.apache.directory.shared.ldap.exception.LdapNamingException;
-import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.util.EmptyEnumeration;
-import org.apache.directory.shared.ldap.util.SingletonEnumeration;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import java.util.*;
 
 
 /**
@@ -63,6 +49,8 @@
     /**  */
     private static final String SZSUFFIX = "_btree_sz";
 
+    private static final byte[] EMPTY_BYTES = new byte[0];
+
     /** */
     private final String name;
     /** */
@@ -73,10 +61,14 @@
     private final TupleComparator comparator;
 
     /** */
-    private int count = 0;
+    private int count;
     /** */
     private BTree bt;
     /** */
+    private TupleBrowserFactory browserFactory;
+
+
+    /** */
     private TupleRenderer renderer;
 
     private int numDupLimit = JdbmIndex.DEFAULT_DUPLICATE_LIMIT;
@@ -137,14 +129,14 @@
             {
                 bt = BTree.load( recMan, recId );
                 recId = recMan.getNamedObject( name + SZSUFFIX );
-                count = ( ( Integer ) recMan.fetch( recId ) ).intValue();
+                count = ( Integer ) recMan.fetch( recId );
             }
             else
             {
                 bt = BTree.createInstance( recMan, comparator.getKeyComparator(), keySerializer, valueSerializer );
                 recId = bt.getRecid();
                 recMan.setNamedObject( name, recId );
-                recId = recMan.insert( new Integer( 0 ) );
+                recId = recMan.insert( 0 );
                 recMan.setNamedObject( name + SZSUFFIX, recId );
             }
         }
@@ -154,6 +146,26 @@
             ne.setRootCause( e );
             throw ne;
         }
+
+        browserFactory = new TupleBrowserFactory()
+        {
+            public long size() throws IOException
+            {
+                return count;
+            }
+
+
+            public org.apache.directory.server.core.partition.impl.btree.TupleBrowser beforeFirst() throws IOException
+            {
+                return new JdbmTupleBrowser( bt.browse() );
+            }
+
+
+            public org.apache.directory.server.core.partition.impl.btree.TupleBrowser afterLast() throws IOException
+            {
+                return new JdbmTupleBrowser( bt.browse( null ) );
+            }
+        };
     }
 
 
@@ -241,7 +253,7 @@
     /**
      * @see Table#count(java.lang.Object, boolean)
      */
-    public int count( Object key, boolean isGreaterThan ) throws NamingException
+    public int count( Object key, boolean isGreaterThan ) throws IOException
     {
         // take a best guess
         return count;
@@ -251,7 +263,7 @@
     /**
      * @see Table#count(java.lang.Object)
      */
-    public int count( Object key ) throws NamingException
+    public int count( Object key ) throws IOException
     {
         if ( !allowsDuplicates )
         {
@@ -297,7 +309,7 @@
     /**
      * @see org.apache.directory.server.core.partition.impl.btree.Table#count()
      */
-    public int count() throws NamingException
+    public int count() throws IOException
     {
         return count;
     }
@@ -310,7 +322,7 @@
     /**
      * @see Table#get(java.lang.Object)
      */
-    public Object get( Object key ) throws NamingException
+    public Object get( Object key ) throws IOException
     {
         if ( ! allowsDuplicates )
         {
@@ -361,7 +373,7 @@
      * java.lang.Object, boolean)
      */
     @SuppressWarnings("unchecked")
-    public boolean has( Object key, Object val, boolean isGreaterThan ) throws NamingException
+    public boolean has( Object key, Object val, boolean isGreaterThan ) throws IOException
     {
         if ( !allowsDuplicates )
         {
@@ -401,7 +413,7 @@
         if ( values instanceof TreeSet )
         {
             TreeSet set = ( TreeSet ) values;
-            SortedSet subset = null;
+            SortedSet subset;
     
             if ( set.size() == 0 )
             {
@@ -416,24 +428,14 @@
             {
                 subset = set.headSet( val );
             }
-    
-            if ( subset.size() > 0 || set.contains( val ) )
-            {
-                return true;
-            }
-    
-            return false;
+
+            return subset.size() > 0 || set.contains( val );
         }
         
         if ( values instanceof BTreeRedirect )
         {
             BTree tree = getBTree( ( BTreeRedirect ) values );
-            if ( tree.size() == 0 )
-            {
-                return false;
-            }
-
-            return btreeHas( tree, val, isGreaterThan );
+            return tree.size() != 0 && btreeHas( tree, val, isGreaterThan );
         }
         
         throw new IllegalStateException( "When using duplicate keys either a TreeSet or BTree is used for values." );
@@ -443,93 +445,79 @@
     /**
      * @see Table#has(java.lang.Object, boolean)
      */
-    public boolean has( Object key, boolean isGreaterThan ) throws NamingException
+    public boolean has( Object key, boolean isGreaterThan ) throws IOException
     {
-        try
+        // See if we can find the border between keys greater than and less
+        // than in the set of keys.  This will be the spot we search from.
+        jdbm.helper.Tuple tuple = bt.findGreaterOrEqual( key );
+
+        // Test for equality first since it satisfies both greater/less than
+        if ( null != tuple && comparator.compareKey( tuple.getKey(), key ) == 0 )
         {
-            // See if we can find the border between keys greater than and less
-            // than in the set of keys.  This will be the spot we search from.
-            jdbm.helper.Tuple tuple = bt.findGreaterOrEqual( key );
+            return true;
+        }
 
-            // Test for equality first since it satisfies both greater/less than
-            if ( null != tuple && comparator.compareKey( tuple.getKey(), key ) == 0 )
+        // Greater searches are easy and quick thanks to findGreaterOrEqual
+        if ( isGreaterThan )
+        {
+            // A null return above means there were no equal or greater keys
+            if ( null == tuple )
             {
-                return true;
+                return false;
             }
 
-            // Greater searches are easy and quick thanks to findGreaterOrEqual
-            if ( isGreaterThan )
-            {
-                // A null return above means there were no equal or greater keys
-                if ( null == tuple )
-                {
-                    return false;
-                }
+            // Not Null! - we found a tuple with equal or greater key value
+            return true;
+        }
 
-                // Not Null! - we found a tuple with equal or greater key value
+        // Less than searches occur below and are not as efficient or easy.
+        // We need to scan up from the begining if findGreaterOrEqual failed
+        // or scan down if findGreaterOrEqual succeed.
+        TupleBrowser browser;
+        if ( null == tuple )
+        {
+            // findGreaterOrEqual failed so we create a tuple and scan from
+            // the lowest values up via getNext comparing each key to key
+            tuple = new jdbm.helper.Tuple();
+            browser = bt.browse();
+
+            // We should at most have to read one key.  If 1st key is not
+            // less than or equal to key then all keys are > key
+            // since the keys are assorted in ascending order based on the
+            // comparator.
+            if ( browser.getNext( tuple ) )
+            {
+                return comparator.compareKey( tuple.getKey(), key ) <= 0;
+            }
+        }
+        else
+        {
+            // findGreaterOrEqual succeeded so use the existing tuple and
+            // scan the down from the highest key less than key via
+            // getPrevious while comparing each key to key.
+            browser = bt.browse( tuple.getKey() );
+
+            // The above call positions the browser just before the given
+            // key so we need to step forward once then back.  Remember this
+            // key represents a key greater than or equal to key.
+            if ( comparator.compareKey( tuple.getKey(), key ) <= 0 )
+            {
                 return true;
             }
 
-            // Less than searches occur below and are not as efficient or easy.
-            // We need to scan up from the begining if findGreaterOrEqual failed
-            // or scan down if findGreaterOrEqual succeed.
-            TupleBrowser browser = null;
-            if ( null == tuple )
-            {
-                // findGreaterOrEqual failed so we create a tuple and scan from
-                // the lowest values up via getNext comparing each key to key
-                tuple = new jdbm.helper.Tuple();
-                browser = bt.browse();
-
-                // We should at most have to read one key.  If 1st key is not
-                // less than or equal to key then all keys are > key
-                // since the keys are assorted in ascending order based on the
-                // comparator.
-                while ( browser.getNext( tuple ) )
-                {
-                    if ( comparator.compareKey( tuple.getKey(), key ) <= 0 )
-                    {
-                        return true;
-                    }
+            browser.getNext( tuple );
 
-                    return false;
-                }
-            }
-            else
+            // We should at most have to read one key, but we don't short
+            // the search as in the search above first because the chance of
+            // unneccessarily looping is nil since values get smaller.
+            while ( browser.getPrevious( tuple ) )
             {
-                // findGreaterOrEqual succeeded so use the existing tuple and
-                // scan the down from the highest key less than key via
-                // getPrevious while comparing each key to key.
-                browser = bt.browse( tuple.getKey() );
-
-                // The above call positions the browser just before the given
-                // key so we need to step forward once then back.  Remember this
-                // key represents a key greater than or equal to key.
                 if ( comparator.compareKey( tuple.getKey(), key ) <= 0 )
                 {
                     return true;
                 }
-
-                browser.getNext( tuple );
-
-                // We should at most have to read one key, but we don't short
-                // the search as in the search above first because the chance of
-                // unneccessarily looping is nil since values get smaller.
-                while ( browser.getPrevious( tuple ) )
-                {
-                    if ( comparator.compareKey( tuple.getKey(), key ) <= 0 )
-                    {
-                        return true;
-                    }
-                }
             }
         }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException();
-            ne.setRootCause( e );
-            throw ne;
-        }
 
         return false;
     }
@@ -539,18 +527,12 @@
      * @see org.apache.directory.server.core.partition.impl.btree.Table#has(java.lang.Object,
      * java.lang.Object)
      */
-    public boolean has( Object key, Object value ) throws NamingException
+    public boolean has( Object key, Object value ) throws IOException
     {
         if ( ! allowsDuplicates )
         {
             Object obj = getRaw( key );
-
-            if ( null == obj )
-            {
-                return false;
-            }
-
-            return obj.equals( value );
+            return null != obj && obj.equals( value );
         }
         
         Object values = getRaw( key );
@@ -577,7 +559,7 @@
     /**
      * @see Table#has(java.lang.Object)
      */
-    public boolean has( Object key ) throws NamingException
+    public boolean has( Object key ) throws IOException
     {
         return getRaw( key ) != null;
     }
@@ -588,9 +570,9 @@
      * java.lang.Object)
      */
     @SuppressWarnings("unchecked")
-    public Object put( Object key, Object value ) throws NamingException
+    public Object put( Object key, Object value ) throws IOException
     {
-        Object replaced = null;
+        Object replaced;
 
         if ( ! allowsDuplicates )
         {
@@ -657,11 +639,10 @@
     
 
     /**
-     * @see Table#put(java.lang.Object,
-     * javax.naming.NamingEnumeration)
+     * @see Table#put(Object, Cursor
      */
     @SuppressWarnings("unchecked")
-    public Object put( Object key, NamingEnumeration values ) throws NamingException
+    public Object put( Object key, Cursor<Object> values ) throws IOException
     {
         /*
          * If we do not allow duplicates call the single add put using the
@@ -671,13 +652,13 @@
          */
         if ( !allowsDuplicates )
         {
-            if ( values.hasMore() )
+            if ( values.next() )
             {
-                Object value = values.next();
+                Object value = values.get();
 
-                if ( values.hasMore() )
+                if ( values.next() )
                 {
-                    throw new UnsupportedOperationException( "Attempting to put duplicate keys into table " + name
+                    throw new IllegalStateException( "Attempting to put duplicate keys into table " + name
                         + " which does not support duplicates" );
                 }
 
@@ -688,7 +669,6 @@
         }
 
         Object storedValues = getRaw( key );
-        
         if ( storedValues == null )
         {
             storedValues = new TreeSet( comparator.getValueComparator() );
@@ -703,9 +683,9 @@
              * if it is we add it and increment the table entry counter.
              */
             TreeSet set = ( TreeSet ) storedValues;
-            while ( values.hasMore() )
+            while ( values.next() )
             {
-                Object val = values.next();
+                Object val = values.get();
     
                 if ( !set.contains( val ) )
                 {
@@ -732,9 +712,9 @@
         if ( storedValues instanceof BTreeRedirect )
         {
             BTree tree = getBTree( ( BTreeRedirect ) storedValues );
-            while ( values.hasMore() )
+            while ( values.next() )
             {
-                Object val = values.next();
+                Object val = values.get();
                 
                 if ( insertDupIntoBTree( tree, val ) )
                 {
@@ -753,7 +733,7 @@
      * @see Table#remove(java.lang.Object,
      * java.lang.Object)
      */
-    public Object remove( Object key, Object value ) throws NamingException
+    public Object remove( Object key, Object value ) throws IOException
     {
         if ( ! allowsDuplicates )
         {
@@ -826,10 +806,9 @@
 
 
     /**
-     * @see Table#remove(java.lang.Object,
-     * javax.naming.NamingEnumeration)
+     * @see Table#remove(Object, Cursor
      */
-    public Object remove( Object key, NamingEnumeration values ) throws NamingException
+    public Object remove( Object key, Cursor<Object> values ) throws IOException
     {
         /*
          * If we do not allow dupliicates call the single remove using the
@@ -839,13 +818,13 @@
          */
         if ( !allowsDuplicates )
         {
-            if ( values.hasMore() )
+            if ( values.next() )
             {
-                Object value = values.next();
+                Object value = values.get();
 
-                if ( values.hasMore() )
+                if ( values.next() )
                 {
-                    throw new UnsupportedOperationException( "Attempting to remove duplicate keys from table " + name
+                    throw new IllegalStateException( "Attempting to remove duplicate keys from table " + name
                         + " which does not support duplicates" );
                 }
 
@@ -877,9 +856,9 @@
              * counter while doing so.
              */
             Object firstValue = null;
-            while ( values.hasMore() )
+            while ( values.next() )
             {
-                Object val = values.next();
+                Object val = values.get();
     
                 // get the first value
                 if ( firstValue == null )
@@ -905,9 +884,9 @@
         {
             BTree tree = getBTree( ( BTreeRedirect ) storedValues );
             Object first = null;
-            while ( values.hasMore() )
+            while ( values.next() )
             {
-                Object val = values.next();
+                Object val = values.get();
                 
                 if ( removeDupFromBTree( tree, val ) )
                 {
@@ -930,7 +909,7 @@
     /**
      * @see Table#remove(java.lang.Object)
      */
-    public Object remove( Object key ) throws NamingException
+    public Object remove( Object key ) throws IOException
     {
         Object returned = removeRaw( key );
 
@@ -966,7 +945,7 @@
     /**
      * @see Table#listValues(java.lang.Object)
      */
-    public NamingEnumeration<Object> listValues( Object key ) throws NamingException
+    public Cursor<Object> listValues( Object key ) throws IOException
     {
         if ( !allowsDuplicates )
         {
@@ -974,11 +953,11 @@
 
             if ( null == value )
             {
-                return new EmptyEnumeration();
+                return new EmptyCursor();
             }
             else
             {
-                return new SingletonEnumeration( value );
+                return new SingletonCursor( value );
             }
         }
 
@@ -986,49 +965,19 @@
         
         if ( values == null )
         {
-            return new EmptyEnumeration();
+            return new EmptyCursor();
         }
         
         if ( values instanceof TreeSet )
         {
             TreeSet set = ( TreeSet ) values;
-            final Iterator list = set.iterator();
-            return new NamingEnumeration()
-            {
-                public void close()
-                {
-                }
-    
-    
-                public Object nextElement()
-                {
-                    return list.next();
-                }
-    
-    
-                public Object next()
-                {
-                    return list.next();
-                }
-    
-    
-                public boolean hasMore()
-                {
-                    return list.hasNext();
-                }
-    
-    
-                public boolean hasMoreElements()
-                {
-                    return list.hasNext();
-                }
-            };
+            return new IteratorCursor( set.iterator() );
         }
         
         if ( values instanceof BTreeRedirect )
         {
             BTree tree = getBTree( ( BTreeRedirect ) values );
-            return new BTreeEnumeration( tree );
+            return new BTreeCursor( tree );
         }
         
         throw new IllegalStateException( "When using duplicate keys either a TreeSet or BTree is used for values." );
@@ -1042,21 +991,9 @@
     /**
      * @see org.apache.directory.server.core.partition.impl.btree.Table#listTuples()
      */
-    public NamingEnumeration<Tuple> listTuples() throws NamingException
+    public Cursor<Tuple> listTuples() throws IOException
     {
-        NamingEnumeration<Tuple> list = null;
-
-        try
-        {
-            JdbmTupleBrowser browser = new JdbmTupleBrowser( bt.browse() );
-            list = new NoDupsEnumeration( browser, true );
-        }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException();
-            ne.setRootCause( e );
-            throw ne;
-        }
+        Cursor<Tuple> list = new NoDupsCursor( browserFactory );
 
         if ( allowsDuplicates )
         {
@@ -1071,7 +1008,7 @@
      * @see org.apache.directory.server.core.partition.impl.btree.Table#listTuples(java.lang.Object)
      */
     @SuppressWarnings("unchecked")
-    public NamingEnumeration<Tuple> listTuples( Object key ) throws NamingException
+    public Cursor<Tuple> listTuples( Object key ) throws IOException
     {
         // Handle single and zero value returns without duplicates enabled
         if ( !allowsDuplicates )
@@ -1080,11 +1017,11 @@
 
             if ( null == val )
             {
-                return new EmptyEnumeration();
+                return new EmptyCursor();
             }
             else
             {
-                return new SingletonEnumeration( new Tuple( key, getRaw( key ) ) );
+                return new SingletonCursor( new Tuple( key, getRaw( key ) ) );
             }
         }
 
@@ -1092,7 +1029,7 @@
 
         if ( values == null )
         {
-            return new EmptyEnumeration();
+            return new EmptyCursor();
         }
         
         if ( values instanceof TreeSet )
@@ -1100,8 +1037,7 @@
             TreeSet set = ( TreeSet ) values;
             Object[] objs = new Object[set.size()];
             objs = set.toArray( objs );
-            ArrayIterator iterator = new ArrayIterator( objs );
-            return new TupleEnumeration( key, iterator );
+            return new ValueArrayCursor( key, objs );
         }
         
         if ( values instanceof BTreeRedirect )
@@ -1117,53 +1053,46 @@
      * @see Table#listTuples(java.lang.Object,
      * boolean)
      */
-    public NamingEnumeration<Tuple> listTuples( Object key, boolean isGreaterThan ) throws NamingException
+    public Cursor<Tuple> listTuples( Object key, boolean isGreaterThan ) throws IOException
     {
-        NamingEnumeration<Tuple> list = null;
+        Cursor<Tuple> list = null;
 
-        try
+        if ( isGreaterThan )
         {
-            if ( isGreaterThan )
-            {
-                JdbmTupleBrowser browser = new JdbmTupleBrowser( bt.browse( key ) );
-                list = new NoDupsEnumeration( browser, isGreaterThan );
-            }
-            else
+            // JdbmTupleBrowser browser = new JdbmTupleBrowser( bt.browse( key ) );
+            // list = new NoDupsEnumeration( browser, isGreaterThan );
+
+            list = new NoDupsCursor( browserFactory, key );
+        }
+        else
+        {
+            /* According to the jdbm docs a browser is positioned right
+             * before a key greater than or equal to key.  getNext() will
+             * return the next tuple with a key greater than or equal to
+             * key.  getPrevious() used in descending scans for less than
+             * for equal to comparisions will not.  We need to advance
+             * forward once and check if the returned Tuple key equals
+             * key.  If it does then we do nothing feeding in the browser
+             * to the NoDupsCursor.  If it does not we call getPrevious and
+             * pass it into the NoDupsCursor constructor.
+             */
+            jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
+            TupleBrowser browser = bt.browse( key );
+
+            if ( browser.getNext( tuple ) )
             {
-                /* According to the jdbm docs a browser is positioned right
-                 * before a key greater than or equal to key.  getNext() will
-                 * return the next tuple with a key greater than or equal to
-                 * key.  getPrevious() used in descending scans for less than
-                 * for equal to comparisions will not.  We need to advance
-                 * forward once and check if the returned Tuple key equals
-                 * key.  If it does then we do nothing feeding in the browser
-                 * to the NoDupsCursor.  If it does not we call getPrevious and
-                 * pass it into the NoDupsCursor constructor.
-                 */
-                jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
-                TupleBrowser browser = bt.browse( key );
+                Object greaterKey = tuple.getKey();
 
-                if ( browser.getNext( tuple ) )
+                if ( 0 != comparator.compareKey( key, greaterKey ) )
                 {
-                    Object greaterKey = tuple.getKey();
-
-                    if ( 0 != comparator.compareKey( key, greaterKey ) )
-                    {
-                        // Make sure we don't return greaterKey in cursor
-                        browser.getPrevious( tuple );
-                    }
+                    // Make sure we don't return greaterKey in cursor
+                    browser.getPrevious( tuple );
                 }
-
-                // If greaterKey != key above then it will not be returned.
-                list = new NoDupsEnumeration( new JdbmTupleBrowser( browser ), isGreaterThan );
             }
-        }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException( "Failed to get TupleBrowser on table " + name + " using key "
-                + renderKey( key ) );
-            ne.setRootCause( e );
-            throw ne;
+
+            // If greaterKey != key above then it will not be returned.
+//            list = new NoDupsCursor( new JdbmTupleBrowser( browser ), isGreaterThan );
+            list = new NoDupsCursor( browserFactory, isGreaterThan );
         }
 
         if ( allowsDuplicates )
@@ -1180,41 +1109,19 @@
      * java.lang.Object, boolean)
      */
     @SuppressWarnings("unchecked")
-    public NamingEnumeration listTuples( Object key, Object val, boolean isGreaterThan ) throws NamingException
+    public Cursor<Tuple> listTuples( Object key, Object val, boolean isGreaterThan ) throws IOException
     {
         if ( !allowsDuplicates )
         {
-            throw new UnsupportedOperationException( "Cannot list tuples over duplicates on table that " +
+            throw new IllegalStateException( "Cannot list tuples over duplicates on table that " +
                     "does not support duplicates." );
-//            Object rval = getRaw( key );
-//
-//            if ( null == rval ) // key does not exist so return nothing
-//            {
-//                return new EmptyEnumeration();
-//            }
-//            else if ( val.equals( rval ) ) // val == rval return tuple
-//            {
-//                return new SingletonEnumeration( new Tuple( key, val ) );
-//            }
-//            // val >= val and test is for greater then return tuple
-//            else if ( comparator.compareValue( val, rval ) >= 1 && isGreaterThan )
-//            {
-//                return new SingletonEnumeration( new Tuple( key, val ) );
-//            }
-//            // val <= val and test is for lesser then return tuple
-//            else if ( comparator.compareValue( val, rval ) <= 1 && !isGreaterThan )
-//            {
-//                return new SingletonEnumeration( new Tuple( key, val ) );
-//            }
-//
-//            return new EmptyEnumeration();
         }
 
         Object values = getRaw( key );
         
         if ( values == null )
         {
-            return new EmptyEnumeration();
+            return new EmptyCursor();
         }
 
         if ( values instanceof TreeSet )
@@ -1227,13 +1134,12 @@
                 
                 if ( tailSet.isEmpty() )
                 {
-                    return new EmptyEnumeration();
+                    return new EmptyCursor();
                 }
                 
                 Object[] objs = new Object[tailSet.size()];
                 objs = tailSet.toArray( objs );
-                ArrayIterator iterator = new ArrayIterator( objs );
-                return new TupleEnumeration( key, iterator );
+                return new ValueArrayCursor( key, objs );
             }
             else
             {
@@ -1256,7 +1162,7 @@
                 // Reverse the list now we have descending values from val to the
                 // smallest value that key has.  Return tuple cursor over list.
                 Collections.reverse( list );
-                return new TupleEnumeration( key, list.iterator() );
+                return new ValueArrayCursor( key, list );
             }
         }
         
@@ -1274,10 +1180,11 @@
     // Maintenance Operations 
     // ------------------------------------------------------------------------
 
+
     /**
      * @see Table#close()
      */
-    public synchronized void close() throws NamingException
+    public synchronized void close() throws IOException
     {
         sync();
     }
@@ -1286,28 +1193,20 @@
     /**
      * Synchronizes the buffers with disk.
      *
-     * @throws NamingException if errors are encountered on the flush
+     * @throws IOException if errors are encountered on the flush
      */
-    public void sync() throws NamingException
+    public void sync() throws IOException
     {
-        try
-        {
-            long recId = recMan.getNamedObject( name + SZSUFFIX );
+        long recId = recMan.getNamedObject( name + SZSUFFIX );
 
-            if ( 0 == recId )
-            {
-                recId = recMan.insert( new Integer( count ) );
-            }
-            else
-            {
-                recMan.update( recId, new Integer( count ) );
-            }
+        if ( 0 == recId )
+        {
+            //noinspection UnusedAssignment
+            recId = recMan.insert( count );
         }
-        catch ( IOException e )
+        else
         {
-            NamingException ne = new NamingException();
-            ne.setRootCause( e );
-            throw ne;
+            recMan.update( recId, count );
         }
     }
 
@@ -1316,6 +1215,7 @@
     // Private Utility Methods 
     // ------------------------------------------------------------------------
 
+
     /**
      * Renders a key using the renderer associated with this table.
      *
@@ -1342,38 +1242,28 @@
 
 
     /**
-     * Gets a Tuple value from the btree while wrapping any IOExceptions with a 
-     * NamingException.
+     * Gets a Tuple value from the btree.
      *
      * @param key the key of the Tuple to get the value of 
      * @return the raw value object from the btree
-     * @throws NamingException if there are any problems accessing the btree.
+     * @throws IOException if there are any problems accessing the btree.
      */
-    private Object getRaw( Object key ) throws NamingException
+    private Object getRaw( Object key ) throws IOException
     {
-        Object val = null;
+        Object val;
 
         if ( null == key )
         {
             return null;
         }
 
-        try
+        if ( !allowsDuplicates )
         {
-            if ( !allowsDuplicates )
-            {
-                val = bt.find( key );
-            }
-            else
-            {
-                val = bt.find( key );
-            }
+            val = bt.find( key );
         }
-        catch ( IOException e )
+        else
         {
-            NamingException ne = new NamingException();
-            ne.setRootCause( e );
-            throw ne;
+            val = bt.find( key );
         }
 
         return val;
@@ -1381,283 +1271,168 @@
 
 
     /**
-     * Puts a Tuple into the btree while wrapping any IOExceptions with a 
-     * NamingException.
+     * @todo what's the reason for keeping this?
+     *
+     * Puts a Tuple into the btree.
      *
      * @param key the key of the Tuple to put
      * @param value the value of the Tuple to put
      * @param doReplace whether or not to replace the object if it exists
      * @return the raw value object removed from the btree on replacement
-     * @throws NamingException if there are any problems accessing the btree.
+     * @throws IOException if there are any problems accessing the btree.
      */
-    private Object putRaw( Object key, Object value, boolean doReplace ) throws NamingException
+    private Object putRaw( Object key, Object value, boolean doReplace ) throws IOException
     {
-        Object val = null;
-
-        try
-        {
-            val = bt.insert( key, value, doReplace );
-        }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException();
-            ne.setRootCause( e );
-            throw ne;
-        }
-
-        return val;
+        return bt.insert( key, value, doReplace );
     }
 
 
     /**
-     * Removes a entry from the btree while wrapping any IOExceptions with a 
+     * @todo what's the reason for keeping this?
+     *
+     * Removes a entry from the btree while wrapping any IOExceptions with a
      * NamingException.
      *
      * @param key the key of the Tuple to remove
      * @return the raw value object removed from the btree
-     * @throws NamingException if there are any problems accessing the btree.
+     * @throws IOException if there are any problems accessing the btree.
      */
-    private Object removeRaw( Object key ) throws NamingException
+    private Object removeRaw( Object key ) throws IOException
     {
-        Object val = null;
-
-        try
-        {
-            val = bt.remove( key );
-        }
-        catch ( IOException e )
-        {
-            NamingException ne = new NamingException();
-            ne.setRootCause( e );
-            throw ne;
-        }
-
-        return val;
+        return bt.remove( key );
     }
 
 
-    BTree getBTree( BTreeRedirect redirect ) throws NamingException
+    BTree getBTree( BTreeRedirect redirect ) throws IOException
     {
         if ( duplicateBtrees.containsKey( redirect.getRecId() ) )
         {
             return duplicateBtrees.get( redirect.getRecId() );
         }
         
-        try
-        {
-            BTree tree = BTree.load( recMan, redirect.getRecId().longValue() );
-            duplicateBtrees.put( redirect.getRecId(), tree );
-            return tree;
-        }
-        catch ( IOException e )
-        {
-            LdapNamingException lne = new LdapNamingException( "Failed to load btree", 
-                ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
-        }
+        BTree tree = BTree.load( recMan, redirect.getRecId() );
+        duplicateBtrees.put( redirect.getRecId(), tree );
+        return tree;
     }
 
 
-    private Object firstKey ( BTree tree ) throws NamingException
+    private Object firstKey ( BTree tree ) throws IOException
     {
         jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
-        boolean success = false;
-        
-        try
-        {
-            success = tree.browse().getNext( tuple );
+        boolean success = tree.browse().getNext( tuple );
             
-            if ( success )
-            {
-                return tuple.getKey();
-            }
-            else 
-            {
-                return null;
-            }
+        if ( success )
+        {
+            return tuple.getKey();
         }
-        catch ( IOException e )
+        else
         {
-            LdapNamingException lne = new LdapNamingException( "IO failure while acessing btree: "
-                + e.getMessage(), ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
+            return null;
         }
     }
 
     
-    private boolean btreeHas( BTree tree, Object key, boolean isGreaterThan ) throws NamingException
+    private boolean btreeHas( BTree tree, Object key, boolean isGreaterThan ) throws IOException
     {
         jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
         
-        try
+        TupleBrowser browser = tree.browse( key );
+        if ( isGreaterThan )
         {
-            TupleBrowser browser = tree.browse( key );
-            if ( isGreaterThan )
+            return browser.getNext( tuple );
+        }
+        else
+        {
+            boolean success = browser.getPrevious( tuple );
+            if ( success )
             {
-                boolean success = browser.getNext( tuple );
-                if ( success )
-                {
-                    return true;
-                }
-                else
-                {
-                    return false;
-                }
+                return true;
             }
             else
             {
-                boolean success = browser.getPrevious( tuple );
+                /*
+                 * Calls to getPrevious() will return a lower key even
+                 * if there exists a key equal to the one searched
+                 * for.  Since isGreaterThan when false really means
+                 * 'less than or equal to' we must check to see if
+                 * the key in front is equal to the key argument provided.
+                 */
+                success = browser.getNext( tuple );
                 if ( success )
                 {
-                    return true;
-                }
-                else
-                {
-                    /*
-                     * Calls to getPrevious() will return a lower key even
-                     * if there exists a key equal to the one searched
-                     * for.  Since isGreaterThan when false really means
-                     * 'less than or equal to' we must check to see if 
-                     * the key in front is equal to the key argument provided.
-                     */
-                    success = browser.getNext( tuple );
-                    if ( success )
+                    Object biggerKey = tuple.getKey();
+                    if ( comparator.compareValue( key, biggerKey ) == 0 )
                     {
-                        Object biggerKey = tuple.getKey();
-                        if ( comparator.compareValue( key, biggerKey ) == 0 )
-                        {
-                            return true;
-                        }
+                        return true;
                     }
-                    return false;
                 }
+                return false;
             }
         }
-        catch ( IOException e )
-        {
-            LdapNamingException lne = new LdapNamingException( "IO failure while acessing btree: "
-                + e.getMessage(), ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
-        }
     }
 
 
-    private boolean btreeHas( BTree tree, Object key ) throws NamingException
+    private boolean btreeHas( BTree tree, Object key ) throws IOException
     {
         jdbm.helper.Tuple tuple = new jdbm.helper.Tuple();
         
-        try
+        TupleBrowser browser = tree.browse( key );
+        boolean success = browser.getNext( tuple );
+        if ( success )
         {
-            TupleBrowser browser = tree.browse( key );
-            boolean success = browser.getNext( tuple );
-            if ( success )
+            if ( comparator.compareValue( key, tuple.getKey() ) == 0 )
             {
-                if ( comparator.compareValue( key, tuple.getKey() ) == 0 )
-                {
-                    return true;
-                }
+                return true;
             }
-
-            return false;
-        }
-        catch ( IOException e )
-        {
-            LdapNamingException lne = new LdapNamingException( "IO failure while acessing btree: "
-                + e.getMessage(), ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
         }
+
+        return false;
     }
 
     
-    private boolean insertDupIntoBTree( BTree tree, Object value ) throws LdapNamingException
+    private boolean insertDupIntoBTree( BTree tree, Object value ) throws IOException
     {
-        try
-        {
-            Object replaced = tree.insert( value, EMPTY_BYTES, true );
-            return null == replaced;
-        }
-        catch ( IOException e )
-        {
-            LdapNamingException lne = new LdapNamingException( "Failed to insert dup into BTree", 
-                ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
-        }
+        Object replaced = tree.insert( value, EMPTY_BYTES, true );
+        return null == replaced;
     }
     
 
-    private boolean removeDupFromBTree( BTree tree, Object value ) throws LdapNamingException
+    private boolean removeDupFromBTree( BTree tree, Object value ) throws IOException
     {
-        try
-        {
-            Object removed = null;
-            if ( tree.find( value ) != null )
-            {
-                removed = tree.remove( value );
-            }
-            return null != removed;
-        }
-        catch ( IOException e )
+        Object removed = null;
+        if ( tree.find( value ) != null )
         {
-            LdapNamingException lne = new LdapNamingException( "Failed to remove dup from BTree", 
-                ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
+            removed = tree.remove( value );
         }
+        return null != removed;
     }
     
 
-    private static final byte[] EMPTY_BYTES = new byte[0];
-    private BTree convertToBTree( TreeSet set ) throws NamingException
+    private BTree convertToBTree( TreeSet set ) throws IOException
     {
-        try
-        {
-            BTree tree = BTree.createInstance( recMan, comparator.getValueComparator() );
-            for ( Iterator ii = set.iterator(); ii.hasNext(); /**/ )
-            {
-                tree.insert( ii.next(), EMPTY_BYTES, true );
-            }
-            return tree;
-        }
-        catch ( IOException e )
+        BTree tree = BTree.createInstance( recMan, comparator.getValueComparator() );
+        for ( Object element : set )
         {
-            LdapNamingException lne = new LdapNamingException( "Failed to convert TreeSet values to BTree", 
-                ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
+            tree.insert( element, EMPTY_BYTES, true );
         }
+        return tree;
     }
     
     
-    private Object removeAll( BTree tree ) throws NamingException
+    private Object removeAll( BTree tree ) throws IOException
     {
         Object first = null;
         jdbm.helper.Tuple jdbmTuple = new jdbm.helper.Tuple();
-        TupleBrowser browser;
-        try
+        TupleBrowser browser = tree.browse();
+        while( browser.getNext( jdbmTuple ) )
         {
-            browser = tree.browse();
-            while( browser.getNext( jdbmTuple ) )
+            tree.remove( jdbmTuple.getKey() );
+            if ( first == null )
             {
-                tree.remove( jdbmTuple.getKey() );
-                if ( first == null )
-                {
-                    first = jdbmTuple.getKey();
-                }
+                first = jdbmTuple.getKey();
             }
         }
-        catch ( IOException e )
-        {
-            LdapNamingException lne = new LdapNamingException( "Failed to remove all keys in BTree",
-                ResultCodeEnum.OTHER );
-            lne.setRootCause( e );
-            throw lne;
-        }
-        
+
         return first;
     }
 }

Added: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTupleBrowserFactory.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTupleBrowserFactory.java?rev=604361&view=auto
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTupleBrowserFactory.java (added)
+++ directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTupleBrowserFactory.java Fri Dec 14 16:58:40 2007
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * 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.
+ */
+package org.apache.directory.server.core.partition.impl.btree.jdbm;
+
+import org.apache.directory.server.core.partition.impl.btree.TupleBrowserFactory;
+import org.apache.directory.server.core.partition.impl.btree.TupleBrowser;
+
+
+import java.io.IOException;
+
+import jdbm.btree.BTree;
+
+
+/**
+ * Document me!
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class JdbmTupleBrowserFactory implements TupleBrowserFactory
+{
+    private final BTree btree;
+
+
+    public JdbmTupleBrowserFactory( BTree btree )
+    {
+        this.btree = btree;
+    }
+
+
+    public long size() throws IOException
+    {
+        return btree.size();
+    }
+
+
+    public TupleBrowser beforeFirst() throws IOException
+    {
+        return new JdbmTupleBrowser( btree.browse() );
+    }
+
+
+    public TupleBrowser afterLast() throws IOException
+    {
+        return new JdbmTupleBrowser( btree.browse( null ) );
+    }
+
+
+    public TupleBrowser beforeKey( Object key ) throws IOException
+    {
+        return new JdbmTupleBrowser( btree.browse( key ) );
+    }
+}

Propchange: directory/sandbox/akarasulu/bigbang/apacheds/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTupleBrowserFactory.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: directory/sandbox/akarasulu/bigbang/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/StandardThreadPool.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/StandardThreadPool.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/StandardThreadPool.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/StandardThreadPool.java Fri Dec 14 16:58:40 2007
@@ -26,7 +26,7 @@
 import java.util.concurrent.TimeUnit;
 
 /**
- * @version $Rev:$ $Date:$
+ * @version $Rev$ $Date$
  * @org.apache.xbean.XBean
  */
 public class StandardThreadPool implements Executor

Modified: directory/sandbox/akarasulu/bigbang/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java
URL: http://svn.apache.org/viewvc/directory/sandbox/akarasulu/bigbang/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java?rev=604361&r1=604360&r2=604361&view=diff
==============================================================================
--- directory/sandbox/akarasulu/bigbang/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java (original)
+++ directory/sandbox/akarasulu/bigbang/apacheds/server-unit/src/test/java/org/apache/directory/server/ModifyRdnTest.java Fri Dec 14 16:58:40 2007
@@ -23,13 +23,10 @@
 import java.util.Hashtable;
 
 import javax.naming.NameNotFoundException;
-import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.DirContext;
-import javax.naming.directory.SearchControls;
-import javax.naming.directory.SearchResult;
 import javax.naming.ldap.InitialLdapContext;
 import javax.naming.ldap.LdapContext;
 
@@ -374,31 +371,30 @@
     /**
      * Test for DIRSERVER-1086.
      * Modify Rdn of an entry that has a child entry, delete its old rdn value.
-     * Ensure that the tree is not broken.
      *
      * @throws NamingException
      */
-    @Test
-    public void testModifyRdnAndDeleteOldWithChild() throws NamingException
+    /*
+    @Test public void testModifyRdnAndDeleteOldWithChild() throws NamingException
     {
         // Create an organizational unit, ou value is rdn
         String oldOu = "Writers";
         String oldRdn = "ou=" + oldOu;
         Attributes attributes = this.getOrganizationalUnitAttributes( oldOu );
         DirContext createdCtx = ctx.createSubcontext( oldRdn, attributes );
-
+  
         // Create a child
         String childCn = "Tori Amos";
         String childRdn = "cn=" + childCn;
         Attributes childAttributes = this.getPersonAttributes( "Amos", childCn );
         createdCtx.createSubcontext( childRdn, childAttributes );
-
+  
         // modify Rdn
         String newOu = "Singers";
         String newRdn = "ou=" + newOu;
         ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
         ctx.rename( oldRdn, newRdn );
-
+  
         // Check, whether old Entry does not exists
         try
         {
@@ -410,46 +406,45 @@
             // expected behaviour
             assertTrue( true );
         }
-
+  
         // Check, whether new Entry exists
         DirContext org = ( DirContext ) ctx.lookup( newRdn );
         assertNotNull( org );
-
+  
         // Check values of ou
         Attribute ou = org.getAttributes( "" ).get( "ou" );
         assertTrue( ou.contains( newOu ) );
         assertTrue( !ou.contains( oldOu ) ); // old value is gone
         assertEquals( 1, ou.size() );
-
+  
         // Perform a search under renamed ou and check whether exactly one child entry exist
         SearchControls searchControls = new SearchControls();
         searchControls.setSearchScope( SearchControls.ONELEVEL_SCOPE );
-        searchControls.setReturningAttributes( new String[]
-            { "objectClass" } );
+        searchControls.setReturningAttributes( new String[]{"objectClass"} );
         NamingEnumeration<SearchResult> results = org.search( "", "(objectClass=*)", searchControls );
         assertTrue( results.hasMore() );
         results.next();
         assertTrue( !results.hasMore() );
-
+  
         // Check whether Tori exists
         DirContext tori = ( DirContext ) org.lookup( childRdn );
         assertNotNull( tori );
-
+  
         // Remove entry (use new rdn)
-        ctx.unbind( childRdn + "," + newRdn );
         ctx.unbind( newRdn );
     }
+    */
 
 
     /**
      * Test for DIRSERVER-1096.
-     * Modify the RDN of an entry with an escaped new RDN. 
-     * Ensure that the attribute itself contains the not-escaped value.
+     * Modify the RDN of an entry with an encoded new RDN. 
+     * Ensure that the attribute itself contains the unencoded value.
      *
      * @throws Exception
      */
-    @Test
-    public void testModifyRdnWithEncodedNewRdn() throws Exception
+    /*
+    @Test public void testModifyRdnWithEncodedNewRdn() throws Exception
     {
         // Create a person, cn value is rdn
         String cnVal = "Tori Amos";
@@ -458,13 +453,11 @@
         Attributes attributes = this.getPersonAttributes( snVal, cnVal );
         ctx.createSubcontext( oldRdn, attributes );
 
-        // modify Rdn from cn=Tori Amos to cn=<A Umlaut>\+
+        // modify Rdn from cn=Tori Amos to cn=Ä\+
         String newCnVal = new String( new byte[]
-            { ( byte ) 0xC3, ( byte ) 0x84, '+' }, "UTF-8" );
-        String newCnEscapedVal = new String( new byte[]
-            { ( byte ) 0xC3, ( byte ) 0x84, '\\', '+' }, "UTF-8" );
+             { ( byte ) 0xC3, ( byte ) 0x84, '\\', '+' }, "UTF-8" );
         ctx.addToEnvironment( "java.naming.ldap.deleteRDN", "true" );
-        String newRdn = "cn=" + newCnEscapedVal;
+        String newRdn = "cn=" + newCnVal;
         ctx.rename( oldRdn, newRdn );
 
         // Check, whether old Entry does not exists
@@ -477,7 +470,7 @@
         {
             // expected behaviour
         }
-
+        
         // Check, whether new Entry exists
         DirContext newCtx = ( DirContext ) ctx.lookup( newRdn );
         assertNotNull( newCtx );
@@ -490,6 +483,7 @@
         // Remove entry (use new rdn)
         ctx.unbind( newRdn );
     }
+    */
 
 }
 



Mime
View raw message