directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1144982 - in /directory: apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/ apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ apacheds/trunk/http-integration/src/main/java/org/apache/...
Date Sun, 10 Jul 2011 22:24:42 GMT
Author: elecharny
Date: Sun Jul 10 22:24:41 2011
New Revision: 1144982

URL: http://svn.apache.org/viewvc?rev=1144982&view=rev
Log:
o Created a DefaultModifictaion constructor taking an AttributeType with no value
o Renamed the userIndinces() method to getUserIndices()
o Renamed the systemIndinces() method to getSystemIndices()
o The Store.modify method now takes a Modification... instead of a List<Modification>
o Renamed the AbstractStore.protect method to checkInitialized for clarity
o Added some missing Javadoc
o Removed the Store.modify method which takes a Entry as a parameter
o Made some method private
o Removed the setCheckHasEntryDuringAdd method
o Fixed the tests and the code using Store to reflect the changes done above

Modified:
    directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
    directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
    directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
    directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
    directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java
    directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java

Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java (original)
+++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java Sun Jul 10 22:24:41 2011
@@ -213,7 +213,7 @@ public final class SchemaPartition exten
         schemaDn = new Dn( schemaManager, SchemaConstants.OU_SCHEMA );
         
         wrapped.setId( ID );
-        wrapped.setSuffix(schemaDn);
+        wrapped.setSuffix( schemaDn );
         wrapped.setSchemaManager( schemaManager );
 
         try

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java (original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java Sun Jul 10 22:24:41 2011
@@ -225,8 +225,8 @@ public class ExceptionInterceptor extend
         }
 
         // check if entry to search exists
-        String msg = "Attempt to search under non-existant entry: ";
-        assertHasEntry( listContext, msg, listContext.getDn() );
+        //String msg = "Attempt to search under non-existant entry: ";
+        //assertHasEntry( listContext, msg, listContext.getDn() );
 
         return nextInterceptor.list( listContext );
     }
@@ -425,7 +425,7 @@ public class ExceptionInterceptor extend
      * @param dn         the distinguished name of the entry that is asserted
      * @throws Exception if the entry does not exist
      * @param nextInterceptor the next interceptor in the chain
-     */
+     *
     private void assertHasEntry( OperationContext opContext, String msg, Dn dn ) throws LdapException
     {
         if ( subschemSubentryDn.equals( dn ) )
@@ -448,5 +448,5 @@ public class ExceptionInterceptor extend
 
             throw e;
         }
-    }
+    }*/
 }

Modified: directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java (original)
+++ directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java Sun Jul 10 22:24:41 2011
@@ -104,7 +104,6 @@ public class HttpServer
      */
     public void start( DirectoryService dirService ) throws Exception
     {
-
         this.dirService = dirService;
         
         XmlConfiguration jettyConf = null;
@@ -136,6 +135,7 @@ public class HttpServer
         if ( configured )
         {
             Handler[] handlers = jetty.getHandlers();
+            
             for( Handler h : handlers )
             {
                 if( h instanceof ContextHandler )

Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Sun Jul 10 22:24:41 2011
@@ -147,7 +147,7 @@ public class JdbmStore<E> extends Abstra
         // then add all index objects to a list
         List<String> allIndices = new ArrayList<String>();
         
-        for( Index i : systemIndices.values() )
+        for( Index<?, E, Long> i : systemIndices.values() )
         {
             allIndices.add( i.getAttribute().getOid() );
         }
@@ -156,7 +156,7 @@ public class JdbmStore<E> extends Abstra
         // one for collecting all user indices
         // two for finding a new index to be built
         // just to avoid another iteration for determining which is the new index
-        for( Index i : userIndices.values() )
+        for( Index<?, E, Long> i : userIndices.values() )
         {
             allIndices.add( i.getAttribute().getOid() );
 
@@ -231,26 +231,18 @@ public class JdbmStore<E> extends Abstra
             return;
         }
 
-        List<Index<?, E, Long>> array = new ArrayList<Index<?, E, Long>>();
-        array.addAll( userIndices.values() );
-        array.add( aliasIdx );
-        array.add( oneAliasIdx );
-        array.add( subAliasIdx );
-        array.add( oneLevelIdx );
-        array.add( presenceIdx );
-        array.add( subLevelIdx );
-        array.add( entryCsnIdx );
-        array.add( entryUuidIdx );
-        array.add( objectClassIdx );
-
+        // Sync all system indices
+        for ( Index<?, E, Long> idx : systemIndices.values() )
+        {
+            idx.sync();
+        }
+        
         // Sync all user defined userIndices
-        for ( Index<?, E, Long> idx : array )
+        for ( Index<?, E, Long> idx : userIndices.values() )
         {
             idx.sync();
         }
 
-        rdnIdx.sync();
-
         ( ( JdbmMasterTable<Entry> ) master ).sync();
         recMan.commit();
     }

Modified: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java (original)
+++ directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java Sun Jul 10 22:24:41 2011
@@ -29,9 +29,7 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.UUID;
 
 import javax.naming.directory.Attributes;
@@ -281,9 +279,9 @@ public class JdbmStoreTest
 
         assertNotNull( store.getSuffixDn() );
 
-        assertEquals( 0, store.getUserIndices().size() );
+        assertFalse( store.getUserIndices().hasNext() );
         store.addIndex( new JdbmIndex<Object, Attributes>( "2.5.4.3" ) );
-        assertEquals( 1, store.getUserIndices().size() );
+        assertEquals( true, store.getUserIndices().hasNext() );
 
         assertNull( store.getPartitionPath() );
         store.setPartitionPath( new File( "." ).toURI() );
@@ -404,7 +402,7 @@ public class JdbmStoreTest
         {
         }
 
-        Iterator<String> systemIndices = store.systemIndices();
+        Iterator<String> systemIndices = store.getSystemIndices();
 
         for ( int ii = 0; ii < 10; ii++ )
         {
@@ -434,11 +432,20 @@ public class JdbmStoreTest
 
         assertNotNull( store.getSuffixDn() );
 
-        assertEquals( 2, store.getUserIndices().size() );
+        Iterator<String> userIndices = store.getUserIndices();
+        int count = 0;
+        
+        while ( userIndices.hasNext() )
+        {
+            userIndices.next();
+            count++;
+        }
+        
+        assertEquals( 2, count );
         assertFalse( store.hasUserIndexOn( DC_AT ) );
         assertTrue( store.hasUserIndexOn( OU_AT ) );
         assertTrue( store.hasSystemIndexOn( APACHE_ALIAS_AT ) );
-        Iterator<String> userIndices = store.userIndices();
+        userIndices = store.getUserIndices();
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
         assertTrue( userIndices.hasNext() );
@@ -688,15 +695,12 @@ public class JdbmStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
         attrib.add( "Engineering" );
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
 
-        mods.add( add );
-
-        store.modify( dn, mods );
+        store.modify( dn, add );
     }
 
 
@@ -783,28 +787,17 @@ public class JdbmStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
-        Attribute attrib = new DefaultAttribute( SchemaConstants.SURNAME_AT, SN_AT );
+        Attribute attrib = new DefaultAttribute( "sn", SN_AT );
 
         String attribVal = "Walker";
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertTrue( lookedup.get( "sn" ).contains( attribVal ) );
-
-        // testing the store.modify( dn, mod, entry ) API
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        attribVal = "+1974045779";
-        entry.add( "telephoneNumber", attribVal );
-
-        store.modify( dn, ModificationOperation.ADD_ATTRIBUTE, entry );
-        lookedup = store.lookup( store.getEntryId( dn ) );
-        assertTrue( lookedup.get( "telephoneNumber" ).contains( attribVal ) );
     }
 
 
@@ -813,29 +806,26 @@ public class JdbmStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.SN_AT, SN_AT );
 
         String attribVal = "Johnny";
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
         assertEquals( "WAlkeR", lookedup.get( "sn" ).get().getString() ); // before replacing
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertEquals( attribVal, lookedup.get( "sn" ).get().getString() );
 
         // testing the store.modify( dn, mod, entry ) API
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        attribVal = "JWalker";
-        entry.add( "sn", attribVal );
+        Modification replace = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, SN_AT, "JWalker" );
 
-        store.modify( dn, ModificationOperation.REPLACE_ATTRIBUTE, entry );
-        assertEquals( attribVal, lookedup.get( "sn" ).get().getString() );
+        store.modify( dn, replace );
+        assertEquals( "JWalker", lookedup.get( "sn" ).get().getString() );
+        assertEquals( 1, lookedup.get( "sn" ).size() );
     }
 
 
@@ -844,28 +834,24 @@ public class JdbmStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.SN_AT, SN_AT );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
         assertNotNull( lookedup.get( "sn" ).get() );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertNull( lookedup.get( "sn" ) );
 
-        // testing the store.modify( dn, mod, entry ) API
-        Entry entry = new DefaultEntry( schemaManager, dn );
-
         // add an entry for the sake of testing the remove operation
-        entry.add( "sn", "JWalker" );
-        store.modify( dn, ModificationOperation.ADD_ATTRIBUTE, entry );
+        add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, SN_AT, "JWalker" );
+        store.modify( dn, add );
         assertNotNull( lookedup.get( "sn" ) );
 
-        store.modify( dn, ModificationOperation.REMOVE_ATTRIBUTE, entry );
+        Modification remove = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, SN_AT );
+        store.modify( dn, remove );
         assertNull( lookedup.get( "sn" ) );
     }
 
@@ -882,20 +868,18 @@ public class JdbmStoreTest
 
         store.add( entry );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
 
         String attribVal = "Marketing";
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
         assertNull( lookedup.get( "ou" ) ); // before replacing
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertEquals( attribVal, lookedup.get( "ou" ).get().getString() );
     }
 

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/AbstractLdifPartition.java Sun Jul 10 22:24:41 2011
@@ -27,7 +27,6 @@ import org.apache.directory.server.core.
 import org.apache.directory.server.core.partition.Partition;
 import org.apache.directory.server.core.partition.impl.avl.AvlPartition;
 import org.apache.directory.server.core.partition.impl.btree.BTreePartition;
-import org.apache.directory.server.xdbm.AbstractStore;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.shared.ldap.model.csn.CsnFactory;
@@ -358,12 +357,4 @@ public abstract class AbstractLdifPartit
         super.setSuffix( suffix );
         wrappedPartition.setSuffix( suffix );
     }
-
-    /**
-     * @see AbstractStore#setCheckHasEntryDuringAdd(boolean)
-     */
-    public void setCheckHasEntryDuringAdd( boolean checkHasEntryDuringAdd )
-    {
-        wrappedPartition.getStore().setCheckHasEntryDuringAdd( checkHasEntryDuringAdd );
-    }
 }

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifPartition.java Sun Jul 10 22:24:41 2011
@@ -41,6 +41,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.DefaultEntry;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.exception.LdapOperationException;
@@ -287,7 +288,7 @@ public class LdifPartition extends Abstr
     {
         Long id = getEntryId( modifyContext.getDn() );
 
-        wrappedPartition.modify( modifyContext.getDn(), modifyContext.getModItems() );
+        wrappedPartition.modify( modifyContext.getDn(), modifyContext.getModItems().toArray( new Modification[]{} ) );
 
         // Get the modified entry and store it in the context for post usage
         Entry modifiedEntry = lookup( id );

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java Sun Jul 10 22:24:41 2011
@@ -138,7 +138,6 @@ public class LdifPartitionTest
         // initialize the store
         // initialize the partition
         partition = new LdifPartition();
-        partition.setCheckHasEntryDuringAdd( true );
         partition.setId( "test-ldif" );
         partition.setSuffix( new Dn( "ou=test,ou=system" ) );
         partition.setSchemaManager( schemaManager );

Modified: directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java (original)
+++ directory/apacheds/trunk/ldif-partition/src/test/java/org/apache/directory/server/core/partition/SingleFileLdifPartitionTest.java Sun Jul 10 22:24:41 2011
@@ -213,7 +213,6 @@ public class SingleFileLdifPartitionTest
         }
 
         SingleFileLdifPartition partition = new SingleFileLdifPartition();
-        partition.setCheckHasEntryDuringAdd( true );
         partition.setId( "test-ldif" );
         partition.setPartitionPath( new File( fileName ).toURI() );
         partition.setSuffix( new Dn( "ou=test,ou=system" ) );

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/avl/AvlPartition.java Sun Jul 10 22:24:41 2011
@@ -21,7 +21,6 @@ package org.apache.directory.server.core
 
 
 import java.util.HashSet;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.directory.server.core.partition.impl.xdbm.AbstractXdbmPartition;
@@ -107,7 +106,7 @@ public class AvlPartition extends Abstra
     }
 
 
-    public final void modify( Dn dn, List<Modification> modifications ) throws LdapException
+    public final void modify( Dn dn, Modification... modifications ) throws LdapException
     {
         try
         {

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/xdbm/AbstractXdbmPartition.java Sun Jul 10 22:24:41 2011
@@ -38,6 +38,7 @@ import org.apache.directory.server.xdbm.
 import org.apache.directory.server.xdbm.IndexNotFoundException;
 import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.shared.ldap.model.entry.Entry;
+import org.apache.directory.shared.ldap.model.entry.Modification;
 import org.apache.directory.shared.ldap.model.exception.LdapAuthenticationNotSupportedException;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.exception.LdapOperationErrorException;
@@ -185,7 +186,7 @@ public abstract class AbstractXdbmPartit
      */
     public final Iterator<String> getUserIndices()
     {
-        return store.userIndices();
+        return store.getUserIndices();
     }
 
 
@@ -194,7 +195,7 @@ public abstract class AbstractXdbmPartit
      */
     public final Iterator<String> getSystemIndices()
     {
-        return store.systemIndices();
+        return store.getSystemIndices();
     }
 
 
@@ -358,7 +359,7 @@ public abstract class AbstractXdbmPartit
     {
         try
         {
-            Entry modifiedEntry = store.modify( modifyContext.getDn(), modifyContext.getModItems() );
+            Entry modifiedEntry = store.modify( modifyContext.getDn(), modifyContext.getModItems().toArray( new Modification[]{}) );
             modifyContext.setAlteredEntry( modifiedEntry );
         }
         catch ( Exception e )

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=1144982&r1=1144981&r2=1144982&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 Sun Jul 10 22:24:41 2011
@@ -23,11 +23,9 @@ package org.apache.directory.server.xdbm
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
@@ -38,7 +36,6 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.Attribute;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Modification;
-import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.entry.Value;
 import org.apache.directory.shared.ldap.model.exception.LdapAliasDereferencingException;
 import org.apache.directory.shared.ldap.model.exception.LdapAliasException;
@@ -169,7 +166,12 @@ public abstract class AbstractStore<E, I
     }
     
 
-    protected void protect( String property )
+    
+    /**
+     * Check that the operation is done on an initialized store
+     * @param property
+     */
+    private void checkInitialized( String property )
     {
         if ( initialized )
         {
@@ -187,22 +189,31 @@ public abstract class AbstractStore<E, I
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setPartitionPath( URI partitionPath )
     {
-        protect( "partitionPath" );
+        checkInitialized( "partitionPath" );
         this.partitionPath = partitionPath;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public URI getPartitionPath()
     {
         return partitionPath;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setSyncOnWrite( boolean isSyncOnWrite )
     {
-        protect( "syncOnWrite" );
+        checkInitialized( "syncOnWrite" );
         this.isSyncOnWrite.set( isSyncOnWrite );
     }
 
@@ -216,9 +227,12 @@ public abstract class AbstractStore<E, I
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setCacheSize( int cacheSize )
     {
-        protect( "cacheSize" );
+        checkInitialized( "cacheSize" );
         this.cacheSize = cacheSize;
     }
 
@@ -232,9 +246,12 @@ public abstract class AbstractStore<E, I
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setId( String id )
     {
-        protect( "id" );
+        checkInitialized( "id" );
         this.id = id;
     }
 
@@ -248,9 +265,12 @@ public abstract class AbstractStore<E, I
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public void setSuffixDn( Dn suffixDn )
     {
-        protect( "suffixDn" );
+        checkInitialized( "suffixDn" );
 
         if ( !suffixDn.isSchemaAware() )
         {
@@ -276,7 +296,7 @@ public abstract class AbstractStore<E, I
     /**
      * Sets up the user indices.
      */
-    protected void setupUserIndices() throws Exception
+    private void setupUserIndices() throws Exception
     {
         // convert and initialize system indices
         Map<String, Index<?, E, ID>> tmp = new HashMap<String, Index<?, E, ID>>();
@@ -415,7 +435,7 @@ public abstract class AbstractStore<E, I
     /**
      * {@inheritDoc}
      */
-    public Iterator<String> userIndices()
+    public Iterator<String> getUserIndices()
     {
         return userIndices.keySet().iterator();
     }
@@ -424,7 +444,7 @@ public abstract class AbstractStore<E, I
     /**
      * {@inheritDoc}
      */
-    public Iterator<String> systemIndices()
+    public Iterator<String> getSystemIndices()
     {
         return systemIndices.keySet().iterator();
     }
@@ -460,15 +480,6 @@ public abstract class AbstractStore<E, I
     /**
      * {@inheritDoc}
      */
-    public Set<Index<?, E, ID>> getUserIndices()
-    {
-        return new HashSet<Index<?, E, ID>>( userIndices.values() );
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public Index<?, E, ID> getIndex( AttributeType attributeType ) throws IndexNotFoundException
     {
         String id = attributeType.getOid();
@@ -534,7 +545,7 @@ public abstract class AbstractStore<E, I
      */
     public void addIndex( Index<?, E, ID> index ) throws Exception
     {
-        protect( "addIndex" );
+        checkInitialized( "addIndex" );
 
         // Check that the index ID is valid
         AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( index.getAttributeId() );
@@ -746,8 +757,10 @@ public abstract class AbstractStore<E, I
 
         if ( entry != null )
         {
+            // We have to store the DN in this entry
             Dn dn = buildEntryDn( id );
             entry.setDn( dn );
+            
             return entry;
         }
 
@@ -934,58 +947,11 @@ public abstract class AbstractStore<E, I
     /**
      * {@inheritDoc}
      */
-    public synchronized void modify( Dn dn, ModificationOperation modOp, Entry mods ) throws Exception
-    {
-        if ( mods instanceof ClonedServerEntry )
-        {
-            throw new Exception( I18n.err( I18n.ERR_215 ) );
-        }
-
-        ID id = getEntryId( dn );
-        Entry entry = master.get( id );
-
-        for ( AttributeType attributeType : mods.getAttributeTypes() )
-        {
-            Attribute attr = mods.get( attributeType );
-
-            switch ( modOp )
-            {
-                case ADD_ATTRIBUTE:
-                    add( id, entry, attr );
-                    break;
-
-                case REMOVE_ATTRIBUTE:
-                    remove( id, entry, attr );
-                    break;
-
-                case REPLACE_ATTRIBUTE:
-                    replace( id, entry, attr );
-
-                    break;
-
-                default:
-                    throw new LdapException( I18n.err( I18n.ERR_221 ) );
-            }
-        }
-
-        updateCsnIndex( entry, id );
-        master.put( id, entry );
-
-        if ( isSyncOnWrite.get() )
-        {
-            sync();
-        }
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
-    public synchronized Entry modify( Dn dn, List<Modification> mods ) throws Exception
+    public synchronized Entry modify( Dn dn, Modification... mods ) throws Exception
     {
         ID id = getEntryId( dn );
         Entry entry = master.get( id );
-
+        
         for ( Modification mod : mods )
         {
             Attribute attrMods = mod.getAttribute();
@@ -1228,13 +1194,13 @@ public abstract class AbstractStore<E, I
      */
     public synchronized void moveAndRename( Dn oldDn, Dn newSuperiorDn, Rdn newRdn, Entry modifiedEntry, boolean deleteOldRdn ) throws Exception
     {
-    	// Check that the old entry exists
+        // Check that the old entry exists
         ID oldId = getEntryId( oldDn );
 
         if ( oldId == null )
         {
             // This is not allowed : the old entry must exist
-        	LdapNoSuchObjectException nse = new LdapNoSuchObjectException(
+            LdapNoSuchObjectException nse = new LdapNoSuchObjectException(
                 I18n.err( I18n.ERR_256_NO_SUCH_OBJECT, oldDn ) );
             throw nse;
         }
@@ -1245,7 +1211,7 @@ public abstract class AbstractStore<E, I
         if ( newSuperiorId == null )
         {
             // This is not allowed : the new superior must exist
-        	LdapNoSuchObjectException nse = new LdapNoSuchObjectException(
+            LdapNoSuchObjectException nse = new LdapNoSuchObjectException(
                 I18n.err( I18n.ERR_256_NO_SUCH_OBJECT, newSuperiorDn ) );
             throw nse;
         }
@@ -1378,7 +1344,7 @@ public abstract class AbstractStore<E, I
      * @return the normalized Dn of the entry
      * @throws Exception
      */
-    protected Dn buildEntryDn( ID id ) throws Exception
+    private Dn buildEntryDn( ID id ) throws Exception
     {
         ID parentId = id;
         ID rootId = getRootId();
@@ -2003,7 +1969,7 @@ public abstract class AbstractStore<E, I
      * @param newParentId new parent's id
      * @throws Exception
      */
-    protected void updateSubLevelIndex( ID entryId, ID oldParentId, ID newParentId ) throws Exception
+    private void updateSubLevelIndex( ID entryId, ID oldParentId, ID newParentId ) throws Exception
     {
         ID tempId = oldParentId;
         List<ID> parentIds = new ArrayList<ID>();
@@ -2071,16 +2037,6 @@ public abstract class AbstractStore<E, I
 
     
     /**
-     * set the flag to nable/disable checking of entry existence before actually adding it
-     * @param checkHasEntryDuringAdd
-     */
-    public void setCheckHasEntryDuringAdd( boolean checkHasEntryDuringAdd )
-    {
-        this.checkHasEntryDuringAdd = checkHasEntryDuringAdd;
-    }
-
-
-    /**
      * @return the schemaManager
      */
     public SchemaManager getSchemaManager()

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/Store.java Sun Jul 10 22:24:41 2011
@@ -25,14 +25,12 @@ import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Iterator;
-import java.util.List;
 import java.util.Set;
 
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.Modification;
-import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
 import org.apache.directory.shared.ldap.model.name.Dn;
 import org.apache.directory.shared.ldap.model.name.Rdn;
@@ -128,14 +126,6 @@ public interface Store<E, ID extends Com
 
 
     /**
-     * Gets the user indices.
-     * 
-     * @return The list of user index
-     */
-    Set<Index<?, E, ID>> getUserIndices();
-
-
-    /**
      * Sets the suffix Dn, must be normalized.
      * 
      * @param suffixDn the new suffix Dn
@@ -315,13 +305,13 @@ public interface Store<E, ID extends Com
     /**
      * An iterator build on top of the User's index
      */
-    Iterator<String> userIndices();
+    Iterator<String> getUserIndices();
 
 
     /**
      * An iterator build on top of the System's index
      */
-    Iterator<String> systemIndices();
+    Iterator<String> getSystemIndices();
 
 
     /**
@@ -468,9 +458,6 @@ public interface Store<E, ID extends Com
     int getChildCount( ID id ) throws Exception;
 
 
-    void modify( Dn dn, ModificationOperation modOp, Entry mods ) throws Exception;
-
-
     /**
      * Modify an entry applying the given list of modifications.
      *
@@ -479,7 +466,7 @@ public interface Store<E, ID extends Com
      * @return The modified entry
      * @throws Exception If the modification failed
      */
-    Entry modify( Dn dn, List<Modification> mods ) throws Exception;
+    Entry modify( Dn dn, Modification... mods ) throws Exception;
 
 
     /**

Modified: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java (original)
+++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java Sun Jul 10 22:24:41 2011
@@ -29,8 +29,7 @@ import static org.junit.Assert.assertTru
 import static org.junit.Assert.fail;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Iterator;
 
 import org.apache.directory.server.xdbm.impl.avl.AvlIndex;
 import org.apache.directory.server.xdbm.impl.avl.AvlStore;
@@ -152,7 +151,17 @@ public class AbstractStoreTest
         assertEquals( 27, store.getObjectClassIndex().count() );
         assertEquals( 11, store.getEntryCsnIndex().count() );
         assertEquals( 11, store.getEntryUuidIndex().count() );
-        assertEquals( 3, store.getUserIndices().size() );
+        
+        Iterator<String> userIndices = store.getUserIndices();
+        int count = 0;
+        
+        while ( userIndices.hasNext() )
+        {
+            userIndices.next();
+            count++;
+        }
+
+        assertEquals( 3, count );
         assertEquals( 9, store.getUserIndex( OU_AT ).count() );
         assertEquals( 0, store.getUserIndex( UID_AT ).count() );
         assertEquals( 6, store.getUserIndex( CN_AT ).count() );
@@ -167,7 +176,6 @@ public class AbstractStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OBJECT_CLASS_AT, schemaManager
             .lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT ) );
 
@@ -175,7 +183,6 @@ public class AbstractStoreTest
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Long entryId = store.getEntryId( dn );
         Entry lookedup = store.lookup( entryId );
@@ -184,7 +191,7 @@ public class AbstractStoreTest
         assertFalse( store.getObjectClassIndex().forward( "uidObject", entryId ) );
         assertFalse( lookedup.get( "objectClass" ).contains( "uidObject" ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
 
         // after modification: expect "uidObject" tuple in objectClass index
         assertTrue( store.getObjectClassIndex().forward( "uidObject", entryId ) );
@@ -200,14 +207,12 @@ public class AbstractStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
 
         String attribVal = "sales";
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Long entryId = store.getEntryId( dn );
         Entry lookedup = store.lookup( entryId );
@@ -217,7 +222,7 @@ public class AbstractStoreTest
         assertTrue( ouIndex.forward( "sales", entryId ) );
         assertTrue( lookedup.get( "ou" ).contains( "sales" ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
 
         // after modification: no "sales" tuple in ou index
         assertFalse( ouIndex.forward( "sales", entryId ) );
@@ -234,11 +239,9 @@ public class AbstractStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Long entryId = store.getEntryId( dn );
         Entry lookedup = store.lookup( entryId );
@@ -249,7 +252,7 @@ public class AbstractStoreTest
         assertTrue( ouIndex.forward( "sales", entryId ) );
         assertTrue( lookedup.get( "ou" ).contains( "sales" ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
 
         // after modification: no "sales" tuple in ou index
         assertFalse( store.getPresenceIndex().forward( SchemaConstants.OU_AT_OID, entryId ) );
@@ -267,7 +270,6 @@ public class AbstractStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OBJECT_CLASS_AT, schemaManager
             .lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT ) );
 
@@ -275,7 +277,6 @@ public class AbstractStoreTest
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Long entryId = store.getEntryId( dn );
         Entry lookedup = store.lookup( entryId );
@@ -284,7 +285,7 @@ public class AbstractStoreTest
         assertTrue( store.getObjectClassIndex().forward( "person", entryId ) );
         assertTrue( lookedup.get( "objectClass" ).contains( "person" ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
 
         // after modification: no "person" tuple in objectClass index
         assertFalse( store.getObjectClassIndex().forward( "person", entryId ) );
@@ -300,12 +301,10 @@ public class AbstractStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OBJECT_CLASS_AT, schemaManager
             .lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT ) );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Long entryId = store.getEntryId( dn );
         Entry lookedup = store.lookup( entryId );
@@ -315,7 +314,7 @@ public class AbstractStoreTest
         assertTrue( store.getObjectClassIndex().forward( "person", entryId ) );
         assertTrue( lookedup.get( "objectClass" ).contains( "person" ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
 
         // after modification: no tuple in objectClass index
         assertFalse( store.getObjectClassIndex().reverse( entryId ) );
@@ -329,7 +328,6 @@ public class AbstractStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         AttributeType csnAt = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT );
         Attribute attrib = new DefaultAttribute( csnAt );
         
@@ -338,7 +336,6 @@ public class AbstractStoreTest
         attrib.add( csn );
 
         Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Long entryId = store.getEntryId( dn );
         Entry lookedup = store.lookup( entryId );
@@ -346,7 +343,7 @@ public class AbstractStoreTest
         assertNotSame( csn, lookedup.get( csnAt ).getString() );
         assertNotSame( csn, store.getEntryCsnIndex().reverseLookup( entryId ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         
         String updateCsn = lookedup.get( csnAt ).getString();
         assertEquals( csn, updateCsn );
@@ -360,7 +357,7 @@ public class AbstractStoreTest
         assertNotSame( csn, updateCsn );
         assertNotSame( csn, store.getEntryCsnIndex().reverseLookup( entryId ) );
         
-        store.modify( dn, ModificationOperation.REPLACE_ATTRIBUTE, modEntry );
+        store.modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, csnAt, csn ) );
         
         assertEquals( csn, lookedup.get( csnAt ).getString() );
         assertEquals( csn, store.getEntryCsnIndex().reverseLookup( entryId ) );

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=1144982&r1=1144981&r2=1144982&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 Sun Jul 10 22:24:41 2011
@@ -29,9 +29,7 @@ import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.UUID;
 
 import javax.naming.directory.Attributes;
@@ -126,10 +124,10 @@ public class AvlStoreTest
 
         EXAMPLE_COM = new Dn( schemaManager, "dc=example,dc=com" );
 
-        OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT );
-        SN_AT = schemaManager.getAttributeType( SchemaConstants.SN_AT );
-        DC_AT = schemaManager.getAttributeType( SchemaConstants.DC_AT );
-        APACHE_ALIAS_AT = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_ALIAS_AT );
+        OU_AT = schemaManager.getAttributeType( "ou" );
+        SN_AT = schemaManager.getAttributeType( "sn" );
+        DC_AT = schemaManager.getAttributeType( "dc" );
+        APACHE_ALIAS_AT = schemaManager.getAttributeType( "apacheAlias" );
     }
 
 
@@ -205,9 +203,9 @@ public class AvlStoreTest
 
         assertNotNull( store.getSuffixDn() );
 
-        assertEquals( 0, store.getUserIndices().size() );
+        assertFalse( store.getUserIndices().hasNext() );
         store.addIndex( new AvlIndex<Object, Attributes>( "2.5.4.3" ) );
-        assertEquals( 1, store.getUserIndices().size() );
+        assertTrue( store.getUserIndices().hasNext() );
 
         assertNull( store.getPartitionPath() );
         store.setPartitionPath( new File( "." ).toURI() );
@@ -327,7 +325,7 @@ public class AvlStoreTest
         {
         }
 
-        Iterator<String> systemIndices = store.systemIndices();
+        Iterator<String> systemIndices = store.getSystemIndices();
 
         for ( int i = 0; i < 10; i++ )
         {
@@ -357,11 +355,21 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getSuffixDn() );
-        assertEquals( 2, store.getUserIndices().size() );
+        
+        Iterator<String> userIndices = store.getUserIndices();
+        int count = 0;
+        
+        while ( userIndices.hasNext() )
+        {
+            userIndices.next();
+            count++;
+        }
+
+        assertEquals( 2, count );
         assertFalse( store.hasUserIndexOn( DC_AT ) );
         assertTrue( store.hasUserIndexOn( OU_AT ) );
         assertTrue( store.hasSystemIndexOn( APACHE_ALIAS_AT ) );
-        Iterator<String> userIndices = store.userIndices();
+        userIndices = store.getUserIndices();
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
         assertTrue( userIndices.hasNext() );
@@ -593,15 +601,12 @@ public class AvlStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
         attrib.add( "Engineering" );
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
 
-        mods.add( add );
-
-        store.modify( dn, mods );
+        store.modify( dn, add );
     }
 
 
@@ -687,7 +692,6 @@ public class AvlStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.SURNAME_AT, schemaManager
             .lookupAttributeTypeRegistry( SchemaConstants.SURNAME_AT ) );
 
@@ -695,21 +699,16 @@ public class AvlStoreTest
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertTrue( lookedup.get( "sn" ).contains( attribVal ) );
 
-        // testing the store.modify( dn, mod, entry ) API
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        attribVal = "+1974045779";
-        entry.add( "telephoneNumber", attribVal );
-
-        store.modify( dn, ModificationOperation.ADD_ATTRIBUTE, entry );
+        store.modify( dn, new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, 
+            schemaManager.getAttributeType( "telephoneNumber" ), "+1974045779" ) );
         lookedup = store.lookup( store.getEntryId( dn ) );
-        assertTrue( lookedup.get( "telephoneNumber" ).contains( attribVal ) );
+        assertTrue( lookedup.get( "telephoneNumber" ).contains( "+1974045779" ) );
     }
 
 
@@ -718,7 +717,6 @@ public class AvlStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.SN_AT, schemaManager
             .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
 
@@ -726,22 +724,16 @@ public class AvlStoreTest
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
         assertEquals( "WAlkeR", lookedup.get( "sn" ).get().getString() ); // before replacing
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertEquals( attribVal, lookedup.get( "sn" ).get().getString() );
 
-        // testing the store.modify( dn, mod, entry ) API
-        Entry entry = new DefaultEntry( schemaManager, dn );
-        attribVal = "JWalker";
-        entry.add( "sn", attribVal );
-
-        store.modify( dn, ModificationOperation.REPLACE_ATTRIBUTE, entry );
-        assertEquals( attribVal, lookedup.get( "sn" ).get().getString() );
+        store.modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, SN_AT, "JWalker" ) );
+        assertEquals( "JWalker", lookedup.get( "sn" ).get().getString() );
     }
 
 
@@ -750,29 +742,23 @@ public class AvlStoreTest
     {
         Dn dn = new Dn( schemaManager, "cn=JOhnny WAlkeR,ou=Sales,o=Good Times Co." );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.SN_AT, schemaManager
             .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
         assertNotNull( lookedup.get( "sn" ).get() );
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertNull( lookedup.get( "sn" ) );
 
-        // testing the store.modify( dn, mod, entry ) API
-        Entry entry = new DefaultEntry( schemaManager, dn );
-
         // add an entry for the sake of testing the remove operation
-        entry.add( "sn", "JWalker" );
-        store.modify( dn, ModificationOperation.ADD_ATTRIBUTE, entry );
+        store.modify( dn, new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, SN_AT, "JWalker" ) );
         assertNotNull( lookedup.get( "sn" ) );
 
-        store.modify( dn, ModificationOperation.REMOVE_ATTRIBUTE, entry );
+        store.modify( dn, new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, SN_AT ) );
         assertNull( lookedup.get( "sn" ) );
     }
 
@@ -789,20 +775,18 @@ public class AvlStoreTest
 
         store.add( entry );
 
-        List<Modification> mods = new ArrayList<Modification>();
         Attribute attrib = new DefaultAttribute( SchemaConstants.OU_AT, OU_AT );
 
         String attribVal = "Marketing";
         attrib.add( attribVal );
 
         Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib );
-        mods.add( add );
 
         Entry lookedup = store.lookup( store.getEntryId( dn ) );
 
         assertNull( lookedup.get( "ou" ) ); // before replacing
 
-        store.modify( dn, mods );
+        store.modify( dn, add );
         assertEquals( attribVal, lookedup.get( "ou" ).get().getString() );
     }
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultAttribute.java Sun Jul 10 22:24:41 2011
@@ -281,7 +281,12 @@ public class DefaultAttribute implements
         }
 
         apply( attributeType );
-        add( vals );
+        
+        if ( ( vals != null ) && ( vals.length > 0 ) )
+        {
+            add( vals );
+        }
+        
         setUpId( upId, attributeType );
     }
 

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java?rev=1144982&r1=1144981&r2=1144982&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java Sun Jul 10 22:24:41 2011
@@ -116,6 +116,19 @@ public class DefaultModification impleme
 
 
     /**
+     * Creates a new instance of DefaultModification with no value
+     *
+     * @param operation The modification operation
+     * @param attributeId The associated attribute ID
+     */
+    public DefaultModification( ModificationOperation operation, String attributeId )
+    {
+        this.operation = operation;
+        this.attribute = new DefaultAttribute( attributeId );
+    }
+
+
+    /**
      * Creates a new instance of DefaultModification.
      *
      * @param operation The modification operation
@@ -161,6 +174,20 @@ public class DefaultModification impleme
 
 
     /**
+     * Creates a new instance of DefaultModification with no value.
+     *
+     * @param operation The modification operation
+     * @param attributeType The associated attributeType
+     */
+    public DefaultModification( ModificationOperation operation, AttributeType attributeType )
+    throws LdapInvalidAttributeValueException
+    {
+        this.operation = operation;
+        this.attribute = new DefaultAttribute( attributeType );
+    }
+
+
+    /**
      * Creates a new instance of DefaultModification.
      *
      * @param schemaManager The schema manager 



Mime
View raw message