directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r824528 [2/3] - in /directory: apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/ apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/ a...
Date Mon, 12 Oct 2009 22:44:54 GMT
Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java Mon Oct 12 22:44:52 2009
@@ -54,6 +54,7 @@
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.After;
 import org.junit.Before;
@@ -98,8 +99,21 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java Mon Oct 12 22:44:52 2009
@@ -54,6 +54,7 @@
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.After;
 import org.junit.Before;
@@ -98,8 +99,21 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java Mon Oct 12 22:44:52 2009
@@ -20,33 +20,37 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
+import static org.junit.Assert.assertEquals;
+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.List;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
-import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
-import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.IndexCursor;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Optimizer;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.filter.ExprNode;
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.name.NameComponentNormalizer;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.ldap.schema.normalizers.ConcreteNameComponentNormalizer;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -89,8 +93,16 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+        
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java Mon Oct 12 22:44:52 2009
@@ -20,17 +20,21 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
+import static org.junit.Assert.assertEquals;
+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.List;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.IndexCursor;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -39,20 +43,18 @@
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.NotNode;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -91,8 +93,21 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java Mon Oct 12 22:44:52 2009
@@ -20,18 +20,25 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.directory.server.xdbm.Store;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
-import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
-import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.csn.CsnFactory;
 import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
@@ -40,21 +47,18 @@
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.SchemaUtils;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-
-import java.io.File;
-import java.util.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -92,8 +96,21 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java Mon Oct 12 22:44:52 2009
@@ -19,20 +19,23 @@
  */
 package org.apache.directory.server.xdbm.search.impl;
 
+import static org.junit.Assert.assertEquals;
+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.ArrayList;
 import java.util.List;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
+import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.search.Evaluator;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
@@ -42,18 +45,16 @@
 import org.apache.directory.shared.ldap.filter.FilterParser;
 import org.apache.directory.shared.ldap.filter.OrNode;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.fail;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -97,8 +98,21 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java Mon Oct 12 22:44:52 2009
@@ -20,32 +20,36 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
-import org.apache.directory.server.xdbm.Store;
-import org.apache.directory.server.xdbm.ForwardIndexEntry;
-import org.apache.directory.server.xdbm.tools.StoreUtils;
+import static org.junit.Assert.assertEquals;
+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.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
 import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.xdbm.ForwardIndexEntry;
+import org.apache.directory.server.xdbm.Store;
+import org.apache.directory.server.xdbm.tools.StoreUtils;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.filter.PresenceNode;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
-import org.apache.commons.io.FileUtils;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import java.io.File;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -81,8 +85,21 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java Mon Oct 12 22:44:52 2009
@@ -20,32 +20,36 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.directory.server.xdbm.Store;
+import static org.junit.Assert.assertEquals;
+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.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
-import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
-import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
 import org.apache.directory.shared.ldap.filter.SubstringNode;
+import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-import java.io.File;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -81,8 +85,21 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+        
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
         SerializableComparator.setRegistry( registries.getComparatorRegistry() );
 
         attributeRegistry = registries.getAttributeTypeRegistry();

Modified: directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java Mon Oct 12 22:44:52 2009
@@ -20,17 +20,26 @@
 package org.apache.directory.server.xdbm.search.impl;
 
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.directory.server.xdbm.Store;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.entry.DefaultServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
+import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
 import org.apache.directory.server.xdbm.ForwardIndexEntry;
 import org.apache.directory.server.xdbm.IndexEntry;
+import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.server.xdbm.tools.StoreUtils;
-import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmStore;
-import org.apache.directory.server.core.partition.impl.btree.jdbm.JdbmIndex;
-import org.apache.directory.server.core.entry.ServerEntry;
-import org.apache.directory.server.core.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.csn.CsnFactory;
 import org.apache.directory.shared.ldap.cursor.InvalidCursorPositionException;
@@ -39,22 +48,17 @@
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.SchemaUtils;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
 import org.junit.After;
+import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-import java.io.File;
-import java.util.UUID;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -91,8 +95,20 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
-        loader.loadAllEnabled( registries );
-        loader.loadWithDependencies( loader.getSchema( "collective" ), registries );
+        
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
+
+        errors = loader.loadWithDependencies( loader.getSchema( "collective" ), registries, true );
+
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
 
         attributeRegistry = registries.getAttributeTypeRegistry();
     }

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/JarLdifSchemaLoader.java Mon Oct 12 22:44:52 2009
@@ -29,14 +29,9 @@
 import java.util.Stack;
 import java.util.regex.Pattern;
 
-import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
-import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.ResourceMap;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.AbstractSchemaLoader;
@@ -49,6 +44,8 @@
 /**
  * Loads schema data from LDIF files containing entries representing schema
  * objects, using the meta schema format.
+ * 
+ * This class is used only for tests.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Revision$
@@ -143,8 +140,13 @@
     /**
      * {@inheritDoc}
      */
-    public void loadWithDependencies( Schema schema, Registries registries ) throws Exception
+    public List<Throwable> loadWithDependencies( Schema schema, Registries registries, boolean check ) throws Exception
     {
+        // Relax the controls at first
+        List<Throwable> errors = new ArrayList<Throwable>();
+        boolean wasRelaxed = registries.isRelaxed();
+        registries.setRelaxed( true );
+
         Stack<String> beenthere = new Stack<String>();
         Map<String,Schema> notLoaded = new HashMap<String,Schema>();
         
@@ -156,7 +158,18 @@
             }
         }
         
-        super.loadDepsFirst( schema, beenthere, notLoaded, schema, registries );
+        loadDepsFirst( schema, beenthere, notLoaded, schema, registries );
+        
+        // At the end, check the registries if required
+        if ( check )
+        {
+            errors = registries.checkRefInteg();
+        }
+        
+        // Restore the Registries isRelaxed flag
+        registries.setRelaxed( wasRelaxed );
+        
+        return errors;
     }
 
 
@@ -190,24 +203,19 @@
         
         registries.schemaLoaded( schema );
         
-        try
-        {
-            loadComparators( schema, registries );
-            loadNormalizers( schema, registries );
-            loadSyntaxCheckers( schema, registries );
-            loadSyntaxes( schema, registries );
-            loadMatchingRules( schema, registries );
-            loadAttributeTypes( schema, registries );
-            loadObjectClasses( schema, registries );
-            loadMatchingRuleUses( schema, registries );
-            loadDitContentRules( schema, registries );
-            loadNameForms( schema, registries );
-            loadDitStructureRules( schema, registries );
-        }
-        catch ( Exception e )
-        {
-            LOG.error( e.getMessage() );
-        }
+        // We set the registries to Permissive, so that we don't care about the order
+        // the SchemaObjects are loaded.
+        loadComparators( schema, registries );
+        loadNormalizers( schema, registries );
+        loadSyntaxCheckers( schema, registries );
+        loadSyntaxes( schema, registries );
+        loadMatchingRules( schema, registries );
+        loadAttributeTypes( schema, registries );
+        loadObjectClasses( schema, registries );
+        loadMatchingRuleUses( schema, registries );
+        loadDitContentRules( schema, registries );
+        loadNameForms( schema, registries );
+        loadDitStructureRules( schema, registries );
 
         notifyListenerOrRegistries( schema, registries );
     }
@@ -386,27 +394,6 @@
      */
     private void loadAttributeTypes( Schema schema, Registries registries ) throws Exception
     {
-    	/*
-    	 * AT's can depend on another AT via the superior relationship.  
-    	 * Because we separate each schema object into its own LDIF file and
-    	 * the file system scan producing the listing of files used to order
-    	 * the LDIF loads does not consider these dependencies we can have
-    	 * a situation where the superior may not be loaded when a dependent
-    	 * AT is loaded.
-    	 * 
-    	 * For this reason we must defer the loading of some LDIF entries 
-    	 * until their superior AT is actually loaded.  This hash stores
-    	 * LDIF entries keyed by the name of their superior AT.  When the
-    	 * superior is loaded, the deferred entries depending on that superior
-    	 * are loaded and the list of dependent entries are removed from this 
-    	 * hash map.
-    	 * 
-    	 * NOTE: Because we don't have an OID and must use a potentially 
-    	 * case varying String as the key in this map, we reduce the String to
-    	 * it's lower cased cannonical form.
-    	 */
-    	Map<String,List<LdifEntry>> deferredEntries = new HashMap<String, List<LdifEntry>>();
-
     	// check that the attributeTypes directory exists for the schema
         String attributeTypesDirectory = getSchemaDirectory( schema )
             + "/" + SchemaConstants.ATTRIBUTES_TYPE_PATH;
@@ -421,102 +408,10 @@
                 URL resource = getResource( resourcePath, "attributeType LDIF file" );
                 LdifReader reader = new LdifReader( resource.openStream() );
                 LdifEntry entry = reader.next();
-                loadAttributeType( schema, deferredEntries, entry, registries );
-            }
-        }
 
-        
-        if ( ! deferredEntries.isEmpty() )
-        {
-        	for ( String missingSuperior : deferredEntries.keySet() )
-        	{
-        		if ( registries.getObjectClassRegistry().containsName( missingSuperior ) )
-        		{
-        			for ( LdifEntry entry : deferredEntries.get( missingSuperior ) )
-        			{
-        				if ( loadAttributeType( schema, deferredEntries, entry, registries ) )
-        				{
-        					LOG.error( "Still failed to load schema entry: {}", entry );
-        				}
-        			}
-        		}
-        	}
-        }
-    }
-    
-    
-    /**
-     * Recursive method that loads an AT, and other deferred ATs that depend
-     * on it.  This is separated from and used by 
-     * {@link #loadAttributeTypes(Schema, Registries)} to enter into this 
-     * method.
-     * 
-     * If the AT being loaded has deferred entries waiting on it to be loaded,
-     * then the AT is loaded then it's deferred entries are loaded by making a
-     * recursive call to this method.  This begins the process a new making 
-     * sure all deferred descendants in the AT hierarchy are load.
-     * 
-     * @param schema the schema we are loading
-     * @param deferredEntries map of deferred AT LDIF entries
-     * @param entry the AT LDIF entry to load
-     * @param registries the registries the schema objects are loaded into
-     * @return true if the AT is loaded, false otherwise
-     * @throws Exception if there any failures looking up or registering
-     */
-    private boolean loadAttributeType( Schema schema, Map<String,List<LdifEntry>> deferredEntries, LdifEntry entry,
-    		Registries registries ) throws Exception
-    {
-        // get superior name and if exists check if loaded, defer if not
-        EntryAttribute superior = entry.getEntry().get( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT );
-        
-        if ( superior != null )
-        {
-        	String superiorName = superior.getString().toLowerCase();
-        	
-        	if ( ! registries.getAttributeTypeRegistry().containsName( superiorName ) )
-        	{
-        		List<LdifEntry> dependents = deferredEntries.get( superiorName );
-        		
-        		if ( dependents == null )
-        		{
-        			dependents = new ArrayList<LdifEntry>();
-        			deferredEntries.put( superiorName, dependents );
-        		}
-
-        		dependents.add( entry );
-        		return false;  // - return false if deferred, true when loaded
-        	}
-        }
-        
-        AttributeType attributeType = registerAttributeType( registries, entry, schema );
-        
-        // after registering AT check if any deferred entries depend on it
-        if ( attributeType.getNames() != null )
-        {
-        	for ( String name : attributeType.getNames() )
-        	{
-        		if ( deferredEntries.containsKey( name.toLowerCase() ) )
-        		{
-        			List<LdifEntry> deferredList = deferredEntries.get( name.toLowerCase() );
-        			List<LdifEntry> copiedList = new ArrayList<LdifEntry>( deferredList );
-        			
-        			for ( LdifEntry deferred : copiedList )
-        			{
-        				if ( loadAttributeType( schema, deferredEntries, deferred, registries ) )
-        				{
-        					deferredList.remove( deferred );
-        				}
-        			}
-        			
-        			if ( deferredList.isEmpty() )
-        			{
-        				deferredEntries.remove( name.toLowerCase() );
-        			}
-        		}
-        	}
+                registerAttributeType( registries, entry, schema );
+            }
         }
-        
-        return true;
     }
 
 
@@ -651,27 +546,6 @@
      */
     private void loadObjectClasses( Schema schema, Registries registries ) throws Exception
     {
-    	/*
-    	 * OC's can depend on other OCs via their list of superior OCs.  
-    	 * Because we separate each schema object into its own LDIF file and
-    	 * the file system scan producing the listing of files used to order
-    	 * the LDIF loads does not consider these dependencies we can have
-    	 * a situation where the superiors may not be loaded when a dependent
-    	 * OC is loaded.
-    	 * 
-    	 * For this reason we must defer the loading of some LDIF entries 
-    	 * until their superior OCs are actually loaded.  This hash stores
-    	 * LDIF entries keyed by the name of their superior OCs.  When a
-    	 * superior is loaded, the deferred entries depending on that superior
-    	 * are loaded and the list of dependent entries are removed from this 
-    	 * hash map.
-    	 * 
-    	 * NOTE: Because we don't have an OID and must use a potentially 
-    	 * case varying String as the key in this map, we reduce the String to
-    	 * it's lower cased cannonical form.
-    	 */
-    	Map<String,List<LdifEntry>> deferredEntries = new HashMap<String, List<LdifEntry>>();
-
     	// get objectClasses directory, check if exists, return if not
     	String objectClassesDirectory = getSchemaDirectory( schema ) + "/" + SchemaConstants.OBJECT_CLASSES_PATH;
 
@@ -684,103 +558,9 @@
                 URL resource = getResource( resourcePath, "objectClass LDIF file" );
                 LdifReader reader = new LdifReader( resource.openStream() );
                 LdifEntry entry = reader.next();
-                loadObjectClass( schema, deferredEntries, entry, registries );
-            }
-            
-            if ( ! deferredEntries.isEmpty() )
-            {
-            	for ( String missingSuperior : deferredEntries.keySet() )
-            	{
-            		if ( registries.getObjectClassRegistry().containsName( missingSuperior ) )
-            		{
-            			for ( LdifEntry entry : deferredEntries.get( missingSuperior ) )
-            			{
-            				if ( loadObjectClass( schema, deferredEntries, entry, registries ) )
-            				{
-            					LOG.error( "Still failed to load schema entry: {}", entry );
-            				}
-            			}
-            		}
-            	}
+
+                registerObjectClass( registries, entry, schema );
             }
         }
     }
-    
-    
-    /**
-     * Recursive method that loads an OC, and other deferred OCs that may
-     * depend on the initial OC loaded.  This is separated from and used by
-     * {@link #loadObjectClasses(Schema, Registries)} to enter into this 
-     * method.
-     * 
-     * If the OC being loaded has deferred entries waiting on it to be loaded,
-     * then the OC is loaded then it's deferred entries are loaded by making a
-     * recursive call to this method.  This begins the process a new making 
-     * sure all deferred descendants in the OC hierarchy are load.
-     * 
-     * @param schema the schema we are loading
-     * @param deferredEntries map of deferred OC LDIF entries
-     * @param entry the OC LDIF entry to load
-     * @param registries the registries the schema objects are loaded into
-     * @return true if the OC is loaded, false otherwise
-     * @throws Exception if there any failures looking up or registering
-     */
-    private boolean loadObjectClass( Schema schema, Map<String,List<LdifEntry>> deferredEntries, LdifEntry entry, 
-    		Registries registries ) throws Exception
-	{
-        // get superior name and if exists check if loaded, defer if not
-        EntryAttribute superiors = entry.getEntry().get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
-        
-        if ( superiors != null )
-        {
-        	for ( Value<?> value : superiors )
-        	{
-        		String superiorName = value.getString().toLowerCase();
-        		
-            	if ( ! registries.getObjectClassRegistry().containsName( superiorName ) )
-            	{
-            		List<LdifEntry> dependents = deferredEntries.get( superiorName );
-            		
-            		if ( dependents == null )
-            		{
-            			dependents = new ArrayList<LdifEntry>();
-            			deferredEntries.put( superiorName, dependents );
-            		}
-
-            		dependents.add( entry );
-            		return false;  // - return false if deferred, true when loaded
-            	}
-        	}
-        }
-        
-        ObjectClass objectClass = registerObjectClass( registries, entry, schema );
-
-        // after registering AT check if any deferred entries depend on it
-        if ( objectClass.getNames() != null )
-        {
-        	for ( String name : objectClass.getNames() )
-        	{
-        		if ( deferredEntries.containsKey( name.toLowerCase() ) )
-        		{
-        			List<LdifEntry> deferredList = deferredEntries.get( name.toLowerCase() );
-        			List<LdifEntry> copiedList = new ArrayList<LdifEntry>( deferredList );
-        			
-        			for ( LdifEntry deferred : copiedList )
-        			{
-        				if ( loadObjectClass( schema, deferredEntries, deferred, registries ) )
-        				{
-        					deferredList.remove( deferred );
-        				}
-        			}
-        			
-        			if ( deferredList.isEmpty() )
-        			{
-        				deferredEntries.remove( name.toLowerCase() );
-        			}
-        		}
-        	}
-        }
-        
-        return true;
-    }
 }

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/loader/ldif/LdifSchemaLoader.java Mon Oct 12 22:44:52 2009
@@ -33,13 +33,9 @@
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.Entry;
-import org.apache.directory.shared.ldap.entry.EntryAttribute;
-import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.ldif.LdifReader;
 import org.apache.directory.shared.ldap.ldif.LdifUtils;
-import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.registries.AbstractSchemaLoader;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
@@ -52,6 +48,8 @@
  * Loads schema data from LDIF files containing entries representing schema
  * objects, using the meta schema format.
  *
+ * This class is used only for tests.
+ * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Revision$
  */
@@ -173,12 +171,28 @@
     /**
      * {@inheritDoc}
      */
-    public void loadWithDependencies( Schema schema, Registries registries ) throws Exception
+    public List<Throwable> loadWithDependencies( Schema schema, Registries registries, boolean check ) throws Exception
     {
+        // Relax the controls at first
+        List<Throwable> errors = new ArrayList<Throwable>();
+        boolean wasRelaxed = registries.isRelaxed();
+        registries.setRelaxed( true );
+
         Stack<String> beenthere = new Stack<String>();
         Map<String,Schema> notLoaded = new HashMap<String,Schema>();
         notLoaded.put( schema.getSchemaName(), schema );
         super.loadDepsFirst( schema, beenthere, notLoaded, schema, registries );
+        
+        // At the end, check the registries if required
+        if ( check )
+        {
+            errors = registries.checkRefInteg();
+        }
+        
+        // Restore the Registries isRelaxed flag
+        registries.setRelaxed( wasRelaxed );
+        
+        return errors;
     }
 
 
@@ -469,27 +483,6 @@
      */
     private void loadAttributeTypes( Schema schema, Registries registries ) throws Exception
     {
-    	/*
-    	 * AT's can depend on another AT via the superior relationship.  
-    	 * Because we separate each schema object into its own LDIF file and
-    	 * the file system scan producing the listing of files used to order
-    	 * the LDIF loads does not consider these dependencies we can have
-    	 * a situation where the superior may not be loaded when a dependent
-    	 * AT is loaded.
-    	 * 
-    	 * For this reason we must defer the loading of some LDIF entries 
-    	 * until their superior AT is actually loaded.  This hash stores
-    	 * LDIF entries keyed by the name of their superior AT.  When the
-    	 * superior is loaded, the deferred entries depending on that superior
-    	 * are loaded and the list of dependent entries are removed from this 
-    	 * hash map.
-    	 * 
-    	 * NOTE: Because we don't have an OID and must use a potentially 
-    	 * case varying String as the key in this map, we reduce the String to
-    	 * it's lower cased cannonical form.
-    	 */
-    	Map<String,List<LdifEntry>> deferredEntries = new HashMap<String, List<LdifEntry>>();
-
     	// check that the attributeTypes directory exists for the schema
         File attributeTypesDirectory = new File ( getSchemaDirectory( schema ), SchemaConstants.ATTRIBUTES_TYPE_PATH );
         
@@ -505,105 +498,13 @@
         {
             LdifReader reader = new LdifReader( ldifFile );
             LdifEntry entry = reader.next();
-            loadAttributeType( schema, deferredEntries, entry, registries );
-        }
-
-        
-        if ( ! deferredEntries.isEmpty() )
-        {
-        	for ( String missingSuperior : deferredEntries.keySet() )
-        	{
-        		if ( registries.getObjectClassRegistry().containsName( missingSuperior ) )
-        		{
-        			for ( LdifEntry entry : deferredEntries.get( missingSuperior ) )
-        			{
-        				if ( loadAttributeType( schema, deferredEntries, entry, registries ) )
-        				{
-        					LOG.error( "Still failed to load schema entry: {}", entry );
-        				}
-        			}
-        		}
-        	}
+            
+            registerAttributeType( registries, entry, schema );
         }
     }
     
     
     /**
-     * Recursive method that loads an AT, and other deferred ATs that depend
-     * on it.  This is separated from and used by 
-     * {@link #loadAttributeTypes(Schema, Registries)} to enter into this 
-     * method.
-     * 
-     * If the AT being loaded has deferred entries waiting on it to be loaded,
-     * then the AT is loaded then it's deferred entries are loaded by making a
-     * recursive call to this method.  This begins the process a new making 
-     * sure all deferred descendants in the AT hierarchy are load.
-     * 
-     * @param schema the schema we are loading
-     * @param deferredEntries map of deferred AT LDIF entries
-     * @param entry the AT LDIF entry to load
-     * @param registries the registries the schema objects are loaded into
-     * @return true if the AT is loaded, false otherwise
-     * @throws Exception if there any failures looking up or registering
-     */
-    private boolean loadAttributeType( Schema schema, Map<String,List<LdifEntry>> deferredEntries, LdifEntry entry,
-    		Registries registries ) throws Exception
-    {
-        // get superior name and if exists check if loaded, defer if not
-        EntryAttribute superior = entry.getEntry().get( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT );
-        
-        if ( superior != null )
-        {
-        	String superiorName = superior.getString().toLowerCase();
-        	
-        	if ( ! registries.getAttributeTypeRegistry().containsName( superiorName ) )
-        	{
-        		List<LdifEntry> dependents = deferredEntries.get( superiorName );
-        		
-        		if ( dependents == null )
-        		{
-        			dependents = new ArrayList<LdifEntry>();
-        			deferredEntries.put( superiorName, dependents );
-        		}
-
-        		dependents.add( entry );
-        		return false;  // - return false if deferred, true when loaded
-        	}
-        }
-        
-        AttributeType attributeType = registerAttributeType( registries, entry, schema );
-
-        // after registering AT check if any deferred entries depend on it
-        if ( attributeType.getNames() != null )
-        {
-        	for ( String name : attributeType.getNames() )
-        	{
-        		if ( deferredEntries.containsKey( name.toLowerCase() ) )
-        		{
-        			List<LdifEntry> deferredList = deferredEntries.get( name.toLowerCase() );
-        			List<LdifEntry> copiedList = new ArrayList<LdifEntry>( deferredList );
-        			
-        			for ( LdifEntry deferred : copiedList )
-        			{
-        				if ( loadAttributeType( schema, deferredEntries, deferred, registries ) )
-        				{
-        					deferredList.remove( deferred );
-        				}
-        			}
-        			
-        			if ( deferredList.isEmpty() )
-        			{
-        				deferredEntries.remove( name.toLowerCase() );
-        			}
-        		}
-        	}
-        }
-        
-        return true;
-    }
-
-
-    /**
      * Loads the MatchingRuleUses from LDIF files in the supplied schema into the 
      * supplied registries.
      *
@@ -738,27 +639,6 @@
      */
     private void loadObjectClasses( Schema schema, Registries registries ) throws Exception
     {
-    	/*
-    	 * OC's can depend on other OCs via their list of superior OCs.  
-    	 * Because we separate each schema object into its own LDIF file and
-    	 * the file system scan producing the listing of files used to order
-    	 * the LDIF loads does not consider these dependencies we can have
-    	 * a situation where the superiors may not be loaded when a dependent
-    	 * OC is loaded.
-    	 * 
-    	 * For this reason we must defer the loading of some LDIF entries 
-    	 * until their superior OCs are actually loaded.  This hash stores
-    	 * LDIF entries keyed by the name of their superior OCs.  When a
-    	 * superior is loaded, the deferred entries depending on that superior
-    	 * are loaded and the list of dependent entries are removed from this 
-    	 * hash map.
-    	 * 
-    	 * NOTE: Because we don't have an OID and must use a potentially 
-    	 * case varying String as the key in this map, we reduce the String to
-    	 * it's lower cased cannonical form.
-    	 */
-    	Map<String,List<LdifEntry>> deferredEntries = new HashMap<String, List<LdifEntry>>();
-
     	// get objectClasses directory, check if exists, return if not
     	File objectClassesDirectory = new File( getSchemaDirectory( schema ), SchemaConstants.OBJECT_CLASSES_PATH );
         
@@ -774,102 +654,8 @@
         {
             LdifReader reader = new LdifReader( ldifFile );
             LdifEntry entry = reader.next();
-            loadObjectClass( schema, deferredEntries, entry, registries );
-        }
-        
-        if ( ! deferredEntries.isEmpty() )
-        {
-        	for ( String missingSuperior : deferredEntries.keySet() )
-        	{
-        		if ( registries.getObjectClassRegistry().containsName( missingSuperior ) )
-        		{
-        			for ( LdifEntry entry : deferredEntries.get( missingSuperior ) )
-        			{
-        				if ( loadObjectClass( schema, deferredEntries, entry, registries ) )
-        				{
-        					LOG.error( "Still failed to load schema entry: {}", entry );
-        				}
-        			}
-        		}
-        	}
-        }
-    }
-    
-    
-    /**
-     * Recursive method that loads an OC, and other deferred OCs that may
-     * depend on the initial OC loaded.  This is separated from and used by
-     * {@link #loadObjectClasses(Schema, Registries)} to enter into this 
-     * method.
-     * 
-     * If the OC being loaded has deferred entries waiting on it to be loaded,
-     * then the OC is loaded then it's deferred entries are loaded by making a
-     * recursive call to this method.  This begins the process a new making 
-     * sure all deferred descendants in the OC hierarchy are load.
-     * 
-     * @param schema the schema we are loading
-     * @param deferredEntries map of deferred OC LDIF entries
-     * @param entry the OC LDIF entry to load
-     * @param registries the registries the schema objects are loaded into
-     * @return true if the OC is loaded, false otherwise
-     * @throws Exception if there any failures looking up or registering
-     */
-    private boolean loadObjectClass( Schema schema, Map<String,List<LdifEntry>> deferredEntries, LdifEntry entry, 
-    		Registries registries ) throws Exception
-	{
-        // get superior name and if exists check if loaded, defer if not
-        EntryAttribute superiors = entry.getEntry().get( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
-        
-        if ( superiors != null )
-        {
-        	for ( Value<?> value : superiors )
-        	{
-        		String superiorName = value.getString().toLowerCase();
-            	
-        		if ( ! registries.getObjectClassRegistry().containsName( superiorName ) )
-            	{
-            		List<LdifEntry> dependents = deferredEntries.get( superiorName );
-            		
-            		if ( dependents == null )
-            		{
-            			dependents = new ArrayList<LdifEntry>();
-            			deferredEntries.put( superiorName, dependents );
-            		}
-
-            		dependents.add( entry );
-            		return false;  // - return false if deferred, true when loaded
-            	}
-        	}
-        }
-        
-        ObjectClass objectClass = registerObjectClass( registries, entry, schema );
-
-        // after registering AT check if any deferred entries depend on it
-        if ( objectClass.getNames() != null )
-        {
-        	for ( String name : objectClass.getNames() )
-        	{
-        		if ( deferredEntries.containsKey( name.toLowerCase() ) )
-        		{
-        			List<LdifEntry> deferredList = deferredEntries.get( name.toLowerCase() );
-        			List<LdifEntry> copiedList = new ArrayList<LdifEntry>( deferredList );
-        			
-        			for ( LdifEntry deferred : copiedList )
-        			{
-        				if ( loadObjectClass( schema, deferredEntries, deferred, registries ) )
-        				{
-        					deferredList.remove( deferred );
-        				}
-        			}
-        			
-        			if ( deferredList.isEmpty() )
-        			{
-        				deferredEntries.remove( name.toLowerCase() );
-        			}
-        		}
-        	}
+            
+            registerObjectClass( registries, entry, schema );
         }
-        
-        return true;
     }
 }

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/JarLdifSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/JarLdifSchemaLoaderTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/JarLdifSchemaLoaderTest.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/JarLdifSchemaLoaderTest.java Mon Oct 12 22:44:52 2009
@@ -41,12 +41,12 @@
     {
         Registries registries = new Registries();
         JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
-        loader.loadWithDependencies( loader.getSchema( "system" ), registries );
+        loader.loadWithDependencies( loader.getSchema( "system" ), registries, true );
         
         assertTrue( registries.getAttributeTypeRegistry().contains( "cn" ) );
         assertFalse( registries.getAttributeTypeRegistry().contains( "m-aux" ) );
         
-        loader.loadWithDependencies( loader.getSchema( "apachemeta" ), registries );
+        loader.loadWithDependencies( loader.getSchema( "apachemeta" ), registries, true );
 
         assertTrue( registries.getAttributeTypeRegistry().contains( "m-aux" ) );
     }

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/loader/ldif/LdifSchemaLoaderTest.java Mon Oct 12 22:44:52 2009
@@ -21,13 +21,16 @@
 
 
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -78,7 +81,13 @@
         
         LdifSchemaLoader loader = new LdifSchemaLoader( new File( workingDirectory, "schema" ) );
         Registries registries = new Registries();
-        loader.loadAllEnabled( registries );
+        
+        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        
+        if ( errors.size() != 0 )
+        {
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+        }
         
         assertTrue( registries.getAttributeTypeRegistry().contains( "cn" ) );
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java Mon Oct 12 22:44:52 2009
@@ -188,12 +188,13 @@
         {
             try
             {
-                // Gets the associated C 
+                // Gets the associated SyntaxChecker
                 syntaxChecker = registries.getSyntaxCheckerRegistry().lookup( oid );
             }
             catch ( NamingException ne )
             {
-                syntaxChecker = new OctetStringSyntaxChecker();
+                // No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker
+                syntaxChecker = new OctetStringSyntaxChecker( oid );
             }
         }
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java Mon Oct 12 22:44:52 2009
@@ -126,16 +126,18 @@
             }
             catch ( NamingException ne )
             {
+                // Default to a catch all comparator
                 ldapComparator = new ComparableComparator( oid );
             }
     
             try
             {
-                // Gets the associated N ormalizer
+                // Gets the associated Normalizer
                 normalizer = registries.getNormalizerRegistry().lookup( oid );
             }
             catch ( NamingException ne )
             {
+                // Default to the NoOp normalizer
                 normalizer = new NoOpNormalizer( oid );
             }
             

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java Mon Oct 12 22:44:52 2009
@@ -356,9 +356,8 @@
      * Gets the superclasses OIDsof this ObjectClass.
      * 
      * @return the superclasses OIDs
-     * @throws NamingException if there is a failure resolving the object
      */
-    public List<String> getSuperiorOids() throws NamingException
+    public List<String> getSuperiorOids()
     {
         return superiorOids;
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java Mon Oct 12 22:44:52 2009
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.schema.normalizers;
 
+import javax.naming.NamingException;
+
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 
 
@@ -46,7 +48,7 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries )
+    public void applyRegistries( Registries registries ) throws NamingException
     {
         super.applyRegistries( registries );
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java Mon Oct 12 22:44:52 2009
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.schema.normalizers;
 
+import javax.naming.NamingException;
+
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 
 
@@ -46,7 +48,7 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries )
+    public void applyRegistries( Registries registries ) throws NamingException
     {
         super.applyRegistries( registries );
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java Mon Oct 12 22:44:52 2009
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.schema.normalizers;
 
+import javax.naming.NamingException;
+
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 
 
@@ -46,7 +48,7 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries )
+    public void applyRegistries( Registries registries ) throws NamingException
     {
         super.applyRegistries( registries );
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java Mon Oct 12 22:44:52 2009
@@ -154,7 +154,7 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries )
+    public void applyRegistries( Registries registries ) throws NamingException
     {
         normalizer.applyRegistries( registries );
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java?rev=824528&r1=824527&r2=824528&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/AbstractSchemaLoader.java Mon Oct 12 22:44:52 2009
@@ -20,8 +20,10 @@
 package org.apache.directory.shared.ldap.schema.registries;
 
 
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Stack;
 
@@ -29,6 +31,7 @@
 
 import org.apache.directory.shared.ldap.NotImplementedException;
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
+import org.apache.directory.shared.ldap.entry.Entry;
 import org.apache.directory.shared.ldap.ldif.LdifEntry;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.DITContentRule;
@@ -104,8 +107,13 @@
     /**
      * {@inheritDoc}
      */
-    public final void loadAllEnabled( Registries registries ) throws Exception
+    public final List<Throwable> loadAllEnabled( Registries registries, boolean check ) throws Exception
     {
+        // Relax the controls at first
+        List<Throwable> errors = new ArrayList<Throwable>();
+        boolean wasRelaxed = registries.isRelaxed();
+        registries.setRelaxed( true );
+
         Map<String,Schema> notloaded = new HashMap<String,Schema>( schemaMap );
         
         for ( String schemaName : schemaMap.keySet() )
@@ -121,6 +129,17 @@
             loadDepsFirst( schema, new Stack<String>(), 
                 notloaded, schema, registries );
         }
+
+        // At the end, check the registries if required
+        if ( check )
+        {
+            errors = registries.checkRefInteg();
+        }
+        
+        // Restore the Registries isRelaxed flag
+        registries.setRelaxed( wasRelaxed );
+        
+        return errors;
     }
     
     
@@ -232,8 +251,13 @@
     /**
      * {@inheritDoc}
      */
-    public void loadWithDependencies( Collection<Schema> schemas, Registries registries ) throws Exception
+    public List<Throwable> loadWithDependencies( Collection<Schema> schemas, Registries registries, boolean check ) throws Exception
     {
+        // Relax the controls at first
+        List<Throwable> errors = new ArrayList<Throwable>();
+        boolean wasRelaxed = registries.isRelaxed();
+        registries.setRelaxed( true );
+
         Map<String,Schema> notLoaded = new HashMap<String,Schema>();
         
         for ( Schema schema : schemas )
@@ -249,6 +273,17 @@
             Stack<String> beenthere = new Stack<String>();
             loadDepsFirst( schema, beenthere, notLoaded, schema, registries );
         }
+        
+        // At the end, check the registries if required
+        if ( check )
+        {
+            errors = registries.checkRefInteg();
+        }
+        
+        // Restore the Registries isRelaxed flag
+        registries.setRelaxed( wasRelaxed );
+        
+        return errors;
     }
     
     
@@ -260,18 +295,48 @@
      * @param schema The associated schema
      * @throws Exception If the registering failed
      */
-    protected void registerComparator( Registries registries, LdifEntry entry, Schema schema) 
+    protected LdapComparator<?> registerComparator( Registries registries, LdifEntry entry, Schema schema ) 
+        throws Exception
+    {
+        return registerComparator( registries, entry.getEntry(), schema );
+    }
+    
+    
+    /**
+     * Register the comparator contained in the given Entry into the registries. 
+     *
+     * @param registries The Registries
+     * @param entry The Entry containing the comparator description
+     * @param schema The associated schema
+     * @throws Exception If the registering failed
+     */
+    protected LdapComparator<?> registerComparator( Registries registries, Entry entry, Schema schema ) 
         throws Exception
     {
         LdapComparator<?> comparator = 
-            factory.getLdapComparator( entry.getEntry(), registries, schema.getSchemaName() );
+            factory.getLdapComparator( entry, registries, schema.getSchemaName() );
         comparator.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() );
 
-        if ( schema.isEnabled() && comparator.isEnabled() )
+        if ( registries.isRelaxed() )
+        {
+            if ( registries.acceptDisabled() )
+            {
+                registries.register( comparator );
+            }
+            else if ( schema.isEnabled() && comparator.isEnabled() )
+            {
+                registries.register( comparator );
+            }
+        }
+        else
         {
-            comparator.applyRegistries( registries );
-            registries.register( comparator );
+            if ( schema.isEnabled() && comparator.isEnabled() )
+            {
+                registries.register( comparator );
+            }
         }
+        
+        return comparator;
     }
     
     
@@ -291,10 +356,23 @@
             factory.getSyntaxChecker( entry.getEntry(), registries, schema.getSchemaName() );
         syntaxChecker.setOid( entry.get( MetaSchemaConstants.M_OID_AT ).getString() );
 
-        if ( schema.isEnabled() && syntaxChecker.isEnabled() )
+        if ( registries.isRelaxed() )
         {
-            syntaxChecker.applyRegistries( registries );
-            registries.register( syntaxChecker );
+            if ( registries.acceptDisabled() )
+            {
+                registries.register( syntaxChecker );
+            }
+            else if ( schema.isEnabled() && syntaxChecker.isEnabled() )
+            {
+                registries.register( syntaxChecker );
+            }
+        }
+        else
+        {
+            if ( schema.isEnabled() && syntaxChecker.isEnabled() )
+            {
+                registries.register( syntaxChecker );
+            }
         }
         
         return syntaxChecker;
@@ -316,10 +394,23 @@
         Normalizer normalizer =
             factory.getNormalizer( entry.getEntry(), registries, schema.getSchemaName() );
         
-        if ( schema.isEnabled() && normalizer.isEnabled() )
+        if ( registries.isRelaxed() )
+        {
+            if ( registries.acceptDisabled() )
+            {
+                registries.register( normalizer );
+            }
+            else if ( schema.isEnabled() && normalizer.isEnabled() )
+            {
+                registries.register( normalizer );
+            }
+        }
+        else
         {
-            normalizer.applyRegistries( registries );
-            registries.register( normalizer );
+            if ( schema.isEnabled() && normalizer.isEnabled() )
+            {
+                registries.register( normalizer );
+            }
         }
         
         return normalizer;
@@ -341,10 +432,23 @@
         MatchingRule matchingRule = factory.getMatchingRule( 
             entry.getEntry(), registries, schema.getSchemaName() );
 
-        if ( schema.isEnabled() && matchingRule.isEnabled() )
+        if ( registries.isRelaxed() )
         {
-            matchingRule.applyRegistries( registries );
-            registries.register( matchingRule );
+            if ( registries.acceptDisabled() )
+            {
+                registries.register( matchingRule );
+            }
+            else if ( schema.isEnabled() && matchingRule.isEnabled() )
+            {
+                registries.register( matchingRule );
+            }
+        }
+        else
+        {
+            if ( schema.isEnabled() && matchingRule.isEnabled() )
+            {
+                registries.register( matchingRule );
+            }
         }
         
         return matchingRule;
@@ -366,10 +470,23 @@
         LdapSyntax syntax = factory.getSyntax( 
             entry.getEntry(), registries, schema.getSchemaName() );
 
-        if ( schema.isEnabled() && syntax.isEnabled() )
+        if ( registries.isRelaxed() )
         {
-            syntax.applyRegistries( registries );
-            registries.register( syntax );
+            if ( registries.acceptDisabled() )
+            {
+                registries.register( syntax );
+            }
+            else if ( schema.isEnabled() && syntax.isEnabled() )
+            {
+                registries.register( syntax );
+            }
+        }
+        else
+        {
+            if ( schema.isEnabled() && syntax.isEnabled() )
+            {
+                registries.register( syntax );
+            }
         }
         
         return syntax;
@@ -385,15 +502,28 @@
      * @return the created AttributeType instance
      * @throws Exception If the registering failed
      */
-    protected AttributeType registerAttributeType( Registries registries, LdifEntry entry, Schema schema) 
+    protected AttributeType registerAttributeType( Registries registries, LdifEntry entry, Schema schema ) 
         throws Exception
     {
         AttributeType attributeType = factory.getAttributeType( entry.getEntry(), registries, schema.getSchemaName() );
         
-        if ( schema.isEnabled() && attributeType.isEnabled() )
+        if ( registries.isRelaxed() )
+        {
+            if ( registries.acceptDisabled() )
+            {
+                registries.register( attributeType );
+            }
+            else if ( schema.isEnabled() && attributeType.isEnabled() )
+            {
+                registries.register( attributeType );
+            }
+        }
+        else
         {
-            attributeType.applyRegistries( registries );
-            registries.register( attributeType );
+            if ( schema.isEnabled() && attributeType.isEnabled() )
+            {
+                registries.register( attributeType );
+            }
         }
         
         return attributeType;
@@ -480,12 +610,41 @@
     protected ObjectClass registerObjectClass( Registries registries, LdifEntry entry, Schema schema) 
         throws Exception
     {
-        ObjectClass objectClass = factory.getObjectClass( entry.getEntry(), registries, schema.getSchemaName() );
+        return registerObjectClass( registries, entry.getEntry(), schema );
+    }
 
-        if ( schema.isEnabled() && objectClass.isEnabled() )
+
+    /**
+     * Register the ObjectClass contained in the given LdifEntry into the registries. 
+     *
+     * @param registries The Registries
+     * @param entry The Entry containing the ObjectClass description
+     * @param schema The associated schema
+     * @return the created ObjectClass instance
+     * @throws Exception If the registering failed
+     */
+    protected ObjectClass registerObjectClass( Registries registries, Entry entry, Schema schema) 
+        throws Exception
+    {
+        ObjectClass objectClass = factory.getObjectClass( entry, registries, schema.getSchemaName() );
+
+        if ( registries.isRelaxed() )
+        {
+            if ( registries.acceptDisabled() )
+            {
+                registries.register( objectClass );
+            }
+            else if ( schema.isEnabled() && objectClass.isEnabled() )
+            {
+                registries.register( objectClass );
+            }
+        }
+        else
         {
-            objectClass.applyRegistries( registries );
-            registries.register( objectClass );
+            if ( schema.isEnabled() && objectClass.isEnabled() )
+            {
+                registries.register( objectClass );
+            }
         }
         
         return objectClass;



Mime
View raw message