directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r963693 - in /directory/apacheds/trunk: jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/ xdbm-partition/src/main/java/org/...
Date Tue, 13 Jul 2010 12:39:43 GMT
Author: elecharny
Date: Tue Jul 13 12:39:43 2010
New Revision: 963693

URL: http://svn.apache.org/viewvc?rev=963693&view=rev
Log:
o Modified the getSystemIndex/getUserIndex/hasSystemIndexOn/hasUserIndexOn methods in AbstractXdbmPartition
to take an AttributeType instead of a String
o Fixed the code and tests accordingly

Modified:
    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/LdifPartition.java
    directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.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/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java
    directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java

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=963693&r1=963692&r2=963693&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
Tue Jul 13 12:39:43 2010
@@ -91,6 +91,15 @@ public class JdbmStoreTest
     /** The OU AttributeType instance */
     private static AttributeType OU_AT;
 
+    /** The ApacheAlias AttributeType instance */
+    private static AttributeType APACHE_ALIAS_AT;
+
+    /** The DC AttributeType instance */
+    private static AttributeType DC_AT;
+
+    /** The SN AttributeType instance */
+    private static AttributeType SN_AT;
+
 
     @BeforeClass
     public static void setup() throws Exception
@@ -121,6 +130,9 @@ public class JdbmStoreTest
         EXAMPLE_COM.normalize( schemaManager.getNormalizerMapping() );
         
         OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT );
+        DC_AT = schemaManager.getAttributeType( SchemaConstants.DC_AT );
+        SN_AT = schemaManager.getAttributeType( SchemaConstants.SN_AT );
+        APACHE_ALIAS_AT = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_ALIAS_AT
);
     }
 
 
@@ -389,7 +401,8 @@ public class JdbmStoreTest
         }
 
         assertFalse( systemIndices.hasNext() );
-        assertNotNull( store.getSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT ) );
+        assertNotNull( store.getSystemIndex( APACHE_ALIAS_AT ) );
+        
         try
         {
             store.getSystemIndex( "bogus" );
@@ -400,7 +413,7 @@ public class JdbmStoreTest
         }
         try
         {
-            store.getSystemIndex( "dc" );
+            store.getSystemIndex( DC_AT );
             fail();
         }
         catch ( IndexNotFoundException e )
@@ -412,14 +425,14 @@ public class JdbmStoreTest
         assertEquals( 2, store.getUserIndices().size() );
         assertFalse( store.hasUserIndexOn( "dc" ) );
         assertTrue( store.hasUserIndexOn( OU_AT ) );
-        assertTrue( store.hasSystemIndexOn( ApacheSchemaConstants.APACHE_ALIAS_AT ) );
+        assertTrue( store.hasSystemIndexOn( APACHE_ALIAS_AT ) );
         Iterator<String> userIndices = store.userIndices();
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
         assertFalse( userIndices.hasNext() );
-        assertNotNull( store.getUserIndex( SchemaConstants.OU_AT ) );
+        assertNotNull( store.getUserIndex( OU_AT ) );
         try
         {
             store.getUserIndex( "bogus" );
@@ -783,8 +796,7 @@ public class JdbmStoreTest
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.SURNAME_AT, schemaManager
-            .lookupAttributeTypeRegistry( SchemaConstants.SURNAME_AT ) );
+        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.SURNAME_AT, SN_AT
);
 
         String attribVal = "Walker";
         attrib.add( attribVal );
@@ -815,8 +827,7 @@ public class JdbmStoreTest
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.SN_AT, schemaManager
-            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
+        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.SN_AT, SN_AT );
 
         String attribVal = "Johnny";
         attrib.add( attribVal );
@@ -848,8 +859,7 @@ public class JdbmStoreTest
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.SN_AT, schemaManager
-            .lookupAttributeTypeRegistry( SchemaConstants.SN_AT_OID ) );
+        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.SN_AT, SN_AT );
 
         Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
attrib );
         mods.add( add );

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=963693&r1=963692&r2=963693&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
Tue Jul 13 12:39:43 2010
@@ -884,9 +884,9 @@ public class LdifPartition extends BTree
 
 
     @Override
-    public Index<?, Entry, Long> getSystemIndex( String id ) throws Exception
+    public Index<?, Entry, Long> getSystemIndex( AttributeType attributeType ) throws
Exception
     {
-        return wrappedPartition.getSystemIndex( id );
+        return wrappedPartition.getSystemIndex( attributeType );
     }
 
 
@@ -898,9 +898,9 @@ public class LdifPartition extends BTree
 
 
     @Override
-    public Index<? extends Object, Entry, Long> getUserIndex( String id ) throws Exception
+    public Index<? extends Object, Entry, Long> getUserIndex( AttributeType attributeType
) throws Exception
     {
-        return wrappedPartition.getUserIndex( id );
+        return wrappedPartition.getUserIndex( attributeType );
     }
 
 
@@ -912,16 +912,16 @@ public class LdifPartition extends BTree
 
 
     @Override
-    public boolean hasSystemIndexOn( String id ) throws Exception
+    public boolean hasSystemIndexOn( AttributeType attributeType ) throws Exception
     {
-        return wrappedPartition.hasSystemIndexOn( id );
+        return wrappedPartition.hasSystemIndexOn( attributeType );
     }
 
 
     @Override
-    public boolean hasUserIndexOn( String id ) throws Exception
+    public boolean hasUserIndexOn( AttributeType attributeType ) throws Exception
     {
-        return wrappedPartition.hasUserIndexOn( id );
+        return wrappedPartition.hasUserIndexOn( attributeType );
     }
 
 

Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java?rev=963693&r1=963692&r2=963693&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
(original)
+++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/BTreePartition.java
Tue Jul 13 12:39:43 2010
@@ -344,10 +344,10 @@ public abstract class BTreePartition<ID>
     public abstract void addIndexOn( Index<? extends Object, Entry, ID> index ) throws
Exception;
 
 
-    public abstract boolean hasUserIndexOn( String attribute ) throws Exception;
+    public abstract boolean hasUserIndexOn( AttributeType attributeType ) throws Exception;
 
 
-    public abstract boolean hasSystemIndexOn( String attribute ) throws Exception;
+    public abstract boolean hasSystemIndexOn( AttributeType attributeType ) throws Exception;
 
 
     public abstract Index<String, Entry, ID> getPresenceIndex();
@@ -423,12 +423,12 @@ public abstract class BTreePartition<ID>
     }
 
 
-    public abstract Index<? extends Object, Entry, ID> getUserIndex( String attribute
) throws Exception;
+    public abstract Index<? extends Object, Entry, ID> getUserIndex( AttributeType
attributeType ) throws Exception;
 
 
-    public abstract Index<? extends Object, Entry, ID> getSystemIndex( String attribute
) throws Exception;
-
+    public abstract Index<? extends Object, Entry, ID> getSystemIndex( AttributeType
attributeType ) throws Exception;
 
+    
     public abstract ID getEntryId( DN dn ) throws LdapException;
 
 

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=963693&r1=963692&r2=963693&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
Tue Jul 13 12:39:43 2010
@@ -45,6 +45,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.DN;
 import org.apache.directory.shared.ldap.name.RDN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 
 
 /**
@@ -168,33 +169,33 @@ public abstract class AbstractXdbmPartit
     }
 
 
-    public final boolean hasUserIndexOn( String id ) throws Exception
+    public final boolean hasUserIndexOn( AttributeType attributeType ) throws Exception
     {
-        return store.hasUserIndexOn( id );
+        return store.hasUserIndexOn( attributeType );
     }
 
 
-    public final boolean hasSystemIndexOn( String id ) throws Exception
+    public final boolean hasSystemIndexOn( AttributeType attributeType ) throws Exception
     {
-        return store.hasSystemIndexOn( id );
+        return store.hasSystemIndexOn( attributeType );
     }
 
 
     /**
      * @see org.apache.directory.server.core.partition.impl.btree.BTreePartition#getUserIndex(String)
      */
-    public final Index<? extends Object, Entry, ID> getUserIndex( String id ) throws
IndexNotFoundException
+    public final Index<? extends Object, Entry, ID> getUserIndex( AttributeType attributeType
) throws IndexNotFoundException
     {
-        return store.getUserIndex( id );
+        return store.getUserIndex( attributeType );
     }
 
 
     /**
      * @see BTreePartition#getEntryId(String)
      */
-    public final Index<? extends Object, Entry, ID> getSystemIndex( String id ) throws
IndexNotFoundException
+    public final Index<? extends Object, Entry, ID> getSystemIndex( AttributeType attributeType
) throws IndexNotFoundException
     {
-        return store.getSystemIndex( id );
+        return store.getSystemIndex( attributeType );
     }
 
 

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=963693&r1=963692&r2=963693&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
Tue Jul 13 12:39:43 2010
@@ -92,6 +92,9 @@ public class AvlStoreTest
 
     /** The DC AttributeType instance */
     private static AttributeType DC_AT;
+    
+    /** The ApacheAlias AttributeType instance */
+    private static AttributeType APACHE_ALIAS_AT;
 
 
     @BeforeClass
@@ -125,6 +128,7 @@ public class AvlStoreTest
 
         OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT );
         DC_AT = schemaManager.getAttributeType( SchemaConstants.DC_AT );
+        APACHE_ALIAS_AT = schemaManager.getAttributeType( ApacheSchemaConstants.APACHE_ALIAS_AT
);
     }
 
 
@@ -225,6 +229,7 @@ public class AvlStoreTest
     public void testSimplePropertiesLocked() throws Exception
     {
         assertNotNull( store.getAliasIndex() );
+        
         try
         {
             store.addIndex( new AvlIndex<String, Entry>( ApacheSchemaConstants.APACHE_ALIAS_AT_OID
) );
@@ -235,8 +240,8 @@ public class AvlStoreTest
         }
 
         assertEquals( 0, store.getCacheSize() );
-
         assertNotNull( store.getPresenceIndex() );
+        
         try
         {
             store.addIndex( new AvlIndex<String, Entry>( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID
) );
@@ -247,6 +252,7 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getOneLevelIndex() );
+        
         try
         {
             store.addIndex( new AvlIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID
) );
@@ -257,6 +263,7 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getSubLevelIndex() );
+        
         try
         {
             store.addIndex( new AvlIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID
) );
@@ -267,6 +274,7 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getId() );
+        
         try
         {
             store.setId( "foo" );
@@ -277,8 +285,8 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getNdnIndex() );
-
         assertNotNull( store.getRdnIndex() );
+        
         try
         {
             store.addIndex( new AvlRdnIndex( ApacheSchemaConstants.APACHE_RDN_AT_OID ) );
@@ -289,6 +297,7 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getOneAliasIndex() );
+        
         try
         {
             store.addIndex( new AvlIndex<Long, Entry>( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID
) );
@@ -299,6 +308,7 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getSubAliasIndex() );
+        
         try
         {
             store.addIndex( new AvlIndex<Long, Entry>( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID
) );
@@ -309,6 +319,7 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getSuffixDn() );
+        
         try
         {
             store.setSuffixDn( EXAMPLE_COM );
@@ -320,14 +331,15 @@ public class AvlStoreTest
 
         Iterator<String> systemIndices = store.systemIndices();
 
-        for ( int ii = 0; ii < 10; ii++ )
+        for ( int i = 0; i < 10; i++ )
         {
             assertTrue( systemIndices.hasNext() );
             assertNotNull( systemIndices.next() );
         }
 
         assertFalse( systemIndices.hasNext() );
-        assertNotNull( store.getSystemIndex( ApacheSchemaConstants.APACHE_ALIAS_AT_OID )
);
+        assertNotNull( store.getSystemIndex( APACHE_ALIAS_AT ) );
+        
         try
         {
             store.getSystemIndex( "bogus" );
@@ -336,9 +348,10 @@ public class AvlStoreTest
         catch ( IndexNotFoundException e )
         {
         }
+        
         try
         {
-            store.getSystemIndex( "dc" );
+            store.getSystemIndex( DC_AT );
             fail();
         }
         catch ( IndexNotFoundException e )
@@ -346,18 +359,18 @@ public class AvlStoreTest
         }
 
         assertNotNull( store.getSuffixDn() );
-
         assertEquals( 2, store.getUserIndices().size() );
         assertFalse( store.hasUserIndexOn( DC_AT ) );
         assertTrue( store.hasUserIndexOn( OU_AT ) );
-        assertTrue( store.hasSystemIndexOn( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ) );
+        assertTrue( store.hasSystemIndexOn( APACHE_ALIAS_AT ) );
         Iterator<String> userIndices = store.userIndices();
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
         assertTrue( userIndices.hasNext() );
         assertNotNull( userIndices.next() );
         assertFalse( userIndices.hasNext() );
-        assertNotNull( store.getUserIndex( SchemaConstants.OU_AT_OID ) );
+        assertNotNull( store.getUserIndex( OU_AT ) );
+        
         try
         {
             store.getUserIndex( "bogus" );
@@ -366,6 +379,7 @@ public class AvlStoreTest
         catch ( IndexNotFoundException e )
         {
         }
+        
         try
         {
             store.getUserIndex( "dc" );
@@ -376,7 +390,6 @@ public class AvlStoreTest
         }
 
         assertNull( store.getPartitionDir() );
-
         assertTrue( store.isInitialized() );
         assertFalse( store.isSyncOnWrite() );
 
@@ -400,9 +413,6 @@ public class AvlStoreTest
         dn.normalize( schemaManager.getNormalizerMapping() );
         assertEquals( 1L, ( long ) store.getEntryId( dn ) );
         assertEquals( 11, store.count() );
-        //        assertEquals( "o=Good Times Co.", store.getEntryDn( 1L ).getName() );
-        //        assertEquals( dn.getNormName(), store.getEntryDn( 1L ).getNormName() );
-        //        assertEquals( dn.getName(), store.getEntryDn( 1L ).getName() );
 
         // note that the suffix entry returns 0 for it's parent which does not exist
         assertEquals( 0L, ( long ) store.getParentId( store.getEntryId( dn ) ) );
@@ -604,8 +614,7 @@ public class AvlStoreTest
         dn.normalize( schemaManager.getNormalizerMapping() );
 
         List<Modification> mods = new ArrayList<Modification>();
-        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.OU_AT, schemaManager
-            .lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );
+        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.OU_AT, OU_AT );
         attrib.add( "Engineering" );
 
         Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE,
attrib );
@@ -812,8 +821,7 @@ public class AvlStoreTest
         store.add( entry );
 
         List<Modification> mods = new ArrayList<Modification>();
-        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.OU_AT, schemaManager
-            .lookupAttributeTypeRegistry( SchemaConstants.OU_AT_OID ) );
+        EntryAttribute attrib = new DefaultEntryAttribute( SchemaConstants.OU_AT, OU_AT );
 
         String attribVal = "Marketing";
         attrib.add( attribVal );

Modified: directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java?rev=963693&r1=963692&r2=963693&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
(original)
+++ directory/apacheds/trunk/xdbm-tools/src/main/java/org/apache/directory/server/core/partition/impl/btree/gui/PartitionFrame.java
Tue Jul 13 12:39:43 2010
@@ -73,6 +73,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.ldif.LdifReader;
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.DN;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
@@ -789,16 +790,18 @@ public class PartitionFrame extends JFra
      */
     public void showIndexDialog( String idxAttr ) throws Exception
     {
+        AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( idxAttr
);
+        
         Index index;
-        boolean isSystem = partition.hasSystemIndexOn( idxAttr );
+        boolean isSystem = partition.hasSystemIndexOn( attributeType );
 
         if ( isSystem )
         {
-            index = partition.getSystemIndex( idxAttr );
+            index = partition.getSystemIndex( attributeType );
         }
         else
         {
-            index = partition.getUserIndex( idxAttr );
+            index = partition.getUserIndex( attributeType );
         }
 
         if ( index != null )



Mime
View raw message