Author: elecharny Date: Fri Jul 22 18:28:27 2011 New Revision: 1149683 URL: http://svn.apache.org/viewvc?rev=1149683&view=rev Log: o Get rid of the SchemaService class : it still exists, but all the remaining methods are static (we don't need anymore to have a schemaService instance in the DirectoryService) o Gives access to the SchemaPartition in the DS o Replaced some calls to the schemaManager.getAttributeTypeRegistry().lookup by the schemaManager.lookupAttributeType() (same for ObjectClass) o Some other minor improvements o Added some Javadoc o Renamed the AbtsractStore test to AbstractPartition (same for AvlStore - AvlPartition) Added: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java - copied, changed from r1149556, 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/AvlPartitionTest.java - copied, changed from r1149556, directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/impl/avl/AvlStoreTest.java Removed: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaService.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/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/exception/ExceptionInterceptor.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DefaultSchemaService.java directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.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/SingleFileLdifPartition.java directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java Modified: directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java (original) +++ directory/apacheds/trunk/core-annotations/src/main/java/org/apache/directory/server/core/factory/DefaultDirectoryServiceFactory.java Fri Jul 22 18:28:27 2011 @@ -30,7 +30,6 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.InstanceLayout; import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.ldif.LdifPartition; -import org.apache.directory.server.core.schema.DefaultSchemaService; import org.apache.directory.server.core.schema.SchemaPartition; import org.apache.directory.server.i18n.I18n; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; @@ -174,15 +173,13 @@ public class DefaultDirectoryServiceFact schemaManager.loadAllEnabled(); directoryService.setSchemaManager( schemaManager ); - directoryService.setSchemaService( new DefaultSchemaService( schemaManager ) ); // Init the LdifPartition LdifPartition ldifPartition = new LdifPartition( schemaManager ); ldifPartition.setPartitionPath( new File(workingDirectory, "schema" ).toURI() ); - - SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition(); - + SchemaPartition schemaPartition = new SchemaPartition( schemaManager ); schemaPartition.setWrappedPartition( ldifPartition ); + directoryService.setSchemaPartition( schemaPartition ); List errors = schemaManager.getErrors(); Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java Fri Jul 22 18:28:27 2011 @@ -36,7 +36,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.PartitionNexus; import org.apache.directory.server.core.replication.ReplicationConfiguration; -import org.apache.directory.server.core.schema.SchemaService; +import org.apache.directory.server.core.schema.SchemaPartition; import org.apache.directory.shared.ldap.codec.api.LdapApiService; import org.apache.directory.shared.ldap.model.csn.Csn; import org.apache.directory.shared.ldap.model.entry.Entry; @@ -129,16 +129,22 @@ public interface DirectoryService extend void setReferralManager( ReferralManager referralManager ); - SchemaService getSchemaService(); + /** + * @return The schema partition + */ + SchemaPartition getSchemaPartition(); /** + * Set the SchemaPartition + * @param schemaPartition the SchemaPartition instance */ - void setSchemaService( SchemaService schemaService ); - - + void setSchemaPartition( SchemaPartition schemaPartition ); + + EventService getEventService(); + /** */ void setEventService( EventService eventService ); Modified: directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java (original) +++ directory/apacheds/trunk/core-api/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java Fri Jul 22 18:28:27 2011 @@ -37,8 +37,8 @@ import javax.naming.directory.SearchResu import org.apache.directory.server.i18n.I18n; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.entry.Attribute; -import org.apache.directory.shared.ldap.model.entry.DefaultEntry; import org.apache.directory.shared.ldap.model.entry.DefaultAttribute; +import org.apache.directory.shared.ldap.model.entry.DefaultEntry; import org.apache.directory.shared.ldap.model.entry.DefaultModification; import org.apache.directory.shared.ldap.model.entry.Entry; import org.apache.directory.shared.ldap.model.entry.Modification; Modified: directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java (original) +++ directory/apacheds/trunk/core-api/src/test/java/org/apache/directory/server/core/MockDirectoryService.java Fri Jul 22 18:28:27 2011 @@ -39,7 +39,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.PartitionNexus; import org.apache.directory.server.core.replication.ReplicationConfiguration; -import org.apache.directory.server.core.schema.SchemaService; +import org.apache.directory.server.core.schema.SchemaPartition; import org.apache.directory.shared.ldap.codec.api.LdapApiService; import org.apache.directory.shared.ldap.model.csn.Csn; import org.apache.directory.shared.ldap.model.entry.Entry; @@ -133,15 +133,14 @@ public class MockDirectoryService implem } - public SchemaService getSchemaService() + public SchemaPartition getSchemaPartition() { return null; } - public void setSchemaService( SchemaService schemaService ) + public void setSchemaPartition( SchemaPartition schemaPartition ) { - } Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java (original) +++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/AbstractMetaSchemaObjectHandler.java Fri Jul 22 18:28:27 2011 @@ -52,7 +52,7 @@ public abstract class AbstractMetaSchema { StringBuilder sb = new StringBuilder(); - sb.append( workingDir ).append( '/' ).append( getService().getSchemaService().getSchemaPartition().getId() ).append( '/' ).append( "ou=schema" ); + sb.append( workingDir ).append( '/' ).append( getService().getSchemaPartition().getId() ).append( '/' ).append( "ou=schema" ); for ( Rdn rdn : dn ) { Modified: directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java (original) +++ directory/apacheds/trunk/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaAttributeTypeHandlerIT.java Fri Jul 22 18:28:27 2011 @@ -413,7 +413,7 @@ public class MetaAttributeTypeHandlerIT assertFalse( "old attributeType OID should be removed from the registry after being renamed", getService().getSchemaManager().getAttributeTypeRegistry().contains( OID ) ); - getService().getSchemaManager().getAttributeTypeRegistry().lookup( OID ); + getService().getSchemaManager().lookupAttributeTypeRegistry( OID ); fail( "attributeType lookup should fail after renaming the attributeType" ); assertTrue( getService().getSchemaManager().getAttributeTypeRegistry().contains( NEW_OID ) ); Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/DefaultDirectoryService.java Fri Jul 22 18:28:27 2011 @@ -73,9 +73,8 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.partition.PartitionNexus; import org.apache.directory.server.core.referral.ReferralInterceptor; import org.apache.directory.server.core.replication.ReplicationConfiguration; -import org.apache.directory.server.core.schema.DefaultSchemaService; import org.apache.directory.server.core.schema.SchemaInterceptor; -import org.apache.directory.server.core.schema.SchemaService; +import org.apache.directory.server.core.schema.SchemaPartition; import org.apache.directory.server.core.security.TlsKeyGenerator; import org.apache.directory.server.core.subtree.SubentryInterceptor; import org.apache.directory.server.core.trigger.TriggerInterceptor; @@ -120,7 +119,7 @@ public class DefaultDirectoryService imp /** The logger */ private static final Logger LOG = LoggerFactory.getLogger( DefaultDirectoryService.class ); - private SchemaService schemaService; + private SchemaPartition schemaPartition; /** A reference on the SchemaManager */ private SchemaManager schemaManager; @@ -1137,15 +1136,21 @@ public class DefaultDirectoryService imp } - public SchemaService getSchemaService() + /** + * {@inheritDoc} + */ + public SchemaPartition getSchemaPartition() { - return schemaService; + return schemaPartition; } - public void setSchemaService( SchemaService schemaService ) + /** + * {@inheritDoc} + */ + public void setSchemaPartition( SchemaPartition schemaPartition ) { - this.schemaService = schemaService; + this.schemaPartition = schemaPartition; } @@ -1516,11 +1521,6 @@ public class DefaultDirectoryService imp LOG.debug( "---> Initializing the DefaultDirectoryService " ); } - if ( schemaService == null ) - { - schemaService = new DefaultSchemaService( schemaManager ); - } - cacheService = new CacheService(); cacheService.initialize( this ); @@ -1533,8 +1533,8 @@ public class DefaultDirectoryService imp dnFactory = new DefaultDnFactory( schemaManager, cacheService.getCache( "dnCache" ) ); // triggers partition to load schema fully from schema partition - schemaService.getSchemaPartition().initialize(); - partitions.add( schemaService.getSchemaPartition() ); + schemaPartition.initialize(); + partitions.add( schemaPartition ); systemPartition.getSuffixDn().apply( schemaManager ); adminDn = getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN ); Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilter.java Fri Jul 22 18:28:27 2011 @@ -40,8 +40,8 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.aci.protectedItem.RestrictedByItem; import org.apache.directory.shared.ldap.aci.protectedItem.SelfValueItem; 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.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.exception.LdapException; import org.apache.directory.shared.ldap.model.name.Dn; @@ -190,7 +190,7 @@ public class RelatedProtectedItemFilter } else { - attr = schemaManager.getAttributeTypeRegistry().lookup( entryAttribute.getId() ); + attr = schemaManager.lookupAttributeTypeRegistry( entryAttribute.getId() ); attrOid = attr.getOid(); entryAttribute.apply( attr ); } Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/changelog/ChangeLogInterceptor.java Fri Jul 22 18:28:27 2011 @@ -24,6 +24,7 @@ import java.util.List; import java.util.Set; import org.apache.directory.server.constants.ApacheSchemaConstants; +import org.apache.directory.server.constants.ServerDNConstants; import org.apache.directory.server.core.DirectoryService; import org.apache.directory.server.core.entry.ClonedServerEntry; import org.apache.directory.server.core.entry.ServerEntryUtils; @@ -37,7 +38,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.interceptor.context.OperationContext; import org.apache.directory.server.core.interceptor.context.RenameOperationContext; import org.apache.directory.server.core.partition.ByPassConstants; -import org.apache.directory.server.core.schema.SchemaService; +import org.apache.directory.server.core.schema.DefaultSchemaService; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.entry.Attribute; import org.apache.directory.shared.ldap.model.entry.DefaultEntry; @@ -50,7 +51,6 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.model.message.controls.ManageDsaITImpl; import org.apache.directory.shared.ldap.model.name.Dn; import org.apache.directory.shared.ldap.model.schema.AttributeType; -import org.apache.directory.shared.ldap.model.schema.SchemaManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,12 +71,6 @@ public class ChangeLogInterceptor extend /** the changelog service to log changes to */ private ChangeLog changeLog; - /** we need the schema manager to deal with special conditions */ - private SchemaManager schemaManager; - - /** we need the schema service to deal with special conditions */ - private SchemaService schemaService; - /** OID of the 'rev' attribute used in changeLogEvent and tag objectclasses */ private static final String REV_AT_OID = "1.3.6.1.4.1.18060.0.4.1.2.47"; @@ -94,7 +88,6 @@ public class ChangeLogInterceptor extend super.init( directoryService ); changeLog = directoryService.getChangeLog(); - schemaService = directoryService.getSchemaService(); entryDeleted = directoryService.getSchemaManager() .getAttributeType( ApacheSchemaConstants.ENTRY_DELETED_AT_OID ); } @@ -175,7 +168,7 @@ public class ChangeLogInterceptor extend for ( Attribute attribute : serverEntry ) { // filter collective attributes, they can't be added by the revert operation - AttributeType at = schemaService.getSchemaManager().getAttributeTypeRegistry().lookup( attribute.getId() ); + AttributeType at = schemaManager.lookupAttributeTypeRegistry( attribute.getId() ); if ( !at.isCollective() || isCollectiveSubentry ) { @@ -201,9 +194,9 @@ public class ChangeLogInterceptor extend Entry serverEntry; // @todo make sure we're not putting in operational attributes that cannot be user modified - if ( schemaService.isSchemaSubentry( dn ) ) + if ( dn.equals( ServerDNConstants.CN_SCHEMA_DN ) ) { - return schemaService.getSubschemaEntryCloned(); + return DefaultSchemaService.getSubschemaEntryCloned( directoryService ); } else { 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=1149683&r1=1149682&r2=1149683&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 Fri Jul 22 18:28:27 2011 @@ -40,6 +40,7 @@ import org.apache.directory.server.core. import org.apache.directory.server.core.partition.ByPassConstants; import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.PartitionNexus; +import org.apache.directory.server.core.schema.DefaultSchemaService; import org.apache.directory.server.i18n.I18n; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.cursor.EmptyCursor; @@ -241,7 +242,7 @@ public class ExceptionInterceptor extend if ( dn.equals( subschemSubentryDn ) ) { - Entry serverEntry = directoryService.getSchemaService().getSubschemaEntry( lookupContext.getAttrsIdArray() ); + Entry serverEntry = DefaultSchemaService.getSubschemaEntry( directoryService, lookupContext.getAttrsIdArray() ); serverEntry.setDn( dn ); return serverEntry; Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DefaultSchemaService.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DefaultSchemaService.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DefaultSchemaService.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DefaultSchemaService.java Fri Jul 22 18:28:27 2011 @@ -24,6 +24,7 @@ import java.util.Set; import org.apache.directory.server.constants.ApacheSchemaConstants; import org.apache.directory.server.constants.ServerDNConstants; +import org.apache.directory.server.core.DirectoryService; import org.apache.directory.server.core.interceptor.context.LookupOperationContext; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.entry.Attribute; @@ -46,6 +47,7 @@ import org.apache.directory.shared.ldap. import org.apache.directory.shared.ldap.model.schema.SchemaUtils; import org.apache.directory.shared.ldap.model.schema.SyntaxChecker; import org.apache.directory.shared.ldap.model.schema.registries.NormalizerRegistry; +import org.apache.directory.shared.util.StringConstants; /** @@ -53,64 +55,24 @@ import org.apache.directory.shared.ldap. * * @author Apache Directory Project */ -public class DefaultSchemaService implements SchemaService +public class DefaultSchemaService { - private static final String[] EMPTY_STRING_ARRAY = new String[0]; - /** cached version of the schema subentry with all attributes in it */ - private Entry schemaSubentry; - private final Object lock = new Object(); - - /** a handle on the schema partition */ - private SchemaPartition schemaPartition; - - /** the normalized name for the schema modification attributes */ - private Dn schemaModificationAttributesDn; + private static Entry schemaSubentry; /** A lock to avid concurrent generation of the SubschemaSubentry */ - private Object schemaSubentrLock = new Object(); - - - public DefaultSchemaService( SchemaManager schemaManager ) throws Exception - { - schemaPartition = new SchemaPartition( schemaManager ); - schemaModificationAttributesDn = new Dn( getSchemaManager(), SchemaConstants.SCHEMA_MODIFICATIONS_DN ); - } - - - /** - * {@inheritDoc} - */ - public boolean isSchemaSubentry( Dn dn ) throws LdapException - { - return dn.getNormName().equals( ServerDNConstants.CN_SCHEMA_DN_NORMALIZED ); - } + private static Object schemaSubentrLock = new Object(); - public final SchemaManager getSchemaManager() - { - return schemaPartition.getSchemaManager(); - } - - - /* (non-Javadoc) - * @see org.apache.directory.server.core.schema.SchemaService#getSchemaPartition() - */ - public SchemaPartition getSchemaPartition() - { - return schemaPartition; - } - - /** * Generate the comparators attribute from the registry */ - private Attribute generateComparators() throws LdapException + private static Attribute generateComparators( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().lookupAttributeTypeRegistry( SchemaConstants.COMPARATORS_AT ) ); + schemaManager.lookupAttributeTypeRegistry( SchemaConstants.COMPARATORS_AT ) ); - for ( LdapComparator comparator : getSchemaManager().getComparatorRegistry() ) + for ( LdapComparator comparator : schemaManager.getComparatorRegistry() ) { attr.add( SchemaUtils.render( comparator ) ); } @@ -119,12 +81,12 @@ public class DefaultSchemaService implem } - private Attribute generateNormalizers() throws LdapException + private static Attribute generateNormalizers( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.NORMALIZERS_AT ) ); + schemaManager.getAttributeType( SchemaConstants.NORMALIZERS_AT ) ); - NormalizerRegistry nr = getSchemaManager().getNormalizerRegistry(); + NormalizerRegistry nr = schemaManager.getNormalizerRegistry(); for ( Normalizer normalizer : nr ) { @@ -135,12 +97,12 @@ public class DefaultSchemaService implem } - private Attribute generateSyntaxCheckers() throws LdapException + private static Attribute generateSyntaxCheckers( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.SYNTAX_CHECKERS_AT ) ); + schemaManager.getAttributeType( SchemaConstants.SYNTAX_CHECKERS_AT ) ); - for ( SyntaxChecker syntaxChecker : getSchemaManager().getSyntaxCheckerRegistry() ) + for ( SyntaxChecker syntaxChecker : schemaManager.getSyntaxCheckerRegistry() ) { attr.add( SchemaUtils.render( syntaxChecker ) ); } @@ -149,12 +111,12 @@ public class DefaultSchemaService implem } - private Attribute generateObjectClasses() throws LdapException + private static Attribute generateObjectClasses( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.OBJECT_CLASSES_AT ) ); + schemaManager.getAttributeType( SchemaConstants.OBJECT_CLASSES_AT ) ); - for ( ObjectClass objectClass : getSchemaManager().getObjectClassRegistry() ) + for ( ObjectClass objectClass : schemaManager.getObjectClassRegistry() ) { attr.add( SchemaUtils.render( objectClass ).toString() ); } @@ -163,12 +125,12 @@ public class DefaultSchemaService implem } - private Attribute generateAttributeTypes() throws LdapException + private static Attribute generateAttributeTypes( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.ATTRIBUTE_TYPES_AT ) ); + schemaManager.getAttributeType( SchemaConstants.ATTRIBUTE_TYPES_AT ) ); - for ( AttributeType attributeType : getSchemaManager().getAttributeTypeRegistry() ) + for ( AttributeType attributeType : schemaManager.getAttributeTypeRegistry() ) { attr.add( SchemaUtils.render( attributeType ).toString() ); } @@ -177,12 +139,12 @@ public class DefaultSchemaService implem } - private Attribute generateMatchingRules() throws LdapException + private static Attribute generateMatchingRules( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.MATCHING_RULES_AT ) ); + schemaManager.getAttributeType( SchemaConstants.MATCHING_RULES_AT ) ); - for ( MatchingRule matchingRule : getSchemaManager().getMatchingRuleRegistry() ) + for ( MatchingRule matchingRule : schemaManager.getMatchingRuleRegistry() ) { attr.add( SchemaUtils.render( matchingRule ).toString() ); } @@ -191,12 +153,12 @@ public class DefaultSchemaService implem } - private Attribute generateMatchingRuleUses() throws LdapException + private static Attribute generateMatchingRuleUses( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.MATCHING_RULE_USE_AT ) ); + schemaManager.getAttributeType( SchemaConstants.MATCHING_RULE_USE_AT ) ); - for ( MatchingRuleUse matchingRuleUse : getSchemaManager().getMatchingRuleUseRegistry() ) + for ( MatchingRuleUse matchingRuleUse : schemaManager.getMatchingRuleUseRegistry() ) { attr.add( SchemaUtils.render( matchingRuleUse ).toString() ); } @@ -205,12 +167,12 @@ public class DefaultSchemaService implem } - private Attribute generateSyntaxes() throws LdapException + private static Attribute generateSyntaxes( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.LDAP_SYNTAXES_AT ) ); + schemaManager.getAttributeType( SchemaConstants.LDAP_SYNTAXES_AT ) ); - for ( LdapSyntax syntax : getSchemaManager().getLdapSyntaxRegistry() ) + for ( LdapSyntax syntax : schemaManager.getLdapSyntaxRegistry() ) { attr.add( SchemaUtils.render( syntax ).toString() ); } @@ -219,12 +181,12 @@ public class DefaultSchemaService implem } - private Attribute generateDitContextRules() throws LdapException + private static Attribute generateDitContextRules( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.DIT_CONTENT_RULES_AT ) ); + schemaManager.getAttributeType( SchemaConstants.DIT_CONTENT_RULES_AT ) ); - for ( DITContentRule ditContentRule : getSchemaManager().getDITContentRuleRegistry() ) + for ( DITContentRule ditContentRule : schemaManager.getDITContentRuleRegistry() ) { attr.add( SchemaUtils.render( ditContentRule ).toString() ); } @@ -233,12 +195,12 @@ public class DefaultSchemaService implem } - private Attribute generateDitStructureRules() throws LdapException + private static Attribute generateDitStructureRules( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.DIT_STRUCTURE_RULES_AT ) ); + schemaManager.getAttributeType( SchemaConstants.DIT_STRUCTURE_RULES_AT ) ); - for ( DITStructureRule ditStructureRule : getSchemaManager().getDITStructureRuleRegistry() ) + for ( DITStructureRule ditStructureRule : schemaManager.getDITStructureRuleRegistry() ) { attr.add( SchemaUtils.render( ditStructureRule ).toString() ); } @@ -247,12 +209,12 @@ public class DefaultSchemaService implem } - private Attribute generateNameForms() throws LdapException + private static Attribute generateNameForms( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( - getSchemaManager().getAttributeType( SchemaConstants.NAME_FORMS_AT ) ); + schemaManager.getAttributeType( SchemaConstants.NAME_FORMS_AT ) ); - for ( NameForm nameForm : getSchemaManager().getNameFormRegistry() ) + for ( NameForm nameForm : schemaManager.getNameFormRegistry() ) { attr.add( SchemaUtils.render( nameForm ).toString() ); } @@ -264,9 +226,9 @@ public class DefaultSchemaService implem /** * Creates the SSSE by extracting all the SchemaObjects from the registries. */ - private void generateSchemaSubentry( Entry mods ) throws LdapException + private static void generateSchemaSubentry( SchemaManager schemaManager, Entry mods ) throws LdapException { - Entry attrs = new DefaultEntry( getSchemaManager(), mods.getDn() ); + Entry attrs = new DefaultEntry( schemaManager, mods.getDn() ); // add the objectClass attribute : 'top', 'subschema', 'subentry' and 'apacheSubschema' attrs.put( SchemaConstants.OBJECT_CLASS_AT, @@ -280,17 +242,17 @@ public class DefaultSchemaService implem attrs.put( SchemaConstants.CN_AT, "schema" ); // generate all the other operational attributes - attrs.put( generateComparators() ); - attrs.put( generateNormalizers() ); - attrs.put( generateSyntaxCheckers() ); - attrs.put( generateObjectClasses() ); - attrs.put( generateAttributeTypes() ); - attrs.put( generateMatchingRules() ); - attrs.put( generateMatchingRuleUses() ); - attrs.put( generateSyntaxes() ); - attrs.put( generateDitContextRules() ); - attrs.put( generateDitStructureRules() ); - attrs.put( generateNameForms() ); + attrs.put( generateComparators( schemaManager ) ); + attrs.put( generateNormalizers( schemaManager ) ); + attrs.put( generateSyntaxCheckers( schemaManager ) ); + attrs.put( generateObjectClasses( schemaManager ) ); + attrs.put( generateAttributeTypes( schemaManager ) ); + attrs.put( generateMatchingRules( schemaManager ) ); + attrs.put( generateMatchingRuleUses( schemaManager ) ); + attrs.put( generateSyntaxes( schemaManager ) ); + attrs.put( generateDitContextRules( schemaManager ) ); + attrs.put( generateDitStructureRules( schemaManager ) ); + attrs.put( generateNameForms( schemaManager ) ); attrs.put( SchemaConstants.SUBTREE_SPECIFICATION_AT, "{}" ); // ------------------------------------------------------------------- @@ -314,14 +276,14 @@ public class DefaultSchemaService implem // don't swap out if a request for the subentry is in progress or we // can give back an inconsistent schema back to the client so we block - synchronized ( lock ) + synchronized ( schemaSubentrLock ) { schemaSubentry = attrs; } } - private void addAttribute( Entry attrs, String id ) throws LdapException + private static void addAttribute( Entry attrs, String id ) throws LdapException { Attribute attr = schemaSubentry.get( id ); @@ -335,13 +297,18 @@ public class DefaultSchemaService implem /** * {@inheritDoc} */ - public Entry getSubschemaEntryImmutable() throws LdapException + public static Entry getSubschemaEntryImmutable( DirectoryService directoryService ) throws LdapException { synchronized ( schemaSubentrLock ) { if ( schemaSubentry == null ) { - generateSchemaSubentry( schemaPartition.lookup( + Dn schemaModificationAttributesDn = new Dn( directoryService.getSchemaManager(), + SchemaConstants.SCHEMA_MODIFICATIONS_DN ); + + generateSchemaSubentry( + directoryService.getSchemaManager(), + directoryService.getSchemaPartition().lookup( new LookupOperationContext( null, schemaModificationAttributesDn) ) ); } @@ -353,11 +320,16 @@ public class DefaultSchemaService implem /* (non-Javadoc) * @see org.apache.directory.server.core.schema.SchemaService#getSubschemaEntryCloned() */ - public Entry getSubschemaEntryCloned() throws LdapException + public static Entry getSubschemaEntryCloned( DirectoryService directoryService ) throws LdapException { if ( schemaSubentry == null ) { - generateSchemaSubentry( schemaPartition.lookup( + Dn schemaModificationAttributesDn = new Dn( directoryService.getSchemaManager(), + SchemaConstants.SCHEMA_MODIFICATIONS_DN ); + + generateSchemaSubentry( + directoryService.getSchemaManager(), + directoryService.getSchemaPartition().lookup( new LookupOperationContext( null, schemaModificationAttributesDn) ) ); } @@ -368,25 +340,29 @@ public class DefaultSchemaService implem /** * {@inheritDoc} */ - public Entry getSubschemaEntry( String[] ids ) throws LdapException + public static Entry getSubschemaEntry( DirectoryService directoryService, String[] ids ) throws LdapException { if ( ids == null ) { - ids = EMPTY_STRING_ARRAY; + ids = StringConstants.EMPTY_STRINGS; } + + SchemaManager schemaManager = directoryService.getSchemaManager(); Set setOids = new HashSet(); - Entry attrs = new DefaultEntry( getSchemaManager(), Dn.ROOT_DSE ); + Entry attrs = new DefaultEntry( schemaManager, Dn.ROOT_DSE ); boolean returnAllOperationalAttributes = false; - synchronized( lock ) + synchronized( schemaSubentrLock ) { // --------------------------------------------------------------- // Check if we need an update by looking at timestamps on disk // --------------------------------------------------------------- + Dn schemaModificationAttributesDn = new Dn( directoryService.getSchemaManager(), + SchemaConstants.SCHEMA_MODIFICATIONS_DN ); Entry mods = - schemaPartition.lookup( + directoryService.getSchemaPartition().lookup( new LookupOperationContext( null, schemaModificationAttributesDn, SchemaConstants.ALL_ATTRIBUTES_ARRAY ) ); // @todo enable this optimization at some point but for now it @@ -418,7 +394,7 @@ public class DefaultSchemaService implem // } // else // { - generateSchemaSubentry( mods ); + generateSchemaSubentry( schemaManager, mods ); // } // --------------------------------------------------------------- @@ -439,7 +415,7 @@ public class DefaultSchemaService implem } else { - setOids.add( getSchemaManager().getAttributeTypeRegistry().getOidByName( id ) ); + setOids.add( schemaManager.getAttributeTypeRegistry().getOidByName( id ) ); } } Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java (original) +++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java Fri Jul 22 18:28:27 2011 @@ -141,8 +141,6 @@ public class SchemaInterceptor extends B /** The schema manager */ private SchemaSubentryManager schemaSubEntryManager; - private SchemaService schemaService; - /** the base Dn (normalized) of the schema partition */ private Dn schemaBaseDn; @@ -181,7 +179,6 @@ public class SchemaInterceptor extends B filters.add( topFilter ); schemaBaseDn = directoryService.getDnFactory().create( SchemaConstants.OU_SCHEMA ); - schemaService = directoryService.getSchemaService(); // stuff for dealing with subentries (garbage for now) Value subschemaSubentry = nexus.getRootDSE( null ).get( SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get(); @@ -195,7 +192,7 @@ public class SchemaInterceptor extends B computeSuperiors(); // Initialize the schema manager - SchemaLoader loader = schemaService.getSchemaPartition().getSchemaManager().getLoader(); + SchemaLoader loader = directoryService.getSchemaManager().getLoader(); schemaSubEntryManager = new SchemaSubentryManager( schemaManager, loader, directoryService.getDnFactory() ); if ( IS_DEBUG ) @@ -690,7 +687,7 @@ public class SchemaInterceptor extends B if ( schemaManager.getObjectClassRegistry().contains( objectClass ) ) { - objectClassOid = schemaManager.getObjectClassRegistry().lookup( objectClass ).getOid(); + objectClassOid = schemaManager.lookupObjectClassRegistry( objectClass ).getOid(); } else { @@ -705,7 +702,7 @@ public class SchemaInterceptor extends B .equals( SchemaConstants.SUBSCHEMA_OC_OID ) ) && ( node instanceof EqualityNode ) ) { // call.setBypass( true ); - Entry serverEntry = schemaService.getSubschemaEntry( searchCtls.getReturningAttributes() ); + Entry serverEntry = DefaultSchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() ); serverEntry.setDn( base ); return new BaseEntryFilteringCursor( new SingletonCursor( serverEntry ), searchContext ); } @@ -722,7 +719,7 @@ public class SchemaInterceptor extends B if ( node.getAttributeType().equals( OBJECT_CLASS_AT ) ) { // call.setBypass( true ); - Entry serverEntry = schemaService.getSubschemaEntry( searchCtls.getReturningAttributes() ); + Entry serverEntry = DefaultSchemaService.getSubschemaEntry( directoryService, searchCtls.getReturningAttributes() ); serverEntry.setDn( base ); EntryFilteringCursor cursor = new BaseEntryFilteringCursor( new SingletonCursor( serverEntry ), searchContext ); @@ -793,7 +790,7 @@ public class SchemaInterceptor extends B hasExtensibleObject = true; } - ObjectClass oc = schemaManager.getObjectClassRegistry().lookup( objectClassName ); + ObjectClass oc = schemaManager.lookupObjectClassRegistry( objectClassName ); // Add all unseen objectClasses to the list, except 'top' if ( !ocSeen.contains( oc.getOid() ) ) @@ -818,7 +815,7 @@ public class SchemaInterceptor extends B for ( Value value : objectClasses ) { String ocName = value.getString(); - ObjectClass oc = schemaManager.getObjectClassRegistry().lookup( ocName ); + ObjectClass oc = schemaManager.lookupObjectClassRegistry( ocName ); List types = oc.getMustAttributeTypes(); @@ -847,7 +844,7 @@ public class SchemaInterceptor extends B for ( Value objectClass : objectClasses ) { String ocName = objectClass.getString(); - ObjectClass oc = schemaManager.getObjectClassRegistry().lookup( ocName ); + ObjectClass oc = schemaManager.lookupObjectClassRegistry( ocName ); List types = oc.getMayAttributeTypes(); @@ -894,7 +891,7 @@ public class SchemaInterceptor extends B { String ocLowerName = ocName.toLowerCase(); - ObjectClass objectClass = schemaManager.getObjectClassRegistry().lookup( ocLowerName ); + ObjectClass objectClass = schemaManager.lookupObjectClassRegistry( ocLowerName ); if ( !objectClasses.contains( ocLowerName ) ) { @@ -1437,7 +1434,7 @@ public class SchemaInterceptor extends B { String supName = sup.getString(); - ObjectClass superior = schemaManager.getObjectClassRegistry().lookup( supName ); + ObjectClass superior = schemaManager.lookupObjectClassRegistry( supName ); switch ( ocType ) { @@ -1518,7 +1515,7 @@ public class SchemaInterceptor extends B Attribute oidAT = entry.get( MetaSchemaConstants.M_OID_AT ); String ocOid = oidAT.getString(); - ObjectClass addedOC = schemaManager.getObjectClassRegistry().lookup( ocOid ); + ObjectClass addedOC = schemaManager.lookupObjectClassRegistry( ocOid ); computeSuperior( addedOC ); } } Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java (original) +++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java Fri Jul 22 18:28:27 2011 @@ -23,10 +23,8 @@ import static org.junit.Assert.assertFal import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import com.mycila.junit.concurrent.Concurrency; -import com.mycila.junit.concurrent.ConcurrentJunitRunner; -import org.apache.directory.shared.ldap.model.entry.DefaultAttribute; import org.apache.directory.shared.ldap.model.entry.Attribute; +import org.apache.directory.shared.ldap.model.entry.DefaultAttribute; import org.apache.directory.shared.ldap.model.entry.StringValue; import org.apache.directory.shared.ldap.model.filter.EqualityNode; import org.apache.directory.shared.ldap.model.filter.ExprNode; @@ -42,6 +40,9 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import com.mycila.junit.concurrent.Concurrency; +import com.mycila.junit.concurrent.ConcurrentJunitRunner; + /** * Unit test cases for testing the evaluator for refinements. @@ -87,7 +88,7 @@ public class RefinementEvaluatorTest evaluator = new RefinementEvaluator( leafEvaluator ); OBJECT_CLASS_AT = schemaManager.getAttributeType( "objectClass" ); - CN_AT = schemaManager.getAttributeTypeRegistry().lookup( "cn" ); + CN_AT = schemaManager.lookupAttributeTypeRegistry( "cn" ); } Modified: directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java (original) +++ directory/apacheds/trunk/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmPartition.java Fri Jul 22 18:28:27 2011 @@ -22,7 +22,6 @@ package org.apache.directory.server.core import java.io.File; import java.io.FilenameFilter; -import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -120,13 +119,14 @@ public class JdbmPartition extends Abstr searchEngine = new DefaultSearchEngine( this, cursorBuilder, evaluatorBuilder, optimizer ); // Create the underlying directories (only if needed) - getPartitionDir().mkdirs(); + File partitionDir = new File( getPartitionPath() ); + partitionDir.mkdirs(); // Initialize the indexes super.doInit(); // First, check if the file storing the data exists - String path = getPartitionDir().getPath() + File.separator + "master"; + String path = partitionDir.getPath() + File.separator + "master"; BaseRecordManager baseRecordManager = new BaseRecordManager( path ); baseRecordManager.disableTransactions(); @@ -147,10 +147,10 @@ public class JdbmPartition extends Abstr master = new JdbmMasterTable( recMan, schemaManager ); // get all index db files first - File[] allIndexDbFiles = getPartitionDir().listFiles( DB_FILTER ); + File[] allIndexDbFiles = partitionDir.listFiles( DB_FILTER ); // get the names of the db files also - List indexDbFileNameList = Arrays.asList( getPartitionDir().list( DB_FILTER ) ); + List indexDbFileNameList = Arrays.asList( partitionDir.list( DB_FILTER ) ); // then add all index objects to a list List allIndices = new ArrayList(); @@ -363,21 +363,6 @@ public class JdbmPartition extends Abstr } - private File getPartitionDir() - { - return new File( getPartitionPath() ); - } - - - /** - * {@inheritDoc} - */ - public URI getPartitionPath() - { - return partitionPath; - } - - /** * {@inheritDoc} */ 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=1149683&r1=1149682&r2=1149683&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 22 18:28:27 2011 @@ -35,7 +35,6 @@ import java.util.UUID; import org.apache.commons.io.FileUtils; import org.apache.directory.server.constants.ApacheSchemaConstants; import org.apache.directory.server.core.interceptor.context.AddOperationContext; -import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.xdbm.GenericIndex; import org.apache.directory.server.xdbm.Index; import org.apache.directory.server.xdbm.IndexEntry; @@ -158,9 +157,9 @@ public class JdbmStoreTest store.addIndex( uidIndex ); Dn suffixDn = new Dn( schemaManager, "o=Good Times Co." ); - ((Partition)store).setSuffixDn( suffixDn ); + store.setSuffixDn( suffixDn ); - ((Partition)store).initialize(); + store.initialize(); StoreUtils.loadExampleData( store, schemaManager ); LOG.debug( "Created new store" ); Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java (original) +++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/SingleFileLdifPartition.java Fri Jul 22 18:28:27 2011 @@ -62,7 +62,6 @@ import org.slf4j.LoggerFactory; */ public class SingleFileLdifPartition extends AbstractLdifPartition { - /** the LDIF file holding the partition's data */ private RandomAccessFile ldifFile; @@ -431,7 +430,6 @@ public class SingleFileLdifPartition ext return ldifFile.readLine(); } - } Modified: directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java (original) +++ directory/apacheds/trunk/server-config/src/main/java/org/apache/directory/server/config/ConfigWriter.java Fri Jul 22 18:28:27 2011 @@ -33,8 +33,8 @@ import java.util.Set; import org.apache.directory.server.config.beans.AdsBaseBean; import org.apache.directory.server.config.beans.ConfigBean; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; -import org.apache.directory.shared.ldap.model.entry.DefaultAttribute; import org.apache.directory.shared.ldap.model.entry.Attribute; +import org.apache.directory.shared.ldap.model.entry.DefaultAttribute; 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.ldif.LdifEntry; @@ -208,7 +208,7 @@ public class ConfigWriter private void addObjectClassAttribute( SchemaManager schemaManager, LdifEntry entry, String objectClass ) throws LdapException { - ObjectClass objectClassObject = schemaManager.getObjectClassRegistry().lookup( objectClass ); + ObjectClass objectClassObject = schemaManager.lookupObjectClassRegistry( objectClass ); if ( objectClassObject != null ) { // Building the list of 'objectClass' attribute values @@ -240,7 +240,7 @@ public class ConfigWriter Set objectClassAttributeValues, ObjectClass objectClass ) throws LdapException { - ObjectClass topObjectClass = schemaManager.getObjectClassRegistry().lookup( SchemaConstants.TOP_OC ); + ObjectClass topObjectClass = schemaManager.lookupObjectClassRegistry( SchemaConstants.TOP_OC ); if ( topObjectClass != null ) { // TODO throw new exception (there should be a top object class Modified: directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java (original) +++ directory/apacheds/trunk/server-jndi/src/main/java/org/apache/directory/server/configuration/ApacheDS.java Fri Jul 22 18:28:27 2011 @@ -474,7 +474,7 @@ public class ApacheDS */ private void initSchema() throws Exception { - SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition(); + SchemaPartition schemaPartition = directoryService.getSchemaPartition(); String workingDirectory = directoryService.getInstanceLayout().getPartitionsDirectory().getPath(); // Extract the schema on disk (a brand new one) and load the registries Modified: directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java (original) +++ directory/apacheds/trunk/service/src/main/java/org/apache/directory/server/ApacheDsService.java Fri Jul 22 18:28:27 2011 @@ -284,10 +284,7 @@ public class ApacheDsService DirectoryService directoryService = ServiceBuilder.createDirectoryService( directoryServiceBean, instanceLayout, schemaManager ); - directoryService.setSchemaManager( schemaManager ); - directoryService.setSchemaService( new DefaultSchemaService( schemaManager ) ); - - SchemaPartition schemaPartition = directoryService.getSchemaService().getSchemaPartition(); + SchemaPartition schemaPartition = directoryService.getSchemaPartition(); schemaPartition.setWrappedPartition( schemaLdifPartition ); directoryService.addPartition( configPartition ); Modified: directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java?rev=1149683&r1=1149682&r2=1149683&view=diff ============================================================================== --- directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java (original) +++ directory/apacheds/trunk/xdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/AbstractBTreePartition.java Fri Jul 22 18:28:27 2011 @@ -447,7 +447,10 @@ public abstract class AbstractBTreeParti * * @return the path in which this Partition stores data. */ - public abstract URI getPartitionPath(); + public URI getPartitionPath() + { + return partitionPath; + } // ------------------------------------------------------------------------ Copied: directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java (from r1149556, 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/PartitionTest.java?p2=directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/PartitionTest.java&p1=directory/apacheds/trunk/xdbm-partition/src/test/java/org/apache/directory/server/xdbm/AbstractStoreTest.java&r1=1149556&r2=1149683&rev=1149683&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/PartitionTest.java Fri Jul 22 18:28:27 2011 @@ -33,10 +33,9 @@ import java.util.Iterator; import net.sf.ehcache.store.AbstractStore; -import org.apache.directory.server.core.partition.Partition; import org.apache.directory.server.core.partition.impl.avl.AvlPartition; import org.apache.directory.server.xdbm.impl.avl.AvlIndex; -import org.apache.directory.server.xdbm.impl.avl.AvlStoreTest; +import org.apache.directory.server.xdbm.impl.avl.AvlPartitionTest; import org.apache.directory.shared.ldap.model.constants.SchemaConstants; import org.apache.directory.shared.ldap.model.csn.CsnFactory; import org.apache.directory.shared.ldap.model.entry.Attribute; @@ -68,11 +67,11 @@ import org.slf4j.LoggerFactory; * * @author Apache Directory Project */ -public class AbstractStoreTest +public class PartitionTest { - private static final Logger LOG = LoggerFactory.getLogger( AbstractStoreTest.class ); + private static final Logger LOG = LoggerFactory.getLogger( PartitionTest.class ); - private static Store store; + private static AvlPartition partition; private static SchemaManager schemaManager = null; /** The OU AttributType instance */ @@ -91,7 +90,7 @@ public class AbstractStoreTest if ( workingDirectory == null ) { - String path = AvlStoreTest.class.getResource( "" ).getPath(); + String path = AvlPartitionTest.class.getResource( "" ).getPath(); int targetPos = path.indexOf( "target" ); workingDirectory = path.substring( 0, targetPos + 6 ); } @@ -120,45 +119,45 @@ public class AbstractStoreTest public void createStore() throws Exception { - // initialize the store - store = new AvlPartition( schemaManager ); - ((Partition)store).setId( "example" ); - store.setSyncOnWrite( false ); - - store.addIndex( new AvlIndex( SchemaConstants.OU_AT_OID ) ); - store.addIndex( new AvlIndex( SchemaConstants.UID_AT_OID ) ); - store.addIndex( new AvlIndex( SchemaConstants.CN_AT_OID ) ); - ((Partition)store).setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) ); + // initialize the partition + partition = new AvlPartition( schemaManager ); + partition.setId( "example" ); + partition.setSyncOnWrite( false ); + + partition.addIndex( new AvlIndex( SchemaConstants.OU_AT_OID ) ); + partition.addIndex( new AvlIndex( SchemaConstants.UID_AT_OID ) ); + partition.addIndex( new AvlIndex( SchemaConstants.CN_AT_OID ) ); + partition.setSuffixDn( new Dn( schemaManager, "o=Good Times Co." ) ); - ((Partition)store).initialize(); + partition.initialize(); - StoreUtils.loadExampleData( store, schemaManager ); - LOG.debug( "Created new store" ); + StoreUtils.loadExampleData( partition, schemaManager ); + LOG.debug( "Created new partition" ); } @After public void destroyStore() throws Exception { - ((Partition)store).destroy(); + partition.destroy(); } @Test public void testExampleDataIndices() throws Exception { - assertEquals( 11, store.getRdnIndex().count() ); - assertEquals( 11, store.getOneLevelIndex().count() ); - assertEquals( 19, store.getSubLevelIndex().count() ); - assertEquals( 3, store.getAliasIndex().count() ); - assertEquals( 3, store.getOneAliasIndex().count() ); - assertEquals( 3, store.getSubAliasIndex().count() ); - assertEquals( 15, store.getPresenceIndex().count() ); - assertEquals( 27, store.getObjectClassIndex().count() ); - assertEquals( 11, store.getEntryCsnIndex().count() ); - assertEquals( 11, store.getEntryUuidIndex().count() ); + assertEquals( 11, partition.getRdnIndex().count() ); + assertEquals( 11, partition.getOneLevelIndex().count() ); + assertEquals( 19, partition.getSubLevelIndex().count() ); + assertEquals( 3, partition.getAliasIndex().count() ); + assertEquals( 3, partition.getOneAliasIndex().count() ); + assertEquals( 3, partition.getSubAliasIndex().count() ); + assertEquals( 15, partition.getPresenceIndex().count() ); + assertEquals( 27, partition.getObjectClassIndex().count() ); + assertEquals( 11, partition.getEntryCsnIndex().count() ); + assertEquals( 11, partition.getEntryUuidIndex().count() ); - Iterator userIndices = store.getUserIndices(); + Iterator userIndices = partition.getUserIndices(); int count = 0; while ( userIndices.hasNext() ) @@ -168,9 +167,9 @@ public class AbstractStoreTest } assertEquals( 3, count ); - assertEquals( 9, store.getUserIndex( OU_AT ).count() ); - assertEquals( 0, store.getUserIndex( UID_AT ).count() ); - assertEquals( 6, store.getUserIndex( CN_AT ).count() ); + assertEquals( 9, partition.getUserIndex( OU_AT ).count() ); + assertEquals( 0, partition.getUserIndex( UID_AT ).count() ); + assertEquals( 6, partition.getUserIndex( CN_AT ).count() ); } @@ -190,17 +189,17 @@ public class AbstractStoreTest Modification add = new DefaultModification( ModificationOperation.ADD_ATTRIBUTE, attrib ); - Long entryId = store.getEntryId( dn ); - Entry lookedup = store.lookup( entryId ); + Long entryId = partition.getEntryId( dn ); + Entry lookedup = partition.lookup( entryId ); // before modification: no "uidObject" tuple in objectClass index - assertFalse( store.getObjectClassIndex().forward( "uidObject", entryId ) ); + assertFalse( partition.getObjectClassIndex().forward( "uidObject", entryId ) ); assertFalse( lookedup.get( "objectClass" ).contains( "uidObject" ) ); - lookedup = store.modify( dn, add ); + lookedup = partition.modify( dn, add ); // after modification: expect "uidObject" tuple in objectClass index - assertTrue( store.getObjectClassIndex().forward( "uidObject", entryId ) ); + assertTrue( partition.getObjectClassIndex().forward( "uidObject", entryId ) ); assertTrue( lookedup.get( "objectClass" ).contains( "uidObject" ) ); } @@ -220,15 +219,15 @@ public class AbstractStoreTest Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib ); - Long entryId = store.getEntryId( dn ); - Entry lookedup = store.lookup( entryId ); + Long entryId = partition.getEntryId( dn ); + Entry lookedup = partition.lookup( entryId ); // before modification: expect "sales" tuple in ou index - Index ouIndex = ( Index ) store.getUserIndex( OU_AT ); + Index ouIndex = ( Index ) partition.getUserIndex( OU_AT ); assertTrue( ouIndex.forward( "sales", entryId ) ); assertTrue( lookedup.get( "ou" ).contains( "sales" ) ); - lookedup = store.modify( dn, add ); + lookedup = partition.modify( dn, add ); // after modification: no "sales" tuple in ou index assertFalse( ouIndex.forward( "sales", entryId ) ); @@ -249,19 +248,19 @@ public class AbstractStoreTest Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib ); - Long entryId = store.getEntryId( dn ); - Entry lookedup = store.lookup( entryId ); + Long entryId = partition.getEntryId( dn ); + Entry lookedup = partition.lookup( entryId ); // before modification: expect "sales" tuple in ou index - Index ouIndex = ( Index ) store.getUserIndex( OU_AT ); - assertTrue( store.getPresenceIndex().forward( SchemaConstants.OU_AT_OID, entryId ) ); + Index ouIndex = ( Index ) partition.getUserIndex( OU_AT ); + assertTrue( partition.getPresenceIndex().forward( SchemaConstants.OU_AT_OID, entryId ) ); assertTrue( ouIndex.forward( "sales", entryId ) ); assertTrue( lookedup.get( "ou" ).contains( "sales" ) ); - lookedup = store.modify( dn, add ); + lookedup = partition.modify( dn, add ); // after modification: no "sales" tuple in ou index - assertFalse( store.getPresenceIndex().forward( SchemaConstants.OU_AT_OID, entryId ) ); + assertFalse( partition.getPresenceIndex().forward( SchemaConstants.OU_AT_OID, entryId ) ); assertFalse( ouIndex.reverse( entryId ) ); assertFalse( ouIndex.forward( "sales", entryId ) ); assertNull( lookedup.get( "ou" ) ); @@ -284,17 +283,17 @@ public class AbstractStoreTest Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib ); - Long entryId = store.getEntryId( dn ); - Entry lookedup = store.lookup( entryId ); + Long entryId = partition.getEntryId( dn ); + Entry lookedup = partition.lookup( entryId ); // before modification: expect "person" tuple in objectClass index - assertTrue( store.getObjectClassIndex().forward( "person", entryId ) ); + assertTrue( partition.getObjectClassIndex().forward( "person", entryId ) ); assertTrue( lookedup.get( "objectClass" ).contains( "person" ) ); - lookedup = store.modify( dn, add ); + lookedup = partition.modify( dn, add ); // after modification: no "person" tuple in objectClass index - assertFalse( store.getObjectClassIndex().forward( "person", entryId ) ); + assertFalse( partition.getObjectClassIndex().forward( "person", entryId ) ); assertFalse( lookedup.get( "objectClass" ).contains( "person" ) ); } @@ -312,19 +311,19 @@ public class AbstractStoreTest Modification add = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE, attrib ); - Long entryId = store.getEntryId( dn ); - Entry lookedup = store.lookup( entryId ); + Long entryId = partition.getEntryId( dn ); + Entry lookedup = partition.lookup( entryId ); // before modification: expect "person" tuple in objectClass index - assertTrue( store.getObjectClassIndex().reverse( entryId ) ); - assertTrue( store.getObjectClassIndex().forward( "person", entryId ) ); + assertTrue( partition.getObjectClassIndex().reverse( entryId ) ); + assertTrue( partition.getObjectClassIndex().forward( "person", entryId ) ); assertTrue( lookedup.get( "objectClass" ).contains( "person" ) ); - lookedup = store.modify( dn, add ); + lookedup = partition.modify( dn, add ); // after modification: no tuple in objectClass index - assertFalse( store.getObjectClassIndex().reverse( entryId ) ); - assertFalse( store.getObjectClassIndex().forward( "person", entryId ) ); + assertFalse( partition.getObjectClassIndex().reverse( entryId ) ); + assertFalse( partition.getObjectClassIndex().forward( "person", entryId ) ); assertNull( lookedup.get( "objectClass" ) ); } @@ -343,17 +342,17 @@ public class AbstractStoreTest Modification add = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, attrib ); - Long entryId = store.getEntryId( dn ); - Entry lookedup = store.lookup( entryId ); + Long entryId = partition.getEntryId( dn ); + Entry lookedup = partition.lookup( entryId ); assertNotSame( csn, lookedup.get( csnAt ).getString() ); - assertNotSame( csn, store.getEntryCsnIndex().reverseLookup( entryId ) ); + assertNotSame( csn, partition.getEntryCsnIndex().reverseLookup( entryId ) ); - lookedup = store.modify( dn, add ); + lookedup = partition.modify( dn, add ); String updateCsn = lookedup.get( csnAt ).getString(); assertEquals( csn, updateCsn ); - assertEquals( csn, store.getEntryCsnIndex().reverseLookup( entryId ) ); + assertEquals( csn, partition.getEntryCsnIndex().reverseLookup( entryId ) ); csn = csnF.newInstance().toString(); @@ -361,12 +360,12 @@ public class AbstractStoreTest modEntry.add( csnAt, csn ); assertNotSame( csn, updateCsn ); - assertNotSame( csn, store.getEntryCsnIndex().reverseLookup( entryId ) ); + assertNotSame( csn, partition.getEntryCsnIndex().reverseLookup( entryId ) ); - lookedup = store.modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, csnAt, csn ) ); + lookedup = partition.modify( dn, new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, csnAt, csn ) ); assertEquals( csn, lookedup.get( csnAt ).getString() ); - assertEquals( csn, store.getEntryCsnIndex().reverseLookup( entryId ) ); + assertEquals( csn, partition.getEntryCsnIndex().reverseLookup( entryId ) ); } @@ -381,13 +380,13 @@ public class AbstractStoreTest entry.add( "sn", "user sn" ); // add - StoreUtils.injectEntryInStore( store, entry ); + StoreUtils.injectEntryInStore( partition, entry ); verifyParentId( dn ); // move Dn newSuperior = new Dn( schemaManager, "o=Good Times Co." ); Dn newDn = new Dn( schemaManager, "cn=user,o=Good Times Co." ); - store.move( dn, newSuperior, newDn, null ); + partition.move( dn, newSuperior, newDn, null ); entry = verifyParentId( newDn ); // move and rename @@ -395,16 +394,16 @@ public class AbstractStoreTest Dn oldDn = newDn; Rdn newRdn = new Rdn( schemaManager, "cn=userMovedAndRenamed" ); - store.moveAndRename( oldDn, newParentDn, newRdn, entry, false ); + partition.moveAndRename( oldDn, newParentDn, newRdn, entry, false ); verifyParentId( newParentDn.add( newRdn ) ); } private Entry verifyParentId( Dn dn ) throws Exception { - Long entryId = store.getEntryId( dn ); - Entry entry = store.lookup( entryId ); - Long parentId = store.getParentId( entryId ); + Long entryId = partition.getEntryId( dn ); + Entry entry = partition.lookup( entryId ); + Long parentId = partition.getParentId( entryId ); Attribute parentIdAt = entry.get( SchemaConstants.ENTRY_PARENT_ID_AT ); assertNotNull( parentIdAt );