Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 574B0692B for ; Fri, 8 Jul 2011 11:10:45 +0000 (UTC) Received: (qmail 39749 invoked by uid 500); 8 Jul 2011 11:10:44 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 39678 invoked by uid 500); 8 Jul 2011 11:10:41 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 39669 invoked by uid 99); 8 Jul 2011 11:10:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jul 2011 11:10:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jul 2011 11:10:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D3A7323888FE for ; Fri, 8 Jul 2011 11:10:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1144255 - in /directory/apacheds/trunk: jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ jdbm-partition/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ xdbm-partition/src/ma... Date: Fri, 08 Jul 2011 11:10:13 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110708111013.D3A7323888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elecharny Date: Fri Jul 8 11:10:13 2011 New Revision: 1144255 URL: http://svn.apache.org/viewvc?rev=1144255&view=rev Log: o The getRootId() method has been added to the Store interface o Removed the Store.hasIndexOn( String id ), Store.getUserIndex( String id ) and Store.getSystemIndex( String id ) methods. o Added some Javadoc o The Store suffix ID is now computed only once o Fixed the tests accordingly to those changes Modified: 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/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/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.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 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=1144255&r1=1144254&r2=1144255&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 Fri Jul 8 11:10:13 2011 @@ -95,8 +95,10 @@ public class JdbmStore extends Abstra } - @Override - protected Long getRootId() + /** + * {@inheritDoc} + */ + public Long getRootId() { return 0L; } 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=1144255&r1=1144254&r2=1144255&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 Fri Jul 8 11:10:13 2011 @@ -100,7 +100,6 @@ public class JdbmStoreTest /** The SN AttributeType instance */ private static AttributeType SN_AT; - @BeforeClass public static void setup() throws Exception { @@ -418,7 +417,7 @@ public class JdbmStoreTest try { - store.getSystemIndex( "bogus" ); + store.getSystemIndex( SN_AT ); fail(); } catch ( IndexNotFoundException e ) @@ -448,7 +447,7 @@ public class JdbmStoreTest assertNotNull( store.getUserIndex( OU_AT ) ); try { - store.getUserIndex( "bogus" ); + store.getUserIndex( SN_AT ); fail(); } catch ( IndexNotFoundException e ) @@ -456,7 +455,7 @@ public class JdbmStoreTest } try { - store.getUserIndex( "dc" ); + store.getUserIndex( DC_AT ); fail(); } catch ( IndexNotFoundException 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=1144255&r1=1144254&r2=1144255&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java Fri Jul 8 11:10:13 2011 @@ -95,6 +95,9 @@ public abstract class AbstractStore key = new ParentIdAndRdn( getRootId(), suffixDn.getRdns() ); - - return rdnIdx.forwardLookup( key ); - } - - - /** * {@inheritDoc} */ public Iterator userIndices() @@ -434,15 +418,6 @@ public abstract class AbstractStore getUserIndex( String id ) throws IndexNotFoundException + public Index getUserIndex( AttributeType attributeType ) throws IndexNotFoundException { - try - { - return getUserIndex( schemaManager.lookupAttributeTypeRegistry( id ) ); - } - catch ( LdapException e ) + if ( attributeType == null ) { - String msg = I18n.err( I18n.ERR_128, id ); - LOG.error( msg, e ); - throw new IndexNotFoundException( msg, id, e ); + throw new IndexNotFoundException( I18n.err( I18n.ERR_3, attributeType, attributeType ) ); } - } - - /** - * {@inheritDoc} - */ - public Index getUserIndex( AttributeType attributeType ) throws IndexNotFoundException - { - String id = attributeType.getOid(); - - if ( userIndices.containsKey( id ) ) + String oid = attributeType.getOid(); + + if ( userIndices.containsKey( oid ) ) { - return userIndices.get( id ); + return userIndices.get( oid ); } - throw new IndexNotFoundException( I18n.err( I18n.ERR_3, id, id ) ); + throw new IndexNotFoundException( I18n.err( I18n.ERR_3, attributeType, attributeType ) ); } /** * {@inheritDoc} */ - public Index getSystemIndex( String id ) throws IndexNotFoundException + public Index getSystemIndex( AttributeType attributeType ) throws IndexNotFoundException { - try - { - return getSystemIndex( schemaManager.lookupAttributeTypeRegistry( id ) ); - } - catch ( LdapException e ) + if ( attributeType == null ) { - String msg = I18n.err( I18n.ERR_128, id ); - LOG.error( msg, e ); - throw new IndexNotFoundException( msg, id, e ); + throw new IndexNotFoundException( I18n.err( I18n.ERR_2, attributeType, attributeType ) ); } - } - - /** - * {@inheritDoc} - */ - public Index getSystemIndex( AttributeType attributeType ) throws IndexNotFoundException - { - String id = attributeType.getOid(); - - if ( systemIndices.containsKey( id ) ) + String oid = attributeType.getOid(); + + if ( systemIndices.containsKey( oid ) ) { - return systemIndices.get( id ); + return systemIndices.get( oid ); } - throw new IndexNotFoundException( I18n.err( I18n.ERR_2, id, id ) ); + throw new IndexNotFoundException( I18n.err( I18n.ERR_2, attributeType, attributeType ) ); } @@ -951,11 +900,12 @@ public abstract class AbstractStore idx = ( Index ) getUserIndex( attributeOid ); + Index idx = ( Index ) getUserIndex( attributeType ); // here lookup by attributeId is OK since we got attributeId from // the entry via the enumeration - it's in there as is for sure @@ -1111,11 +1061,12 @@ public abstract class AbstractStore index = getUserIndex( attributeOid ); + Index index = getUserIndex( attributeType ); // here lookup by attributeId is ok since we got attributeId from // the entry via the enumeration - it's in there as is for sure @@ -1180,7 +1131,7 @@ public abstract class AbstractStore index = getUserIndex( newNormType ); + Index index = getUserIndex( newRdnAttrType ); ( ( Index ) index ).add( newNormValue, id ); // Make sure the altered entry shows the existence of the new attrib @@ -1236,7 +1187,7 @@ public abstract class AbstractStore index = getUserIndex( oldNormType ); + Index index = getUserIndex( oldRdnAttrType ); ( ( Index ) index ).drop( oldNormValue, id ); /* @@ -1485,6 +1436,7 @@ public abstract class AbstractStore index = getUserIndex( modsOid ); + Index index = getUserIndex( attributeType ); for ( Value value : mods ) { @@ -1546,9 +1498,10 @@ public abstract class AbstractStore index = getUserIndex( modsOid ); + Index index = getUserIndex( attributeType ); // if the id exists in the index drop all existing attribute // value index entries and add new ones @@ -1637,9 +1590,10 @@ public abstract class AbstractStore index = getUserIndex( modsOid ); + Index index = getUserIndex( attributeType ); /* * If there are no attribute values in the modifications then this @@ -2216,4 +2170,20 @@ public abstract class AbstractStore key = new ParentIdAndRdn( getRootId(), suffixDn.getRdns() ); + + suffixId = rdnIdx.forwardLookup( key ); + } + + return suffixId; + } } 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=1144255&r1=1144254&r2=1144255&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 Fri Jul 8 11:10:13 2011 @@ -152,6 +152,13 @@ public interface Storeor System's index list * @throws Exception If something went wrong */ - boolean hasIndexOn( String id ) throws Exception; - - - /** - * Tells if an index is already present in the User's or System's index list - * @param attributeType The index we are looking for - * @return true if the index is already present in the - * User's or System's index list - * @throws Exception If something went wrong - */ boolean hasIndexOn( AttributeType attributeType ) throws Exception; @@ -389,16 +386,7 @@ public interface Store getUserIndex( String id ) throws IndexNotFoundException; - - - /** - * Get the user index associated with the given attributeType - * @param attributeType The index attributeType we are looking for + * @param attributeType The index name we are looking for * @return The associated user index * @throws IndexNotFoundException If the index does not exist */ @@ -407,16 +395,7 @@ public interface Store getSystemIndex( String id ) throws IndexNotFoundException; - - - /** - * Get the system index associated with the given attributeType - * @param attributeType The index attributeType we are looking for + * @param attributeType The index name we are looking for * @return The associated system index * @throws IndexNotFoundException If the index does not exist */ Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java?rev=1144255&r1=1144254&r2=1144255&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/impl/avl/AvlStore.java Fri Jul 8 11:10:13 2011 @@ -142,8 +142,10 @@ public class AvlStore extends Abstrac } - @Override - protected Long getRootId() + /** + * {@inheritDoc} + */ + public Long getRootId() { return 0L; } Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java?rev=1144255&r1=1144254&r2=1144255&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/LessEqEvaluator.java Fri Jul 8 11:10:13 2011 @@ -26,8 +26,8 @@ import org.apache.directory.server.i18n. import org.apache.directory.server.xdbm.Index; import org.apache.directory.server.xdbm.IndexEntry; import org.apache.directory.server.xdbm.Store; -import org.apache.directory.shared.ldap.model.entry.Entry; 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.Value; import org.apache.directory.shared.ldap.model.filter.LessEqNode; import org.apache.directory.shared.ldap.model.schema.AttributeType; Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java?rev=1144255&r1=1144254&r2=1144255&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/xdbm/search/impl/SubstringEvaluator.java Fri Jul 8 11:10:13 2011 @@ -29,8 +29,8 @@ import org.apache.directory.server.xdbm. import org.apache.directory.server.xdbm.Store; import org.apache.directory.server.xdbm.search.Evaluator; import org.apache.directory.shared.ldap.model.cursor.Cursor; -import org.apache.directory.shared.ldap.model.entry.Entry; 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.Value; import org.apache.directory.shared.ldap.model.filter.SubstringNode; import org.apache.directory.shared.ldap.model.schema.AttributeType; 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=1144255&r1=1144254&r2=1144255&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 Fri Jul 8 11:10:13 2011 @@ -70,20 +70,17 @@ public class AbstractStoreTest { private static final Logger LOG = LoggerFactory.getLogger( AbstractStoreTest.class ); - private static File wkdir; private static Store store; private static SchemaManager schemaManager = null; - private static Dn EXAMPLE_COM; /** The OU AttributType instance */ private static AttributeType OU_AT; - - /** The CN AttributType instance */ - private static AttributeType CN_AT; - + /** The UID AttributType instance */ private static AttributeType UID_AT; - + + /** The CN AttributType instance */ + private static AttributeType CN_AT; @BeforeClass public static void setup() throws Exception @@ -110,12 +107,10 @@ public class AbstractStoreTest { fail( "Schema load failed : " + Exceptions.printErrors(schemaManager.getErrors()) ); } - - EXAMPLE_COM = new Dn( schemaManager, "dc=example,dc=com" ); OU_AT = schemaManager.getAttributeType( SchemaConstants.OU_AT ); - CN_AT = schemaManager.getAttributeType( SchemaConstants.CN_AT ); UID_AT = schemaManager.getAttributeType( SchemaConstants.UID_AT ); + CN_AT = schemaManager.getAttributeType( SchemaConstants.CN_AT ); } 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=1144255&r1=1144254&r2=1144255&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java Fri Jul 8 11:10:13 2011 @@ -89,13 +89,15 @@ public class AvlStoreTest /** The OU AttributeType instance */ private static AttributeType OU_AT; + /** The SN AttributeType instance */ + private static AttributeType SN_AT; + /** The DC AttributeType instance */ private static AttributeType DC_AT; /** The ApacheAlias AttributeType instance */ private static AttributeType APACHE_ALIAS_AT; - @BeforeClass public static void setup() throws Exception { @@ -125,6 +127,7 @@ 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 ); } @@ -143,6 +146,7 @@ public class AvlStoreTest store.addIndex( new AvlIndex( SchemaConstants.OU_AT_OID ) ); store.addIndex( new AvlIndex( SchemaConstants.UID_AT_OID ) ); + StoreUtils.loadExampleData( store, schemaManager ); LOG.debug( "Created new store" ); } @@ -336,7 +340,7 @@ public class AvlStoreTest try { - store.getSystemIndex( "bogus" ); + store.getSystemIndex( SN_AT ); fail(); } catch ( IndexNotFoundException e ) @@ -354,9 +358,9 @@ public class AvlStoreTest assertNotNull( store.getSuffixDn() ); assertEquals( 2, store.getUserIndices().size() ); - assertFalse( store.hasUserIndexOn( DC_AT ) ); - assertTrue( store.hasUserIndexOn( OU_AT ) ); - assertTrue( store.hasSystemIndexOn( APACHE_ALIAS_AT ) ); + assertFalse( store.hasUserIndexOn( "dc" ) ); + assertTrue( store.hasUserIndexOn( "ou" ) ); + assertTrue( store.hasSystemIndexOn( "apacheAlias" ) ); Iterator userIndices = store.userIndices(); assertTrue( userIndices.hasNext() ); assertNotNull( userIndices.next() ); @@ -367,7 +371,7 @@ public class AvlStoreTest try { - store.getUserIndex( "bogus" ); + store.getUserIndex( SN_AT ); fail(); } catch ( IndexNotFoundException e ) @@ -376,7 +380,7 @@ public class AvlStoreTest try { - store.getUserIndex( "dc" ); + store.getUserIndex( DC_AT ); fail(); } catch ( IndexNotFoundException e )