directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kayyag...@apache.org
Subject svn commit: r686849 - in /directory/apacheds/branches/bigbang/jdbm-store/src: main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Date Mon, 18 Aug 2008 19:08:51 GMT
Author: kayyagari
Date: Mon Aug 18 12:08:47 2008
New Revision: 686849

URL: http://svn.apache.org/viewvc?rev=686849&view=rev
Log:
fixed a bug ( DIRSERVER-1211 ) related to modify-replace operation on an indexed attribute
whose value is not present 
in the index

Modified:
    directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=686849&r1=686848&r2=686849&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
(original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Mon Aug 18 12:08:47 2008
@@ -1391,8 +1391,11 @@
         {
             Index<?,E> index = getUserIndex( modsOid );
 
-            // Drop all existing attribute value index entries and add new ones
-            ( ( JdbmIndex<?,E> ) index ).drop( id );
+            // if the id exists in the index drop all existing attribute value index entries
and add new ones
+            if( index.reverse( id ) )
+            {
+                ( ( JdbmIndex<?,E> ) index ).drop( id );
+            }
             
             for ( Value<?> value : mods )
             {

Modified: directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=686849&r1=686848&r2=686849&view=diff
==============================================================================
--- directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
(original)
+++ directory/apacheds/branches/bigbang/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
Mon Aug 18 12:08:47 2008
@@ -869,4 +869,33 @@
         assertNull( lookedup.get( "sn" ) );
     }
 
+    
+    @Test
+    public void testModifyReplaceNonExistingIndexAttribute() throws Exception
+    {
+        LdapDN dn = new LdapDN( "cn=Tim B,ou=Sales,o=Good Times Co." );
+        dn.normalize( attributeRegistry.getNormalizerMapping() );
+        DefaultServerEntry entry = new DefaultServerEntry( registries, dn );
+        entry.add( "objectClass", "top", "person", "organizationalPerson" );
+        entry.add( "cn", "Tim B");
+        
+        store.add( dn, entry );
+        
+        List<Modification> mods = new ArrayList<Modification>();
+        ServerAttribute attrib = new DefaultServerAttribute( SchemaConstants.OU_AT,
+            attributeRegistry.lookup( SchemaConstants.OU_AT_OID ) );
+        
+        String attribVal = "Marketing";
+        attrib.add( attribVal );
+        
+        Modification add = new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE,
attrib );
+        mods.add( add );
+        
+        ServerEntry lookedup = store.lookup( store.getEntryId( dn.toNormName() ) );
+        
+        assertNull( lookedup.get( "ou" ) ); // before replacing
+        
+        store.modify( dn, mods );
+        assertEquals( attribVal, lookedup.get( "ou" ).get().get() );
+    }
 }



Mime
View raw message