directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896599 [19/30] - in /directory/apacheds/trunk: ./ avl-partition/ avl-partition/src/ avl-partition/src/main/ avl-partition/src/main/java/ avl-partition/src/main/java/org/ avl-partition/src/main/java/org/apache/ avl-partition/src/main/java/o...
Date Wed, 06 Jan 2010 18:27:19 GMT
Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java Wed Jan  6 18:26:43 2010
@@ -20,24 +20,23 @@
 package org.apache.directory.server.core.schema;
 
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.File;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.CosineSchema;
-import org.apache.directory.server.schema.bootstrap.NisSchema;
-import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
-import org.apache.directory.server.schema.registries.DefaultRegistries;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.junit.Before;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
 
 
 /**
@@ -45,27 +44,47 @@
  */
 public class SchemaServiceTest
 {
-    private static DefaultRegistries registries;
+    private static SchemaManager schemaManager;
     
     
-    @Before
-    public void setUp() throws Exception
+    @BeforeClass
+    public static void setUp() throws Exception
     {
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        registries = new DefaultRegistries( "bootstrap", loader, new DefaultOidRegistry() );
-        loader.load( new SystemSchema(), registries, false );
-        loader.load( new ApacheSchema(), registries, false );
-        loader.load( new CoreSchema(), registries, false );
-        loader.load( new CosineSchema(), registries, false );
-        loader.load( new NisSchema(), registries, false );
+    	String workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = SchemaServiceTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        File schemaRepository = new File( workingDirectory, "schema" );
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+        extractor.extractOrCopy( true );
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
+
+        loaded = schemaManager.loadWithDeps( "nis" );
+        
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
     }
 
     
     @Test
     public void testDescendants() throws Exception
     {
-        AttributeTypeRegistry attrRegistry = registries.getAttributeTypeRegistry();
-        Iterator<AttributeType> list = attrRegistry.descendants( "name" );
+        Iterator<AttributeType> list = schemaManager.getAttributeTypeRegistry().descendants( "name" );
         Set<String> nameAttrs = new HashSet<String>();
         
         while ( list.hasNext() )
@@ -74,19 +93,37 @@
             nameAttrs.add( type.getName() );
         }
         
-        assertEquals( "size of attributes extending name", 15, nameAttrs.size() );
-        assertTrue( nameAttrs.contains( "dmdName" ) );
-        assertTrue( nameAttrs.contains( "o" ) );
-        assertTrue( nameAttrs.contains( "c" ) );
-        assertTrue( nameAttrs.contains( "initials" ) );
-        assertTrue( nameAttrs.contains( "ou" ) );
-        assertTrue( nameAttrs.contains( "sn" ) );
-        assertTrue( nameAttrs.contains( "title" ) );
-        assertTrue( nameAttrs.contains( "l" ) );
-        assertTrue( nameAttrs.contains( "apacheExistence" ) );
-        assertTrue( nameAttrs.contains( "cn" ) );
-        assertTrue( nameAttrs.contains( "st" ) );
-        assertTrue( nameAttrs.contains( "givenName" ) );
+        // We should only have 13 AT
+        String[] expectedNames = new String[]
+        {
+            "sn", 
+            "generationQualifier", 
+            "ou", 
+            "c", 
+            "o", 
+            "l", 
+            "c-st", 
+            "givenName", 
+            "title", 
+            "cn", 
+            "initials", 
+            "dmdName", 
+            "c-ou", 
+            "c-o", 
+            "apacheExistence", 
+            "st", 
+            "c-l"
+        };
+        
+        for ( String name : expectedNames )
+        {
+            if ( nameAttrs.contains( name) )
+            {
+                nameAttrs.remove( name );
+            }
+        }
+        
+        assertEquals( 0, nameAttrs.size() );
     }
 /*
     public void testAlterObjectClassesBogusAttr() throws NamingException

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/security/TlsKeyGeneratorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/security/TlsKeyGeneratorTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/security/TlsKeyGeneratorTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/security/TlsKeyGeneratorTest.java Wed Jan  6 18:26:43 2010
@@ -17,32 +17,26 @@
  *   under the License.
  *
  */
-
 package org.apache.directory.server.core.security;
 
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
+import java.io.File;
 import java.security.KeyPair;
 import java.security.cert.X509Certificate;
-import java.util.HashSet;
-import java.util.Set;
 
 import org.apache.directory.server.core.entry.DefaultServerEntry;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.ApachemetaSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.CosineSchema;
-import org.apache.directory.server.schema.bootstrap.InetorgpersonSchema;
-import org.apache.directory.server.schema.bootstrap.Schema;
-import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
-import org.apache.directory.server.schema.registries.DefaultRegistries;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.slf4j.Logger;
@@ -58,9 +52,8 @@
 public class TlsKeyGeneratorTest
 {
     private static final Logger LOG = LoggerFactory.getLogger( TlsKeyGeneratorTest.class );
-    private static BootstrapSchemaLoader loader;
-    private static Registries registries;
-    private static OidRegistry oidRegistry;
+    private static LdifSchemaLoader loader;
+    private static SchemaManager schemaManager;
     
 
     /**
@@ -69,20 +62,27 @@
     @BeforeClass
     public static void setup() throws Exception
     {
-        loader = new BootstrapSchemaLoader();
-        oidRegistry = new DefaultOidRegistry();
-        registries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
-        
-        // load essential bootstrap schemas 
-        Set<Schema> bootstrapSchemas = new HashSet<Schema>();
-        bootstrapSchemas.add( new ApachemetaSchema() );
-        bootstrapSchemas.add( new ApacheSchema() );
-        bootstrapSchemas.add( new CoreSchema() );
-        bootstrapSchemas.add( new SystemSchema() );
-        bootstrapSchemas.add( new InetorgpersonSchema() );
-        bootstrapSchemas.add( new CosineSchema() );
-        loader.loadWithDependencies( bootstrapSchemas, registries );
-        
+    	String workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = TlsKeyGeneratorTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        File schemaRepository = new File( workingDirectory, "schema" );
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+        extractor.extractOrCopy( true );
+        loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
     }
     
     
@@ -92,7 +92,7 @@
     @Test
     public void testAll() throws Exception
     {
-        DefaultServerEntry entry = new DefaultServerEntry( registries, new LdapDN() );
+        DefaultServerEntry entry = new DefaultServerEntry( schemaManager, new LdapDN() );
         TlsKeyGenerator.addKeyPair( entry );
         LOG.debug( "Entry: {}", entry );
         assertTrue( entry.contains( SchemaConstants.OBJECT_CLASS_AT, TlsKeyGenerator.TLS_KEY_INFO_OC ) );

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcUtilsTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcUtilsTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcUtilsTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/sp/StoredProcUtilsTest.java Wed Jan  6 18:26:43 2010
@@ -21,11 +21,12 @@
 
 package org.apache.directory.server.core.sp;
 
-import junit.framework.TestCase;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
 
-public class StoredProcUtilsTest extends TestCase
+public class StoredProcUtilsTest
 {
-
+    @Test
     public void testSPNameTokenization()
     {
         String fullSPName = "Greeter:seyHello";

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=896599&r1=896598&r2=896599&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 Wed Jan  6 18:26:43 2010
@@ -19,32 +19,29 @@
  */
 package org.apache.directory.server.core.subtree;
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
-import javax.naming.NamingException;
-
-import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.ServerAttribute;
-import org.apache.directory.server.core.subtree.RefinementEvaluator;
-import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.NotNode;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-import static org.junit.Assert.fail;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
 
 /**
  * Unit test cases for testing the evaluator for refinements.
@@ -65,19 +62,27 @@
 
     /** The CN AttributeType */
     private static AttributeType CN;
-
-    /** A reference to the directory service */
-    private static DirectoryService service;
-
+    
     
     /**
      * Initializes the global registries.
      * @throws javax.naming.NamingException if there is a failure loading the schema
      */
-    @BeforeClass public static void init() throws NamingException
+    @BeforeClass 
+    public static void init() throws Exception
     {
-        service = new DefaultDirectoryService();
-        registries = service.getRegistries();
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+
+        SchemaManager sm = new DefaultSchemaManager( loader );
+
+        boolean loaded = sm.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( sm.getErrors() ) );
+        }
+
+        registries = sm.getRegistries();
     }
 
 
@@ -87,7 +92,7 @@
      */
     @Before public void setUp() throws Exception
     {
-        OidRegistry registry = registries.getOidRegistry();
+        OidRegistry registry = registries.getGlobalOidRegistry();
         RefinementLeafEvaluator leafEvaluator = new RefinementLeafEvaluator( registry );
         evaluator = new RefinementEvaluator( leafEvaluator );
         

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java Wed Jan  6 18:26:43 2010
@@ -20,26 +20,28 @@
 package org.apache.directory.server.core.subtree;
 
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
 import javax.naming.NamingException;
 
-import org.apache.directory.server.core.DefaultDirectoryService;
-import org.apache.directory.server.core.DirectoryService;
 import org.apache.directory.server.core.entry.DefaultServerAttribute;
 import org.apache.directory.server.core.entry.ServerAttribute;
-import org.apache.directory.server.core.subtree.RefinementLeafEvaluator;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.filter.EqualityNode;
 import org.apache.directory.shared.ldap.filter.GreaterEqNode;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.loader.ldif.JarLdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 
 /**
@@ -52,9 +54,6 @@
 {
     /** The ObjectClass AttributeType */
     private static AttributeType OBJECT_CLASS;
-
-    /** A reference to the directory service */
-    private static DirectoryService service;
     
     /** the registries */
     private static Registries registries;
@@ -67,21 +66,34 @@
      * Initializes the global registries.
      * @throws javax.naming.NamingException if there is a failure loading the schema
      */
-    @BeforeClass public static void init() throws NamingException
+    @BeforeClass 
+    public static void init() throws Exception
     {
-        service = new DefaultDirectoryService();
-        registries = service.getRegistries();
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+
+        SchemaManager sm = new DefaultSchemaManager( loader );
+
+        boolean loaded = sm.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( sm.getErrors() ) );
+        }
+
+        registries = sm.getRegistries();
+        
         OBJECT_CLASS = registries.getAttributeTypeRegistry().lookup( "objectClass" );
     }
     
 
     /**
-     * Initializes registries and creates the leaf evalutator
+     * Initializes registries and creates the leaf evaluator
      * @throws Exception if there are schema initialization problems
      */
-    @Before public void setUp() throws Exception
+    @Before 
+    public void setUp() throws Exception
     {
-        OidRegistry registry = registries.getOidRegistry();
+        OidRegistry registry = registries.getGlobalOidRegistry();
         evaluator = new RefinementLeafEvaluator( registry );
     }
 

Modified: directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java (original)
+++ directory/apacheds/trunk/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java Wed Jan  6 18:26:43 2010
@@ -20,80 +20,99 @@
 package org.apache.directory.server.core.subtree;
 
 
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
 import java.util.HashSet;
 import java.util.Set;
 
-import junit.framework.TestCase;
-
 import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.normalization.FilterNormalizingVisitor;
-import org.apache.directory.server.schema.ConcreteNameComponentNormalizer;
-import org.apache.directory.server.schema.bootstrap.ApacheSchema;
-import org.apache.directory.server.schema.bootstrap.BootstrapSchemaLoader;
-import org.apache.directory.server.schema.bootstrap.CoreSchema;
-import org.apache.directory.server.schema.bootstrap.Schema;
-import org.apache.directory.server.schema.bootstrap.SystemSchema;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.DefaultOidRegistry;
-import org.apache.directory.server.schema.registries.DefaultRegistries;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.name.LdapDN;
-import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.impl.DefaultSchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.loader.ldif.LdifSchemaLoader;
+import org.apache.directory.shared.ldap.schema.manager.impl.DefaultSchemaManager;
+import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecification;
 import org.apache.directory.shared.ldap.subtree.SubtreeSpecificationModifier;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.junit.After;
 import org.junit.AfterClass;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
 
+
 /**
  * Unit test cases for the SubtreeEvaluator.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class SubtreeEvaluatorTest extends TestCase
+public class SubtreeEvaluatorTest
 {
-    private Registries registries;
+    private static SchemaManager schemaManager;
     private SubtreeEvaluator evaluator;
     FilterNormalizingVisitor visitor;
-    AttributeTypeRegistry attributeRegistry;
-
+    static ConcreteNameComponentNormalizer ncn;
 
-    private void init() throws Exception
+    @BeforeClass
+    public static void init() throws Exception
     {
-        BootstrapSchemaLoader loader = new BootstrapSchemaLoader();
-        OidRegistry oidRegistry = new DefaultOidRegistry();
-        DefaultRegistries bsRegistries = new DefaultRegistries( "bootstrap", loader, oidRegistry );
-        registries = bsRegistries;
-        Set<Schema> schemas = new HashSet<Schema>();
-        schemas.add( new SystemSchema() );
-        schemas.add( new ApacheSchema() );
-        schemas.add( new CoreSchema() );
-        loader.loadWithDependencies( schemas, bsRegistries );
-        attributeRegistry = registries.getAttributeTypeRegistry();
-        
-        NameComponentNormalizer ncn = new ConcreteNameComponentNormalizer( attributeRegistry, oidRegistry );
-        visitor = new FilterNormalizingVisitor( ncn, registries );
+    	String workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = SubtreeEvaluatorTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        File schemaRepository = new File( workingDirectory, "schema" );
+        SchemaLdifExtractor extractor = new DefaultSchemaLdifExtractor( new File( workingDirectory ) );
+        extractor.extractOrCopy( true );
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        schemaManager = new DefaultSchemaManager( loader );
+
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
+        }
+
+        ncn = new ConcreteNameComponentNormalizer( schemaManager );
     }
 
-    @BeforeClass
-    protected void setUp() throws Exception
+    
+    @Before
+    public void initTest()
     {
-        init();
-        evaluator = new SubtreeEvaluator( registries.getOidRegistry(), registries.getAttributeTypeRegistry() );
+        visitor = new FilterNormalizingVisitor( ncn, schemaManager );
+        evaluator = new SubtreeEvaluator( schemaManager.getGlobalOidRegistry(), schemaManager );
     }
 
 
-    @AfterClass
-    protected void tearDown() throws Exception
+    @After
+    public void destroyTest()
     {
+        visitor = null;
         evaluator = null;
-        registries = null;
+    }
+
+    
+    @AfterClass
+    public static void tearDown() throws Exception
+    {
+        schemaManager = null;
     }
 
 
@@ -104,7 +123,7 @@
         SubtreeSpecification ss = modifier.getSubtreeSpecification();
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
-        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );
+        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn, "objectClass" );
 
         assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );
 
@@ -124,7 +143,7 @@
         SubtreeSpecification ss = modifier.getSubtreeSpecification();
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
-        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );
+        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn, "objectClass" );
 
         assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );
 
@@ -146,7 +165,7 @@
         SubtreeSpecification ss = modifier.getSubtreeSpecification();
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
-        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );
+        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn, "objectClass" );
 
         assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
 
@@ -181,7 +200,7 @@
         SubtreeSpecification ss = modifier.getSubtreeSpecification();
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
-        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );
+        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn, "objectClass" );
 
         assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
 
@@ -216,7 +235,7 @@
         SubtreeSpecification ss = modifier.getSubtreeSpecification();
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
-        ServerEntry entry = new DefaultServerEntry( registries, entryDn, "objectClass" );
+        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn, "objectClass" );
 
         assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
 
@@ -251,7 +270,7 @@
         SubtreeSpecification ss = modifier.getSubtreeSpecification();
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
-        ServerEntry entry = new DefaultServerEntry( registries, entryDn );
+        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn );
         entry.put( "objectClass", "person" );
 
         assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
@@ -272,7 +291,7 @@
         assertFalse( evaluator.evaluate( ss, apDn, entryDn, entry ) );
 
         // now change the refinement so the entry is rejected
-        entry = new DefaultServerEntry( registries, entryDn );
+        entry = new DefaultServerEntry( schemaManager, entryDn );
         entry.put( "objectClass", "organizationalUnit" );
         
 
@@ -311,7 +330,7 @@
         LdapDN apDn = new LdapDN( "ou=system" );
         LdapDN entryDn = new LdapDN( "ou=users,ou=system" );
 
-        ServerEntry entry = new DefaultServerEntry( registries, entryDn );;
+        ServerEntry entry = new DefaultServerEntry( schemaManager, entryDn );;
         entry.put( "objectClass", "person" );
         entry.put( "cn", "Ersin" );
 
@@ -321,7 +340,7 @@
         assertTrue( evaluator.evaluate( ss, apDn, entryDn, entry ) );
 
         // now change the filter so the entry is rejected
-        entry = new DefaultServerEntry( registries, entryDn );;
+        entry = new DefaultServerEntry( schemaManager, entryDn );;
         entry.put( "objectClass", "person" );
         entry.put( "cn", "Alex" );
 

Modified: directory/apacheds/trunk/core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/test/resources/log4j.properties?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/core/src/test/resources/log4j.properties (original)
+++ directory/apacheds/trunk/core/src/test/resources/log4j.properties Wed Jan  6 18:26:43 2010
@@ -14,7 +14,7 @@
 #    See the License for the specific language governing permissions and
 #    limitations under the License.
 #############################################################################
-log4j.rootCategory=ERROR, stdout
+log4j.rootCategory=OFF, stdout
 
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

Propchange: directory/apacheds/trunk/http-integration/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Wed Jan  6 18:26:43 2010
@@ -1,4 +1,17 @@
-.classpath
-.project
 target
+.clover
+.wtpmodules
 .settings
+.deployables
+apache.org
+.metadata
+*.md5
+*.log
+*.iml
+*.ipr
+*.iws
+.project
+.classpath
+nbproject
+schema
+

Modified: directory/apacheds/trunk/interceptor-kerberos/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptor-kerberos/pom.xml?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptor-kerberos/pom.xml (original)
+++ directory/apacheds/trunk/interceptor-kerberos/pom.xml Wed Jan  6 18:26:43 2010
@@ -49,13 +49,6 @@
 
     <dependency>
       <groupId>org.apache.directory.server</groupId>
-      <artifactId>apacheds-bootstrap-partition</artifactId>
-      <version>${pom.version}</version>
-      <scope>test</scope>
-    </dependency>
-
-    <dependency>
-      <groupId>org.apache.directory.server</groupId>
       <artifactId>apacheds-kerberos-shared</artifactId>
       <version>${pom.version}</version>
     </dependency>

Modified: directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java (original)
+++ directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/KeyDerivationInterceptor.java Wed Jan  6 18:26:43 2010
@@ -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;
@@ -62,8 +64,6 @@
 import org.apache.directory.server.kerberos.shared.io.encoder.EncryptionKeyEncoder;
 import org.apache.directory.server.kerberos.shared.messages.value.EncryptionKey;
 import org.apache.directory.server.kerberos.shared.store.KerberosAttribute;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
@@ -71,6 +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.SchemaManager;
 import org.apache.directory.shared.ldap.util.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -133,7 +134,7 @@
         if ( ( entry.get( SchemaConstants.USER_PASSWORD_AT ) != null ) && 
             ( entry.get( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ) != null ) )
         {
-            log.debug( "Adding the entry '{}' for DN '{}'.", entry, normName.getUpName() );
+            log.debug( "Adding the entry '{}' for DN '{}'.", entry, normName.getName() );
 
             ServerBinaryValue userPassword = (ServerBinaryValue)entry.get( SchemaConstants.USER_PASSWORD_AT ).get();
             String strUserPassword = userPassword.getString();
@@ -158,10 +159,10 @@
             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() );
+                .getName() );
         }
 
         next.add( addContext );
@@ -311,7 +312,7 @@
         else
         {
             subContext.isPrincipal( true );
-            log.debug( "DN {} is a Kerberos principal.  Will attempt key derivation.", principalDn.getUpName() );
+            log.debug( "DN {} is a Kerberos principal.  Will attempt key derivation.", principalDn.getName() );
         }
 
         if ( subContext.getPrincipalName() == null )
@@ -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<EncryptionType, EncryptionKey> keys ) throws Exception
+    private ServerAttribute getKeyAttribute( SchemaManager schemaManager, Map<EncryptionType, EncryptionKey> 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<EncryptionKey> it = keys.values().iterator();
 

Modified: directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/PasswordPolicyInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/PasswordPolicyInterceptor.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/PasswordPolicyInterceptor.java (original)
+++ directory/apacheds/trunk/interceptor-kerberos/src/main/java/org/apache/directory/server/core/kerberos/PasswordPolicyInterceptor.java Wed Jan  6 18:26:43 2010
@@ -71,7 +71,7 @@
 
         ServerEntry entry = addContext.getEntry();
 
-        log.debug( "Adding the entry '{}' for DN '{}'.", entry, normName.getUpName() );
+        log.debug( "Adding the entry '{}' for DN '{}'.", entry, normName.getName() );
 
         if ( entry.get( SchemaConstants.USER_PASSWORD_AT ) != null )
         {
@@ -170,13 +170,13 @@
                     }
 
                     // if userPassword fails checks, throw new NamingException.
-                    check( name.getUpName(), pwd );
+                    check( name.getName(), pwd );
                 }
             }
 
             if ( log.isDebugEnabled() )
             {
-                log.debug( operation + " for entry '" + name.getUpName() + "' the attribute " + mod.getAttribute() );
+                log.debug( operation + " for entry '" + name.getName() + "' the attribute " + mod.getAttribute() );
             }
         }
 

Propchange: directory/apacheds/trunk/jdbm-partition/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jan  6 18:26:43 2010
@@ -0,0 +1,16 @@
+target
+.clover
+.wtpmodules
+.settings
+.deployables
+apache.org
+.metadata
+*.md5
+*.log
+*.iml
+*.ipr
+*.iws
+.project
+.classpath
+nbproject
+schema

Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan  6 18:26:43 2010
@@ -0,0 +1,3 @@
+/directory/apacheds/branches/apacheds-replication/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:749790-764110
+/directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:806623-896441
+/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/partition/tree:806623-894866*

Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan  6 18:26:43 2010
@@ -0,0 +1,3 @@
+/directory/apacheds/branches/apacheds-replication/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:749790-764110
+/directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:806623-896441
+/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema:806623-894866*

Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Wed Jan  6 18:26:43 2010
@@ -0,0 +1,3 @@
+/directory/apacheds/branches/apacheds-replication/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:749790-764110
+/directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:806623-896441
+/directory/apacheds/trunk/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java:806623-894866

Modified: directory/apacheds/trunk/jdbm-store/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/pom.xml?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/pom.xml (original)
+++ directory/apacheds/trunk/jdbm-store/pom.xml Wed Jan  6 18:26:43 2010
@@ -85,15 +85,16 @@
     </dependency>
 
     <dependency>
-      <groupId>${pom.groupId}</groupId>
-      <artifactId>apacheds-schema-registries</artifactId>
-      <version>${pom.version}</version>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
+      <scope>test</scope>
     </dependency>
 
     <dependency>
-      <groupId>${pom.groupId}</groupId>
-      <artifactId>apacheds-schema-bootstrap</artifactId>
-      <version>${pom.version}</version>
+      <groupId>org.apache.directory.shared</groupId>
+      <artifactId>shared-ldap-schema-manager</artifactId>
+      <version>${org.apache.directory.shared.version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndex.java Wed Jan  6 18:26:43 2010
@@ -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;
@@ -27,22 +32,19 @@
 
 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.schema.SerializableComparator;
 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 javax.naming.NamingException;
-import java.io.File;
-import java.io.IOException;
-
 
 /** 
  * A Jdbm based index implementation.
@@ -114,7 +116,7 @@
     /** whether or not this index has been initialized */
     protected boolean initialized;
     
-    /** a customm working directory path when specified in configuration */
+    /** a custom working directory path when specified in configuration */
     protected File wkDirPath;
 
 
@@ -153,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() );
         
@@ -178,7 +180,7 @@
 
         try
         {
-            initTables();
+            initTables( schemaManager );
         }
         catch ( IOException e )
         {
@@ -196,30 +198,31 @@
      * 
      * @throws IOException if we cannot initialize the forward and reverse
      * tables
+     * @throws NamingException 
      */
-    private void initTables() throws IOException
+    private void initTables( SchemaManager schemaManager ) throws IOException
     {
         SerializableComparator<K> comp;
 
-        try
+        MatchingRule mr = attribute.getEquality();
+        
+        if ( mr == null )
         {
-            MatchingRule mr = attribute.getEquality();
-            
-            comp = new SerializableComparator<K>( mr.getOid() );
-        }
-        catch ( NamingException e )
-        {
-            IOException ioe = new IOException( "Failed to find an equality matching rule for attribute type" );
-            ioe.initCause( e );
-            throw ioe;
+            throw new IOException( "No Equality MatchingRule available for attribute " + attribute.getName() );
         }
+        
+        comp = new SerializableComparator<K>( mr.getOid() );
 
         /*
          * The forward key/value map stores attribute values to master table 
          * 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<K, Long>(
+            schemaManager,
             attribute.getName() + FORWARD_BTREE, 
             numDupLimit,
             recMan, 
@@ -232,9 +235,10 @@
          * is single valued according to its specification based on a schema 
          * then duplicate keys should not be allowed within the reverse table.
          */
-        if ( attribute.isSingleValue() )
+        if ( attribute.isSingleValued() )
         {
             reverse = new JdbmTable<Long,K>(
+                schemaManager,
                 attribute.getName() + REVERSE_BTREE,
                 recMan,
                 LongComparator.INSTANCE,
@@ -244,6 +248,7 @@
         else
         {
             reverse = new JdbmTable<Long,K>(
+                schemaManager,
                 attribute.getName() + REVERSE_BTREE,
                 numDupLimit,
                 recMan,

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTable.java Wed Jan  6 18:26:43 2010
@@ -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.schema.SerializableComparator;
-import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.xdbm.MasterTable;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
 
 
 /**
@@ -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<String,String>( "admin", recMan, STRING_COMPARATOR, null, null );
+        super( schemaManager, DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, new ServerEntrySerializer( schemaManager ) );
+        adminTbl = new JdbmTable<String,String>( 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<String,String>( dbName, recMan, STRING_COMPARATOR, null, null );
+        super( schemaManager, DBF, recMan, LONG_COMPARATOR, LongSerializer.INSTANCE, serializer );
+        adminTbl = new JdbmTable<String,String>( schemaManager, dbName, recMan, STRING_COMPARATOR, null, null );
         String seqValue = adminTbl.get( SEQPROP_KEY );
 
         if ( null == seqValue )

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java Wed Jan  6 18:26:43 2010
@@ -39,12 +39,7 @@
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.entry.ServerAttribute;
-import org.apache.directory.server.core.entry.ServerBinaryValue;
 import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.ServerStringValue;
-import org.apache.directory.server.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.server.schema.registries.OidRegistry;
-import org.apache.directory.server.schema.registries.Registries;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
@@ -61,11 +56,12 @@
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
-import org.apache.directory.shared.ldap.name.AttributeTypeAndValue;
+import org.apache.directory.shared.ldap.name.AVA;
 import org.apache.directory.shared.ldap.name.LdapDN;
 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.SchemaManager;
 import org.apache.directory.shared.ldap.util.NamespaceTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -145,11 +141,8 @@
     private static AttributeType ENTRY_UUID_AT;
     private static AttributeType ALIASED_OBJECT_NAME_AT;
 
-    /** A pointer on the AT registry */
-    private AttributeTypeRegistry attributeTypeRegistry;
-
-    /** A pointer on the OID registry */
-    private OidRegistry oidRegistry;
+    /** A pointer on the schemaManager */
+    private SchemaManager schemaManager;
 
     private String suffixDn;
     private int cacheSize = DEFAULT_CACHE_SIZE;
@@ -251,22 +244,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.oidRegistry = registries.getOidRegistry();
-        this.attributeTypeRegistry = registries.getAttributeTypeRegistry();
+        this.schemaManager = schemaManager;
 
         // Initialize Attribute types used all over this method
-        OBJECT_CLASS_AT = attributeTypeRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT );
-        ALIASED_OBJECT_NAME_AT = attributeTypeRegistry.lookup( SchemaConstants.ALIASED_OBJECT_NAME_AT );
-        ENTRY_CSN_AT = attributeTypeRegistry.lookup( SchemaConstants.ENTRY_CSN_AT );
-        ENTRY_UUID_AT = attributeTypeRegistry.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, attributeTypeRegistry.getNormalizerMapping() );
+        this.normSuffix = LdapDN.normalize( upSuffix, schemaManager.getNormalizerMapping() );
         workingDirectory.mkdirs();
 
         // First, check if the file storing the data exists
@@ -288,7 +280,7 @@
         recMan = new CacheRecordManager( base, new MRU( cacheSize ) );
 
         // Create the master table (the table containing all the entries)
-        master = new JdbmMasterTable<ServerEntry>( recMan, registries );
+        master = new JdbmMasterTable<ServerEntry>( recMan, schemaManager );
 
         // -------------------------------------------------------------------
         // Initializes the user and system indices
@@ -311,9 +303,9 @@
             
             for ( Index<?,E> index : systemIndices.values() )
             {
-                String oid = oidRegistry.getOid( index.getAttributeId() );
+                String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
                 tmp.put( oid, index );
-                ( ( JdbmIndex ) index ).init( attributeTypeRegistry.lookup( oid ), workingDirectory );
+                ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ), workingDirectory );
             }
             systemIndices = tmp;
         }
@@ -323,7 +315,7 @@
             ndnIdx = new JdbmIndex<String,E>();
             ndnIdx.setAttributeId( ApacheSchemaConstants.APACHE_N_DN_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_N_DN_AT_OID, ndnIdx );
-            ndnIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_N_DN_AT_OID ), workingDirectory );
+            ndnIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_N_DN_AT_OID ), workingDirectory );
         }
 
         if ( updnIdx == null )
@@ -331,7 +323,7 @@
             updnIdx = new JdbmIndex<String,E>();
             updnIdx.setAttributeId( ApacheSchemaConstants.APACHE_UP_DN_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_UP_DN_AT_OID, updnIdx );
-            updnIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ), workingDirectory );
+            updnIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_UP_DN_AT_OID ), workingDirectory );
         }
 
         if ( presenceIdx == null )
@@ -339,7 +331,7 @@
             presenceIdx = new JdbmIndex<String,E>();
             presenceIdx.setAttributeId( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID, presenceIdx );
-            presenceIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), workingDirectory );
+            presenceIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_EXISTENCE_AT_OID ), workingDirectory );
         }
 
         if ( oneLevelIdx == null )
@@ -347,7 +339,7 @@
             oneLevelIdx = new JdbmIndex<Long,E>();
             oneLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID, oneLevelIdx );
-            oneLevelIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ), workingDirectory );
+            oneLevelIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_LEVEL_AT_OID ), workingDirectory );
         }
 
         if ( oneAliasIdx == null )
@@ -355,7 +347,7 @@
             oneAliasIdx = new JdbmIndex<Long,E>();
             oneAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID, oneAliasIdx );
-            oneAliasIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ), workingDirectory );
+            oneAliasIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ONE_ALIAS_AT_OID ), workingDirectory );
         }
 
         if ( subAliasIdx == null )
@@ -363,7 +355,7 @@
             subAliasIdx = new JdbmIndex<Long,E>();
             subAliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID, subAliasIdx );
-            subAliasIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ), workingDirectory );
+            subAliasIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_ALIAS_AT_OID ), workingDirectory );
         }
 
         if ( aliasIdx == null )
@@ -371,7 +363,7 @@
             aliasIdx = new JdbmIndex<String,E>();
             aliasIdx.setAttributeId( ApacheSchemaConstants.APACHE_ALIAS_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_ALIAS_AT_OID, aliasIdx );
-            aliasIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ), workingDirectory );
+            aliasIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_ALIAS_AT_OID ), workingDirectory );
         }
         
         if ( subLevelIdx == null )
@@ -379,7 +371,7 @@
             subLevelIdx = new JdbmIndex<Long, E>();
             subLevelIdx.setAttributeId( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID );
             systemIndices.put( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID, subLevelIdx );
-            subLevelIdx.init( attributeTypeRegistry.lookup( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ), workingDirectory );
+            subLevelIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( ApacheSchemaConstants.APACHE_SUB_LEVEL_AT_OID ), workingDirectory );
         }
         
         if ( entryCsnIdx == null )
@@ -387,7 +379,7 @@
             entryCsnIdx = new JdbmIndex<String, E>();
             entryCsnIdx.setAttributeId( SchemaConstants.ENTRY_CSN_AT_OID );
             systemIndices.put( SchemaConstants.ENTRY_CSN_AT_OID, entryCsnIdx );
-            entryCsnIdx.init( attributeTypeRegistry.lookup( SchemaConstants.ENTRY_CSN_AT_OID ), workingDirectory );
+            entryCsnIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_CSN_AT_OID ), workingDirectory );
         }
         
         if ( entryUuidIdx == null )
@@ -395,7 +387,7 @@
             entryUuidIdx = new JdbmIndex<byte[], E>();
             entryUuidIdx.setAttributeId( SchemaConstants.ENTRY_UUID_AT_OID );
             systemIndices.put( SchemaConstants.ENTRY_UUID_AT_OID, entryUuidIdx );
-            entryUuidIdx.init( attributeTypeRegistry.lookup( SchemaConstants.ENTRY_UUID_AT_OID ), workingDirectory );
+            entryUuidIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ENTRY_UUID_AT_OID ), workingDirectory );
         }
         
         if ( objectClassIdx == null )
@@ -403,7 +395,7 @@
             objectClassIdx = new JdbmIndex<String, E>();
             objectClassIdx.setAttributeId( SchemaConstants.OBJECT_CLASS_AT_OID );
             systemIndices.put( SchemaConstants.OBJECT_CLASS_AT_OID, objectClassIdx );
-            objectClassIdx.init( attributeTypeRegistry.lookup( SchemaConstants.OBJECT_CLASS_AT_OID ), workingDirectory );
+            objectClassIdx.init( schemaManager, schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT_OID ), workingDirectory );
         }
     }
 
@@ -417,7 +409,7 @@
             
             for ( Index<?,E> index : userIndices.values() )
             {
-                String oid = oidRegistry.getOid( index.getAttributeId() );
+                String oid = schemaManager.getAttributeTypeRegistry().getOidByName( index.getAttributeId() );
 
                 if ( systemIndices.containsKey( oid ) )
                 {
@@ -425,14 +417,14 @@
                     // present in the SystemIndices
                     continue;
                 }
-                AttributeType attributeType = attributeTypeRegistry.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( attributeTypeRegistry.lookup( oid ), workingDirectory );
+                    ( ( JdbmIndex ) index ).init( schemaManager, schemaManager.lookupAttributeTypeRegistry( oid ), workingDirectory );
                     tmp.put( oid, index );
                 }
                 else
@@ -845,13 +837,13 @@
 
     public boolean hasUserIndexOn( String id ) throws NamingException
     {
-        return userIndices.containsKey( oidRegistry.getOid( id ) );
+        return userIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) );
     }
 
 
     public boolean hasSystemIndexOn( String id ) throws NamingException
     {
-        return systemIndices.containsKey( oidRegistry.getOid( id ) );
+        return systemIndices.containsKey( schemaManager.getAttributeTypeRegistry().getOidByName( id ) );
     }
 
 
@@ -859,7 +851,7 @@
     {
         try
         {
-            id = oidRegistry.getOid( id );
+            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
         }
         catch ( NamingException e )
         {
@@ -881,7 +873,7 @@
     {
         try
         {
-            id = oidRegistry.getOid( id );
+            id = schemaManager.getAttributeTypeRegistry().getOidByName( id );
         }
         catch ( NamingException e )
         {
@@ -1021,7 +1013,7 @@
 
         // Access aliasedObjectName, normalize it and generate the Name 
         normalizedAliasTargetDn = new LdapDN( aliasTarget );
-        normalizedAliasTargetDn.normalize( attributeTypeRegistry.getNormalizerMapping() );
+        normalizedAliasTargetDn.normalize( schemaManager.getNormalizerMapping() );
 
         /*
          * Check For Cycles
@@ -1064,7 +1056,7 @@
         if ( !normalizedAliasTargetDn.startsWith( normSuffix ) )
         {
             String msg = "[36] aliasDereferencingProblem - "
-                + " the alias points to an entry outside of the " + upSuffix.getUpName()
+                + " the alias points to an entry outside of the " + upSuffix.getName()
                 + " namingContext to an object whose existence cannot be determined.";
             ResultCodeEnum rc = ResultCodeEnum.ALIAS_DEREFERENCING_PROBLEM;
             LdapNamingException e = new LdapNamingException( msg, rc );
@@ -1085,7 +1077,7 @@
         {
             // Complain about target not existing
             String msg = "[33] aliasProblem - "
-                + "the alias '" + aliasDn.getUpName() + "' when dereferenced would not name a known object."
+                + "the alias '" + aliasDn.getName() + "' when dereferenced would not name a known object."
                 + "The aliased ObjectName '" + aliasTarget + "' must be set to a valid existing entry.";
             ResultCodeEnum rc = ResultCodeEnum.ALIAS_PROBLEM;
             LdapNamingException e = new LdapNamingException( msg, rc );
@@ -1204,7 +1196,7 @@
 
         if ( objectClass == null )
         {
-            String msg = "Entry " + entryDn.getUpName() + " contains no objectClass attribute: " + entry;
+            String msg = "Entry " + entryDn.getName() + " contains no objectClass attribute: " + entry;
             ResultCodeEnum rc = ResultCodeEnum.OBJECT_CLASS_VIOLATION;
             NamingException e = new LdapSchemaViolationException( msg, rc );
             e.setResolvedName( entryDn );
@@ -1232,7 +1224,7 @@
         }
 
         ndnIdx.add( entryDn.toNormName(), id );
-        updnIdx.add( entryDn.getUpName(), id );
+        updnIdx.add( entryDn.getName(), id );
         oneLevelIdx.add( parentId, id );
 
         // Update the EntryCsn index
@@ -1240,7 +1232,7 @@
 
         if ( entryCsn == null )
         {
-            String msg = "Entry " + entryDn.getUpName() + " contains no entryCsn attribute: " + entry;
+            String msg = "Entry " + entryDn.getName() + " contains no entryCsn attribute: " + entry;
             throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
         }
         
@@ -1251,7 +1243,7 @@
 
         if ( entryUuid == null )
         {
-            String msg = "Entry " + entryDn.getUpName() + " contains no entryUuid attribute: " + entry;
+            String msg = "Entry " + entryDn.getName() + " contains no entryUuid attribute: " + entry;
             throw new LdapSchemaViolationException( msg, ResultCodeEnum.OBJECT_CLASS_VIOLATION );
         }
         
@@ -1433,7 +1425,7 @@
             throw new Exception( "Cannot store a ClonedServerEntry" );
         }
         
-        String modsOid = oidRegistry.getOid( mods.getId() );
+        String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() );
 
         // Special case for the ObjectClass index
         if ( modsOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
@@ -1460,7 +1452,7 @@
         }
 
         // add all the values in mods to the same attribute in the entry
-        AttributeType type = attributeTypeRegistry.lookup( modsOid );
+        AttributeType type = schemaManager.lookupAttributeTypeRegistry( modsOid );
 
         for ( Value<?> value : mods )
         {
@@ -1496,7 +1488,7 @@
             throw new Exception( "Cannot store a ClonedServerEntry" );
         }
         
-        String modsOid = oidRegistry.getOid( mods.getId() );
+        String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() );
         
         // Special case for the ObjectClass index
         if ( modsOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
@@ -1525,7 +1517,7 @@
             }
         }
 
-        AttributeType attrType = attributeTypeRegistry.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
@@ -1590,7 +1582,7 @@
             throw new Exception( "Cannot store a ClonedServerEntry" );
         }
         
-        String modsOid = oidRegistry.getOid( mods.getId() );
+        String modsOid = schemaManager.getAttributeTypeRegistry().getOidByName( mods.getId() );
 
         // Special case for the ObjectClass index
         if ( modsOid.equals( SchemaConstants.OBJECT_CLASS_AT_OID ) )
@@ -1633,7 +1625,7 @@
             }
         }
 
-        String aliasAttributeOid = oidRegistry.getOid( SchemaConstants.ALIASED_OBJECT_NAME_AT );
+        String aliasAttributeOid = schemaManager.getAttributeTypeRegistry().getOidByName( SchemaConstants.ALIASED_OBJECT_NAME_AT );
 
         if ( modsOid.equals( aliasAttributeOid ) )
         {
@@ -1771,28 +1763,13 @@
          * new Rdn attribute within this entry.
          */
 
-        for ( AttributeTypeAndValue newAtav : newRdn )
+        for ( AVA newAtav : newRdn )
         {
             String newNormType = newAtav.getNormType();
-            String newNormValue = newAtav.getNormValue().getString();
-            AttributeType newRdnAttrType = attributeTypeRegistry.lookup( newNormType );
-            
-            Object unEscapedRdn = Rdn.unescapeValue( newAtav.getUpValue().getString() );
-            
-            Value<?> value = null;
-            
-            if ( unEscapedRdn instanceof String )
-            {
-                value = new ServerStringValue( newRdnAttrType, (String)unEscapedRdn );
-            }
-            else
-            {
-                value = new ServerBinaryValue( newRdnAttrType, (byte[])unEscapedRdn );
-            }
+            Object newNormValue = newAtav.getNormValue().get();
+            AttributeType newRdnAttrType = schemaManager.lookupAttributeTypeRegistry( newNormType );
             
-            value.normalize();
-            
-            entry.add( newRdnAttrType, value );
+            entry.add( newRdnAttrType, newAtav.getUpValue() );
 
             if ( hasUserIndexOn( newNormType ) )
             {
@@ -1827,12 +1804,12 @@
         if ( deleteOldRdn )
         {
             Rdn oldRdn = updn.getRdn();
-            for ( AttributeTypeAndValue oldAtav : oldRdn )
+            for ( AVA oldAtav : oldRdn )
             {
                 // check if the new ATAV is part of the old Rdn
                 // if that is the case we do not remove the ATAV
                 boolean mustRemove = true;
-                for ( AttributeTypeAndValue newAtav : newRdn )
+                for ( AVA newAtav : newRdn )
                 {
                     if ( oldAtav.equals( newAtav ) )
                     {
@@ -1845,7 +1822,7 @@
                 {
                     String oldNormType = oldAtav.getNormType();
                     String oldNormValue = oldAtav.getNormValue().getString();
-                    AttributeType oldRdnAttrType = attributeTypeRegistry.lookup( oldNormType );
+                    AttributeType oldRdnAttrType = schemaManager.lookupAttributeTypeRegistry( oldNormType );
                     entry.remove( oldRdnAttrType, oldNormValue );
 
                     if ( hasUserIndexOn( oldNormType ) )
@@ -1882,7 +1859,7 @@
         newUpdn.add( newRdn.getUpName() ); // add da new upRdn
 
         // gotta normalize cuz this thang is cloned and not normalized by default
-        newUpdn.normalize( attributeTypeRegistry.getNormalizerMapping() );
+        newUpdn.normalize( schemaManager.getNormalizerMapping() );
 
         modifyDn( id, newUpdn, false ); // propagate dn changes
 
@@ -1923,14 +1900,14 @@
         
         if ( !updn.isNormalized() )
         {
-            updn.normalize( attributeTypeRegistry.getNormalizerMapping() );
+            updn.normalize( schemaManager.getNormalizerMapping() );
         }
         
         ndnIdx.add( updn.toNormName(), id );
         
         // update user provided DN index
         updnIdx.drop( id );
-        updnIdx.add( updn.getUpName(), id );
+        updnIdx.add( updn.getName(), id );
 
         /* 
          * Read Alias Index Tuples
@@ -1969,7 +1946,7 @@
 
             String rdn = oldUpdn.get( oldUpdn.size() - 1 );
             LdapDN rdnDN = new LdapDN( rdn );
-            rdnDN.normalize( attributeTypeRegistry.getNormalizerMapping() );
+            rdnDN.normalize( schemaManager.getNormalizerMapping() );
             childUpdn.add( rdnDN.getRdn() );
 
             // Modify the child
@@ -2228,9 +2205,17 @@
     }
 
 
-    public void initRegistries( Registries registries )
+    public void initSchemaManager( SchemaManager schemaManager )
+    {
+        this.schemaManager = schemaManager;
+    }
+
+
+    /**
+     * @param schemaManager the schemaManager to set
+     */
+    public void setSchemaManager( SchemaManager schemaManager )
     {
-        this.attributeTypeRegistry = registries.getAttributeTypeRegistry();
-        this.oidRegistry = registries.getOidRegistry();
+        this.schemaManager = schemaManager;
     }
 }

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmTable.java Wed Jan  6 18:26:43 2010
@@ -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;
@@ -29,20 +33,17 @@
 import org.apache.directory.server.core.avltree.ArrayTree;
 import org.apache.directory.server.core.avltree.ArrayTreeCursor;
 import org.apache.directory.server.core.avltree.Marshaller;
-import org.apache.directory.server.schema.SerializableComparator;
 import org.apache.directory.server.xdbm.Table;
 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<ArrayTree<V>> 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<K> keyComparator, Comparator<V> 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<K>)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<K> keyComparator,
+    public JdbmTable( SchemaManager schemaManager, String name, RecordManager manager, Comparator<K> 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<K>)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<K>)tree.getComparator()).setSchemaManager( schemaManager );
         duplicateBtrees.put( redirect.getRecId(), tree );
         return tree;
     }

Modified: directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java?rev=896599&r1=896598&r2=896599&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java (original)
+++ directory/apacheds/trunk/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/BTreeRedirectMarshallerTest.java Wed Jan  6 18:26:43 2010
@@ -24,7 +24,12 @@
 import org.junit.Before;
 import org.apache.directory.shared.ldap.util.ArrayUtils;
 
-import static junit.framework.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.fail;
+
 
 import java.util.Random;
 import java.io.IOException;



Mime
View raw message