Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 34328 invoked from network); 7 Nov 2009 07:58:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Nov 2009 07:58:48 -0000 Received: (qmail 44104 invoked by uid 500); 7 Nov 2009 07:58:48 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 44043 invoked by uid 500); 7 Nov 2009 07:58:47 -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 44034 invoked by uid 99); 7 Nov 2009 07:58:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 07 Nov 2009 07:58:47 +0000 X-ASF-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL,BAYES_00,SUBJECT_FUZZY_TION 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; Sat, 07 Nov 2009 07:58:39 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7CD6023889FF; Sat, 7 Nov 2009 07:57:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r833647 [10/17] - in /directory: apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/pa... Date: Sat, 07 Nov 2009 07:57:42 -0000 To: commits@directory.apache.org From: elecharny@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091107075754.7CD6023889FF@eris.apache.org> Modified: directory/apacheds/branches/apacheds-schema/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java (original) +++ directory/apacheds/branches/apacheds-schema/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java Sat Nov 7 07:57:34 2009 @@ -30,21 +30,11 @@ import java.util.Map; import java.util.Set; -import org.apache.directory.server.core.interceptor.BaseInterceptor; -import org.apache.directory.server.core.interceptor.Interceptor; -import org.apache.directory.server.core.interceptor.NextInterceptor; -import org.apache.directory.server.core.interceptor.context.AddOperationContext; -import org.apache.directory.server.core.interceptor.context.LookupOperationContext; -import org.apache.directory.server.core.interceptor.context.ModifyOperationContext; -import org.apache.directory.server.core.normalization.NormalizationInterceptor; +import javax.naming.NamingException; + import org.apache.directory.server.core.authn.AuthenticationInterceptor; import org.apache.directory.server.core.authz.AciAuthorizationInterceptor; import org.apache.directory.server.core.authz.DefaultAuthorizationInterceptor; -import org.apache.directory.server.core.exception.ExceptionInterceptor; -import org.apache.directory.server.core.operational.OperationalAttributeInterceptor; -import org.apache.directory.server.core.referral.ReferralInterceptor; -import org.apache.directory.server.core.schema.SchemaInterceptor; -import org.apache.directory.server.core.subtree.SubentryInterceptor; import org.apache.directory.server.core.collective.CollectiveAttributeInterceptor; import org.apache.directory.server.core.entry.ClonedServerEntry; import org.apache.directory.server.core.entry.DefaultServerAttribute; @@ -54,6 +44,18 @@ import org.apache.directory.server.core.entry.ServerModification; import org.apache.directory.server.core.entry.ServerStringValue; import org.apache.directory.server.core.event.EventInterceptor; +import org.apache.directory.server.core.exception.ExceptionInterceptor; +import org.apache.directory.server.core.interceptor.BaseInterceptor; +import org.apache.directory.server.core.interceptor.Interceptor; +import org.apache.directory.server.core.interceptor.NextInterceptor; +import org.apache.directory.server.core.interceptor.context.AddOperationContext; +import org.apache.directory.server.core.interceptor.context.LookupOperationContext; +import org.apache.directory.server.core.interceptor.context.ModifyOperationContext; +import org.apache.directory.server.core.normalization.NormalizationInterceptor; +import org.apache.directory.server.core.operational.OperationalAttributeInterceptor; +import org.apache.directory.server.core.referral.ReferralInterceptor; +import org.apache.directory.server.core.schema.SchemaInterceptor; +import org.apache.directory.server.core.subtree.SubentryInterceptor; import org.apache.directory.server.core.trigger.TriggerInterceptor; import org.apache.directory.server.kerberos.shared.crypto.encryption.EncryptionType; import org.apache.directory.server.kerberos.shared.crypto.encryption.KerberosKeyFactory; @@ -69,8 +71,7 @@ import org.apache.directory.shared.ldap.entry.Value; import org.apache.directory.shared.ldap.exception.LdapAuthenticationException; import org.apache.directory.shared.ldap.name.LdapDN; -import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry; -import org.apache.directory.shared.ldap.schema.registries.Registries; +import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.util.StringTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -158,7 +159,7 @@ entry.put( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT, principalName ); entry.put( KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT, "0" ); - entry.put( getKeyAttribute( addContext.getSession().getDirectoryService().getRegistries(), keys ) ); + entry.put( getKeyAttribute( addContext.getSession().getDirectoryService().getSchemaManager(), keys ) ); log.debug( "Adding modified entry '{}' for DN '{}'.", entry, normName .getUpName() ); @@ -367,8 +368,8 @@ newModsList.add( mod ); } - AttributeTypeRegistry atRegistry = modContext.getSession() - .getDirectoryService().getRegistries().getAttributeTypeRegistry(); + SchemaManager schemaManager = modContext.getSession() + .getDirectoryService().getSchemaManager(); // Add our modification items. newModsList.add( @@ -376,29 +377,29 @@ ModificationOperation.REPLACE_ATTRIBUTE, new DefaultServerAttribute( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT, - atRegistry.lookup( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ), + schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ), principalName ) ) ); newModsList.add( new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, new DefaultServerAttribute( KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT, - atRegistry.lookup( KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT ), + schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT ), Integer.toString( kvno ) ) ) ); ServerAttribute attribute = getKeyAttribute( modContext.getSession() - .getDirectoryService().getRegistries(), keys ); + .getDirectoryService().getSchemaManager(), keys ); newModsList.add( new ServerModification( ModificationOperation.REPLACE_ATTRIBUTE, attribute ) ); modContext.setModItems( newModsList ); } - private ServerAttribute getKeyAttribute( Registries registries, Map keys ) throws Exception + private ServerAttribute getKeyAttribute( SchemaManager schemaManager, Map keys ) throws Exception { ServerAttribute keyAttribute = new DefaultServerAttribute( KerberosAttribute.KRB5_KEY_AT, - registries.getAttributeTypeRegistry().lookup( KerberosAttribute.KRB5_KEY_AT ) ); + schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_KEY_AT ) ); Iterator it = keys.values().iterator(); Modified: directory/apacheds/branches/apacheds-schema/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Sat Nov 7 07:57:34 2009 @@ -121,7 +121,7 @@ { store.setWorkingDirectory( getPartitionDir() ); - EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder( store, registries ); + EvaluatorBuilder evaluatorBuilder = new EvaluatorBuilder( store, schemaManager ); CursorBuilder cursorBuilder = new CursorBuilder( store, evaluatorBuilder ); // setup optimizer and registries for parent @@ -141,7 +141,7 @@ store.setName( id ); // Normalize the suffix - suffix.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() ); + suffix.normalize( schemaManager.getNormalizerMapping() ); store.setSuffixDn( suffix.getNormName() ); store.setWorkingDirectory( getPartitionDir() ); @@ -163,7 +163,7 @@ index.setWkDirPath( obj.getWkDirPath() ); } - String oid = registries.getAttributeTypeRegistry().getOidByName( index.getAttributeId() ); + String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() ); if ( SYS_INDEX_OIDS.contains( oid ) ) { @@ -220,7 +220,7 @@ store.setUserIndices( userIndices ); } - store.init( registries ); + store.init( schemaManager ); } Modified: directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java Sat Nov 7 07:57:34 2009 @@ -35,9 +35,7 @@ import org.apache.directory.server.core.DirectoryService; import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmPartition; import org.apache.directory.shared.ldap.schema.SchemaManager; -import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor; -import org.apache.directory.shared.ldap.schema.registries.Registries; import org.apache.directory.shared.ldap.schema.registries.Schema; import org.apache.directory.shared.ldap.util.ExceptionUtils; import org.apache.directory.shared.schema.DefaultSchemaManager; @@ -58,7 +56,7 @@ @Ignore ( "Ignore this test until we get the LDIF partition in place." ) public class PartitionSchemaLoaderTest { - private static Registries registries; + private static SchemaManager schemaManager; private static DirectoryService directoryService; private static JdbmPartition schemaPartition; @@ -91,18 +89,15 @@ SchemaLdifExtractor extractor = new SchemaLdifExtractor( workingDirectory ); extractor.extractOrCopy(); LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository ); - SchemaManager sm = new DefaultSchemaManager( loader ); + schemaManager = new DefaultSchemaManager( loader ); - boolean loaded = sm.loadAllEnabled(); + boolean loaded = schemaManager.loadAllEnabled(); if ( !loaded ) { - fail( "Schema load failed : " + ExceptionUtils.printErrors( sm.getErrors() ) ); + fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) ); } - registries = sm.getRegistries(); - SerializableComparator.setRegistry( registries.getComparatorRegistry() ); - // -------------------------------------------------------------------- // TODO add code here to start up the LDIF schema partition // -------------------------------------------------------------------- @@ -113,7 +108,7 @@ @Test public void testGetSchemas() throws Exception { - PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, registries ); + PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, schemaManager ); Map schemas = loader.getSchemas(); Schema schema = schemas.get( "mozilla" ); @@ -232,7 +227,7 @@ @Test public void testGetSchemaNames() throws Exception { - PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, registries ); + PartitionSchemaLoader loader = new PartitionSchemaLoader( schemaPartition, schemaManager ); Set schemaNames = loader.getSchemaNames(); assertTrue( schemaNames.contains( "mozilla" ) ); assertTrue( schemaNames.contains( "core" ) ); Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Sat Nov 7 07:57:34 2009 @@ -20,6 +20,11 @@ package org.apache.directory.server.core.partition.impl.btree.jdbm; +import java.io.File; +import java.io.IOException; + +import javax.naming.NamingException; + import jdbm.RecordManager; import jdbm.helper.MRU; import jdbm.recman.BaseRecordManager; @@ -28,22 +33,18 @@ import org.apache.directory.server.core.partition.impl.btree.IndexCursorAdaptor; import org.apache.directory.server.core.partition.impl.btree.LongComparator; import org.apache.directory.server.xdbm.Index; -import org.apache.directory.server.xdbm.Tuple; import org.apache.directory.server.xdbm.IndexCursor; +import org.apache.directory.server.xdbm.Tuple; import org.apache.directory.shared.ldap.cursor.Cursor; import org.apache.directory.shared.ldap.entry.client.ClientBinaryValue; import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.MatchingRule; +import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; import org.apache.directory.shared.ldap.util.SynchronizedLRUMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.File; -import java.io.IOException; - -import javax.naming.NamingException; - /** * A Jdbm based index implementation. @@ -154,7 +155,7 @@ } - public void init( AttributeType attributeType, File wkDirPath ) throws IOException + public void init( SchemaManager schemaManager, AttributeType attributeType, File wkDirPath ) throws IOException { LOG.debug( "Initializing an Index for attribute '{}'", attributeType.getName() ); @@ -179,7 +180,7 @@ try { - initTables(); + initTables( schemaManager ); } catch ( IOException e ) { @@ -199,7 +200,7 @@ * tables * @throws NamingException */ - private void initTables() throws IOException + private void initTables( SchemaManager schemaManager ) throws IOException { SerializableComparator comp; @@ -217,7 +218,11 @@ * primary keys. A value for an attribute can occur several times in * different entries so the forward map can have more than one value. */ + LongComparator.INSTANCE.setSchemaManager( schemaManager ); + comp.setSchemaManager( schemaManager ); + forward = new JdbmTable( + schemaManager, attribute.getName() + FORWARD_BTREE, numDupLimit, recMan, @@ -233,6 +238,7 @@ if ( attribute.isSingleValued() ) { reverse = new JdbmTable( + schemaManager, attribute.getName() + REVERSE_BTREE, recMan, LongComparator.INSTANCE, @@ -242,6 +248,7 @@ else { reverse = new JdbmTable( + schemaManager, attribute.getName() + REVERSE_BTREE, numDupLimit, recMan, Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Sat Nov 7 07:57:34 2009 @@ -25,10 +25,10 @@ import jdbm.helper.Serializer; import jdbm.helper.StringComparator; -import org.apache.directory.server.xdbm.MasterTable; import org.apache.directory.server.core.entry.ServerEntrySerializer; +import org.apache.directory.server.xdbm.MasterTable; +import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; -import org.apache.directory.shared.ldap.schema.registries.Registries; /** @@ -112,26 +112,29 @@ * Creates the master table using JDBM B+Trees for the backing store. * * @param recMan the JDBM record manager - * @param registries the schema registries + * @param schemaManager the schema mamanger * @throws Exception if there is an error opening the Db file. */ - public JdbmMasterTable( RecordManager recMan, Registries registries ) throws Exception + public JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager ) throws Exception { - super( DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, new ServerEntrySerializer( registries ) ); - adminTbl = new JdbmTable( "admin", recMan, STRING_COMPARATOR, null, null ); + super( schemaManager, DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, new ServerEntrySerializer( schemaManager ) ); + adminTbl = new JdbmTable( schemaManager, "admin", recMan, STRING_COMPARATOR, null, null ); String seqValue = adminTbl.get( SEQPROP_KEY ); if ( null == seqValue ) { adminTbl.put( SEQPROP_KEY, "0" ); } + + LONG_COMPARATOR.setSchemaManager( schemaManager ); + STRING_COMPARATOR.setSchemaManager( schemaManager ); } - protected JdbmMasterTable( RecordManager recMan, String dbName, Serializer serializer ) throws Exception + protected JdbmMasterTable( RecordManager recMan, SchemaManager schemaManager, String dbName, Serializer serializer ) throws Exception { - super( DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, serializer ); - adminTbl = new JdbmTable( dbName, recMan, STRING_COMPARATOR, null, null ); + super( schemaManager, DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, serializer ); + adminTbl = new JdbmTable( schemaManager, dbName, recMan, STRING_COMPARATOR, null, null ); String seqValue = adminTbl.get( SEQPROP_KEY ); if ( null == seqValue ) Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Sat Nov 7 07:57:34 2009 @@ -63,8 +63,7 @@ import org.apache.directory.shared.ldap.name.Rdn; import org.apache.directory.shared.ldap.schema.AttributeType; import org.apache.directory.shared.ldap.schema.MatchingRule; -import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry; -import org.apache.directory.shared.ldap.schema.registries.Registries; +import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.util.NamespaceTools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -144,8 +143,8 @@ private static AttributeType ENTRY_UUID_AT; private static AttributeType ALIASED_OBJECT_NAME_AT; - /** A pointer on the AT registry */ - private AttributeTypeRegistry atRegistry; + /** A pointer on the schemaManager */ + private SchemaManager schemaManager; private String suffixDn; private int cacheSize = DEFAULT_CACHE_SIZE; @@ -247,21 +246,21 @@ /** * Initialize the JDBM storage system. * - * @param registries the schema registries - * @throws Exception on failure to lookup elements in registries or create database files + * @param schemaManager the schema manager + * @throws Exception on failure to lookup elements in schemaManager or create database files */ - public synchronized void init( Registries registries ) throws Exception + public synchronized void init( SchemaManager schemaManager ) throws Exception { - this.atRegistry = registries.getAttributeTypeRegistry(); + this.schemaManager = schemaManager; // Initialize Attribute types used all over this method - OBJECT_CLASS_AT = atRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT ); - ALIASED_OBJECT_NAME_AT = atRegistry.lookup( SchemaConstants.ALIASED_OBJECT_NAME_AT ); - ENTRY_CSN_AT = atRegistry.lookup( SchemaConstants.ENTRY_CSN_AT ); - ENTRY_UUID_AT = atRegistry.lookup( SchemaConstants.ENTRY_UUID_AT ); + OBJECT_CLASS_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT ); + ALIASED_OBJECT_NAME_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ALIASED_OBJECT_NAME_AT ); + ENTRY_CSN_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT ); + ENTRY_UUID_AT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_UUID_AT ); this.upSuffix = new LdapDN( suffixDn ); - this.normSuffix = LdapDN.normalize( upSuffix, atRegistry.getNormalizerMapping() ); + this.normSuffix = LdapDN.normalize( upSuffix, schemaManager.getNormalizerMapping() ); workingDirectory.mkdirs(); // First, check if the file storing the data exists @@ -283,7 +282,7 @@ recMan = new CacheRecordManager( base, new MRU( cacheSize ) ); // Create the master table (the table containing all the entries) - master = new JdbmMasterTable( recMan, registries ); + master = new JdbmMasterTable( recMan, schemaManager ); // ------------------------------------------------------------------- // Initializes the user and system indices @@ -306,9 +305,9 @@ for ( Index index : systemIndices.values() ) { - String oid = atRegistry.getOidByName( index.getAttributeId() ); + String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() ); tmp.put( oid, index ); - ( ( JdbmIndex ) index ).init( atRegistry.lookup( oid ), workingDirectory ); + ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ), workingDirectory ); } systemIndices = tmp; } @@ -318,7 +317,7 @@ ndnIdx = new JdbmIndex(); ndnIdx.setAttributeId( ApacheSchemaConstants.APACHE_N_DN_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_N_DN_AT_OID, ndnIdx ); - ndnIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_N_DN_AT_OID ), workingDirectory ); + ndnIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_N_DN_AT_OID ), workingDirectory ); } if ( updnIdx == null ) @@ -326,7 +325,7 @@ updnIdx = new JdbmIndex(); updnIdx.setAttributeId( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_UP_DN_AT_OID, updnIdx ); - updnIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ), workingDirectory ); + updnIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ), workingDirectory ); } if ( presenceIdx == null ) @@ -334,7 +333,7 @@ presenceIdx = new JdbmIndex(); presenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID, presenceIdx ); - presenceIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), workingDirectory ); + presenceIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), workingDirectory ); } if ( oneLevelIdx == null ) @@ -342,7 +341,7 @@ oneLevelIdx = new JdbmIndex(); oneLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID, oneLevelIdx ); - oneLevelIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ), workingDirectory ); + oneLevelIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ), workingDirectory ); } if ( oneAliasIdx == null ) @@ -350,7 +349,7 @@ oneAliasIdx = new JdbmIndex(); oneAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, oneAliasIdx ); - oneAliasIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ), workingDirectory ); + oneAliasIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ), workingDirectory ); } if ( subAliasIdx == null ) @@ -358,7 +357,7 @@ subAliasIdx = new JdbmIndex(); subAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID, subAliasIdx ); - subAliasIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ), workingDirectory ); + subAliasIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ), workingDirectory ); } if ( aliasIdx == null ) @@ -366,7 +365,7 @@ aliasIdx = new JdbmIndex(); aliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_ALIAS_AT_OID, aliasIdx ); - aliasIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ), workingDirectory ); + aliasIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ), workingDirectory ); } if ( subLevelIdx == null ) @@ -374,7 +373,7 @@ subLevelIdx = new JdbmIndex(); subLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ); systemIndices.put( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID, subLevelIdx ); - subLevelIdx.init( atRegistry.lookup( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ), workingDirectory ); + subLevelIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ), workingDirectory ); } if ( entryCsnIdx == null ) @@ -382,7 +381,7 @@ entryCsnIdx = new JdbmIndex(); entryCsnIdx.setAttributeId( SchemaConstants.ENTRY_CSN_AT_OID ); systemIndices.put( SchemaConstants.ENTRY_CSN_AT_OID, entryCsnIdx ); - entryCsnIdx.init( atRegistry.lookup( SchemaConstants.ENTRY_CSN_AT_OID ), workingDirectory ); + entryCsnIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT_OID ), workingDirectory ); } if ( entryUuidIdx == null ) @@ -390,7 +389,7 @@ entryUuidIdx = new JdbmIndex(); entryUuidIdx.setAttributeId( SchemaConstants.ENTRY_UUID_AT_OID ); systemIndices.put( SchemaConstants.ENTRY_UUID_AT_OID, entryUuidIdx ); - entryUuidIdx.init( atRegistry.lookup( SchemaConstants.ENTRY_UUID_AT_OID ), workingDirectory ); + entryUuidIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_UUID_AT_OID ), workingDirectory ); } if ( objectClassIdx == null ) @@ -398,7 +397,7 @@ objectClassIdx = new JdbmIndex(); objectClassIdx.setAttributeId( SchemaConstants.OBJECT_CLASS_AT_OID ); systemIndices.put( SchemaConstants.OBJECT_CLASS_AT_OID, objectClassIdx ); - objectClassIdx.init( atRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT_OID ), workingDirectory ); + objectClassIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT_OID ), workingDirectory ); } } @@ -412,7 +411,7 @@ for ( Index index : userIndices.values() ) { - String oid = atRegistry.getOidByName( index.getAttributeId() ); + String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() ); if ( systemIndices.containsKey( oid ) ) { @@ -420,14 +419,14 @@ // present in the SystemIndices continue; } - AttributeType attributeType = atRegistry.lookup( oid ); + AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid ); // Check that the attributeType has an EQUALITY matchingRule MatchingRule mr = attributeType.getEquality(); if ( mr != null ) { - ( ( JdbmIndex ) index ).init( atRegistry.lookup( oid ), workingDirectory ); + ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ), workingDirectory ); tmp.put( oid, index ); } else @@ -840,13 +839,13 @@ public boolean hasUserIndexOn( String id ) throws NamingException { - return userIndices.containsKey( atRegistry.getOidByName( id ) ); + return userIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) ); } public boolean hasSystemIndexOn( String id ) throws NamingException { - return systemIndices.containsKey( atRegistry.getOidByName( id ) ); + return systemIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) ); } @@ -854,7 +853,7 @@ { try { - id = atRegistry.getOidByName( id ); + id = schemaManager.getAttributeTypeRegistry().getOidByName( id ); } catch ( NamingException e ) { @@ -876,7 +875,7 @@ { try { - id = atRegistry.getOidByName( id ); + id = schemaManager.getAttributeTypeRegistry().getOidByName( id ); } catch ( NamingException e ) { @@ -1016,7 +1015,7 @@ // Access aliasedObjectName, normalize it and generate the Name normalizedAliasTargetDn = new LdapDN( aliasTarget ); - normalizedAliasTargetDn.normalize( atRegistry.getNormalizerMapping() ); + normalizedAliasTargetDn.normalize( schemaManager.getNormalizerMapping() ); /* * Check For Cycles @@ -1428,7 +1427,7 @@ throw new Exception( "Cannot store a ClonedServerEntry" ); } - String modsOid = atRegistry.getOidByName( mods.getId() ); + String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() ); // Special case for the ObjectClass index if ( modsOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) ) @@ -1455,7 +1454,7 @@ } // add all the values in mods to the same attribute in the entry - AttributeType type = atRegistry.lookup( modsOid ); + AttributeType type = schemaManager.lookupAttributeTypeRegistry( modsOid ); for ( Value value : mods ) { @@ -1491,7 +1490,7 @@ throw new Exception( "Cannot store a ClonedServerEntry" ); } - String modsOid = atRegistry.getOidByName( mods.getId() ); + String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() ); // Special case for the ObjectClass index if ( modsOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) ) @@ -1520,7 +1519,7 @@ } } - AttributeType attrType = atRegistry.lookup( modsOid ); + AttributeType attrType = schemaManager.lookupAttributeTypeRegistry( modsOid ); /* * If there are no attribute values in the modifications then this * implies the compelete removal of the attribute from the entry. Else @@ -1585,7 +1584,7 @@ throw new Exception( "Cannot store a ClonedServerEntry" ); } - String modsOid = atRegistry.getOidByName( mods.getId() ); + String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() ); // Special case for the ObjectClass index if ( modsOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) ) @@ -1628,7 +1627,7 @@ } } - String aliasAttributeOid = atRegistry.getOidByName( SchemaConstants.ALIASED_OBJECT_NAME_AT ); + String aliasAttributeOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.ALIASED_OBJECT_NAME_AT ); if ( modsOid.equals( aliasAttributeOid ) ) { @@ -1770,7 +1769,7 @@ { String newNormType = newAtav.getNormType(); String newNormValue = newAtav.getNormValue().getString(); - AttributeType newRdnAttrType = atRegistry.lookup( newNormType ); + AttributeType newRdnAttrType = schemaManager.lookupAttributeTypeRegistry( newNormType ); Object unEscapedRdn = Rdn.unescapeValue( newAtav.getUpValue().getString() ); @@ -1840,7 +1839,7 @@ { String oldNormType = oldAtav.getNormType(); String oldNormValue = oldAtav.getNormValue().getString(); - AttributeType oldRdnAttrType = atRegistry.lookup( oldNormType ); + AttributeType oldRdnAttrType = schemaManager.lookupAttributeTypeRegistry( oldNormType ); entry.remove( oldRdnAttrType, oldNormValue ); if ( hasUserIndexOn( oldNormType ) ) @@ -1877,7 +1876,7 @@ newUpdn.add( newRdn.getUpName() ); // add da new upRdn // gotta normalize cuz this thang is cloned and not normalized by default - newUpdn.normalize( atRegistry.getNormalizerMapping() ); + newUpdn.normalize( schemaManager.getNormalizerMapping() ); modifyDn( id, newUpdn, false ); // propagate dn changes @@ -1918,7 +1917,7 @@ if ( !updn.isNormalized() ) { - updn.normalize( atRegistry.getNormalizerMapping() ); + updn.normalize( schemaManager.getNormalizerMapping() ); } ndnIdx.add( updn.toNormName(), id ); @@ -1964,7 +1963,7 @@ String rdn = oldUpdn.get( oldUpdn.size() - 1 ); LdapDN rdnDN = new LdapDN( rdn ); - rdnDN.normalize( atRegistry.getNormalizerMapping() ); + rdnDN.normalize( schemaManager.getNormalizerMapping() ); childUpdn.add( rdnDN.getRdn() ); // Modify the child @@ -2223,8 +2222,17 @@ } - public void initRegistries( Registries registries ) + public void initSchemaManager( SchemaManager schemaManager ) { - this.atRegistry = registries.getAttributeTypeRegistry(); + this.schemaManager = schemaManager; + } + + + /** + * @param schemaManager the schemaManager to set + */ + public void setSchemaManager( SchemaManager schemaManager ) + { + this.schemaManager = schemaManager; } } Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Sat Nov 7 07:57:34 2009 @@ -20,6 +20,10 @@ package org.apache.directory.server.core.partition.impl.btree.jdbm; +import java.io.IOException; +import java.util.Comparator; +import java.util.Map; + import jdbm.RecordManager; import jdbm.btree.BTree; import jdbm.helper.Serializer; @@ -33,16 +37,13 @@ import org.apache.directory.shared.ldap.cursor.Cursor; import org.apache.directory.shared.ldap.cursor.EmptyCursor; import org.apache.directory.shared.ldap.cursor.SingletonCursor; +import org.apache.directory.shared.ldap.schema.SchemaManager; import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; import org.apache.directory.shared.ldap.util.StringTools; import org.apache.directory.shared.ldap.util.SynchronizedLRUMap; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.util.Comparator; -import java.util.Map; - /** * A jdbm Btree wrapper that enables duplicate sorted keys using collections. @@ -91,6 +92,8 @@ Marshaller> marshaller; + /** The global SchemaManager */ + private SchemaManager schemaManager; // ------------------------------------------------------------------------ // C O N S T R U C T O R @@ -114,11 +117,13 @@ * @throws IOException if the table's file cannot be created */ @SuppressWarnings("unchecked") - public JdbmTable( String name, int numDupLimit, RecordManager manager, + public JdbmTable( SchemaManager schemaManager, String name, int numDupLimit, RecordManager manager, Comparator keyComparator, Comparator valueComparator, Serializer keySerializer, Serializer valueSerializer ) throws IOException { + this.schemaManager = schemaManager; + // TODO make the size of the duplicate btree cache configurable via constructor duplicateBtrees = new SynchronizedLRUMap( 100 ); @@ -177,6 +182,7 @@ else // Load existing BTree { bt = BTree.load( recMan, recId ); + ((SerializableComparator)bt.getComparator()).setSchemaManager( schemaManager ); recId = recMan.getNamedObject( name + SZSUFFIX ); count = ( Integer ) recMan.fetch( recId ); } @@ -197,16 +203,25 @@ * using default Java serialization which could be very expensive * @throws IOException if the table's file cannot be created */ - public JdbmTable( String name, RecordManager manager, SerializableComparator keyComparator, + public JdbmTable( SchemaManager schemaManager, String name, RecordManager manager, Comparator keyComparator, Serializer keySerializer, Serializer valueSerializer ) throws IOException { + this.schemaManager = schemaManager; this.duplicateBtrees = null; this.numDupLimit = Integer.MAX_VALUE; this.name = name; this.recMan = manager; - this.keyComparator = keyComparator; + if ( keyComparator == null ) + { + throw new NullPointerException( "Key comparator cannot be null." ); + } + else + { + this.keyComparator = keyComparator; + } + this.valueComparator = null; this.keySerializer = keySerializer; @@ -219,6 +234,7 @@ if ( recId != 0 ) { bt = BTree.load( recMan, recId ); + ((SerializableComparator)bt.getComparator()).setSchemaManager( schemaManager ); bt.setValueSerializer( valueSerializer ); recId = recMan.getNamedObject( name + SZSUFFIX ); count = ( Integer ) recMan.fetch( recId ); @@ -394,6 +410,7 @@ // Handle values if they are stored in another BTree BTree tree = getBTree( values.getBTreeRedirect() ); + jdbm.helper.Tuple tuple = new jdbm.helper.Tuple(); tree.browse().getNext( tuple ); //noinspection unchecked @@ -1008,6 +1025,7 @@ } BTree tree = BTree.load( recMan, redirect.getRecId() ); + ((SerializableComparator)tree.getComparator()).setSchemaManager( schemaManager ); duplicateBtrees.put( redirect.getRecId(), tree ); return tree; } Modified: directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursorTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursorTest.java?rev=833647&r1=833646&r2=833647&view=diff ============================================================================== --- directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursorTest.java (original) +++ directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/DupsContainerCursorTest.java Sat Nov 7 07:57:34 2009 @@ -19,28 +19,35 @@ package org.apache.directory.server.core.partition.impl.btree.jdbm; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.directory.server.xdbm.Tuple; -import org.apache.directory.shared.ldap.cursor.Cursor; -import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException; -import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; -import org.apache.directory.shared.ldap.schema.registries.OidRegistry; -import org.junit.Before; -import org.junit.After; -import org.junit.Test; - +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.io.File; import jdbm.RecordManager; -import jdbm.helper.IntegerSerializer; +import jdbm.helper.DefaultSerializer; import jdbm.recman.BaseRecordManager; +import org.apache.directory.server.xdbm.Tuple; +import org.apache.directory.shared.ldap.constants.SchemaConstants; +import org.apache.directory.shared.ldap.cursor.Cursor; +import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException; +import org.apache.directory.shared.ldap.schema.SchemaManager; +import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator; +import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor; +import org.apache.directory.shared.ldap.util.ExceptionUtils; +import org.apache.directory.shared.schema.DefaultSchemaManager; +import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * Tests the DupsContainerCursor. @@ -53,12 +60,40 @@ private static final Logger LOG = LoggerFactory.getLogger( NoDupsCursorTest.class.getSimpleName() ); private static final String TEST_OUTPUT_PATH = "test.output.path"; - transient JdbmTable table; + transient JdbmTable table; transient File dbFile; + private static SchemaManager schemaManager; transient RecordManager recman; private static final int SIZE = 15; + @BeforeClass + public static void init() throws Exception + { + String workingDirectory = System.getProperty( "workingDirectory" ); + + if ( workingDirectory == null ) + { + String path = DupsContainerCursorTest.class.getResource( "" ).getPath(); + int targetPos = path.indexOf( "target" ); + workingDirectory = path.substring( 0, targetPos + 6 ); + } + + File schemaRepository = new File( workingDirectory, "schema" ); + SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) ); + extractor.extractOrCopy(); + LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository ); + schemaManager = new DefaultSchemaManager( loader ); + + boolean loaded = schemaManager.loadAllEnabled(); + + if ( !loaded ) + { + fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) ); + } + } + + @Before public void createTable() throws Exception { @@ -73,18 +108,12 @@ dbFile = File.createTempFile( getClass().getSimpleName(), "db", tmpDir ); dbFile.deleteOnExit(); recman = new BaseRecordManager( dbFile.getAbsolutePath() ); - - // gosh this is a terrible use of a global static variable - SerializableComparator.setRegistry( - new MockComparatorRegistry( - new OidRegistry() ) ); - - table = new JdbmTable( "test", SIZE, recman, - new SerializableComparator( "" ), - new SerializableComparator( "" ), - null, new IntegerSerializer() ); + + SerializableComparator comparator = new SerializableComparator( SchemaConstants.INTEGER_ORDERING_MATCH_MR_OID ); + comparator.setSchemaManager( schemaManager ); + table = new JdbmTable( schemaManager, "test", SIZE, recman, + comparator, comparator, null, new DefaultSerializer() ); LOG.debug( "Created new table and populated it with data" ); - } @@ -109,13 +138,15 @@ recman = new BaseRecordManager( dbFile.getAbsolutePath() ); // gosh this is a terrible use of a global static variable - SerializableComparator.setRegistry( - new MockComparatorRegistry( - new OidRegistry() ) ); - table = new JdbmTable( "test", recman, new SerializableComparator( "" ), null, null ); + //SerializableComparator.setRegistry( + // new MockComparatorRegistry( + // new OidRegistry() ) ); + SerializableComparator comparator = new SerializableComparator( SchemaConstants.INTEGER_ORDERING_MATCH_MR_OID ); + comparator.setSchemaManager( schemaManager ); + table = new JdbmTable( schemaManager, "test", recman, comparator, null, null ); - Cursor>> cursor = - new DupsContainerCursor( table ); + Cursor>> cursor = + new DupsContainerCursor( table ); assertNotNull( cursor ); } @@ -123,21 +154,21 @@ @Test( expected=InvalidCursorPositionException.class ) public void testEmptyTable() throws Exception { - Cursor>> cursor = - new DupsContainerCursor( table ); + Cursor>> cursor = + new DupsContainerCursor( table ); assertNotNull( cursor ); assertFalse( cursor.available() ); assertFalse( cursor.isClosed() ); assertTrue( cursor.isElementReused() ); - cursor = new DupsContainerCursor( table ); + cursor = new DupsContainerCursor( table ); assertFalse( cursor.previous() ); - cursor = new DupsContainerCursor( table ); + cursor = new DupsContainerCursor( table ); assertFalse( cursor.next() ); - cursor.after( new Tuple>( 7, null ) ); + cursor.after( new Tuple>( "7", null ) ); cursor.get(); } @@ -145,14 +176,14 @@ @Test public void testOnTableWithSingleEntry() throws Exception { - table.put( 1, 1 ); - Cursor>> cursor = - new DupsContainerCursor( table ); + table.put( "1", "1" ); + Cursor>> cursor = + new DupsContainerCursor( table ); assertTrue( cursor.first() ); - Tuple> tuple = cursor.get(); - assertTrue( tuple.getKey().equals( 1 ) ); - assertEquals( 1, ( int ) tuple.getValue().getArrayTree().getFirst() ); + Tuple> tuple = cursor.get(); + assertEquals( "1", tuple.getKey() ); + assertEquals( "1", tuple.getValue().getArrayTree().getFirst() ); cursor.beforeFirst(); assertFalse( cursor.previous() ); @@ -165,24 +196,25 @@ { for( int i=1; i < 10; i++ ) { - table.put( i, i ); + String istr = Integer.toString( i ); + table.put( istr, istr ); } - Cursor>> cursor = - new DupsContainerCursor( table ); + Cursor>> cursor = + new DupsContainerCursor( table ); - cursor.after( new Tuple>( 2, null ) ); + cursor.after( new Tuple>( "2", null ) ); assertTrue( cursor.next() ); - Tuple> tuple = cursor.get(); - assertTrue( tuple.getKey().equals( 3 ) ); - assertEquals( 3, ( int ) tuple.getValue().getArrayTree().getFirst() ); + Tuple> tuple = cursor.get(); + assertEquals( "3", tuple.getKey() ); + assertEquals( "3", tuple.getValue().getArrayTree().getFirst() ); - cursor.before( new Tuple>( 7, null ) ); + cursor.before( new Tuple>( "7", null ) ); cursor.next(); tuple = cursor.get(); - assertTrue( tuple.getKey().equals( 7 ) ); - assertEquals( 7, ( int ) tuple.getValue().getArrayTree().getFirst() ); + assertEquals( "7", tuple.getKey() ); + assertEquals( "7", tuple.getValue().getArrayTree().getFirst() ); cursor.last(); cursor.next(); @@ -194,8 +226,8 @@ cursor.beforeFirst(); cursor.next(); tuple = cursor.get(); - assertTrue( tuple.getKey().equals( 1 ) ); - assertEquals( 1, ( int ) tuple.getValue().getArrayTree().getFirst() ); + assertEquals( "1", tuple.getKey() ); + assertEquals( "1", tuple.getValue().getArrayTree().getFirst() ); cursor.afterLast(); assertFalse( cursor.next() ); @@ -205,13 +237,13 @@ // just to clear the jdbmTuple value so that line 127 inside after(tuple) method // can be executed as part of the below after(tuple) call - cursor.before(new Tuple>( 1, null ) ); - cursor.after( new Tuple>( 0, null ) ); // this positions on tuple with key 1 + cursor.before(new Tuple>( "1", null ) ); + cursor.after( new Tuple>( "0", null ) ); // this positions on tuple with key 1 cursor.next(); // this moves onto tuple with key 2 tuple = cursor.get(); - assertTrue( tuple.getKey().equals( 2 ) ); - assertEquals( 2, ( int ) tuple.getValue().getArrayTree().getFirst() ); + assertEquals( "2", tuple.getKey() ); + assertEquals( "2", tuple.getValue().getArrayTree().getFirst() ); }