directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r831373 [1/2] - in /directory/apacheds/branches/apacheds-schema: avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/ core-api/src/main/java/org/apache/directory/server/core/ core-api/src/main/java/org/apache/director...
Date Fri, 30 Oct 2009 16:20:44 GMT
Author: elecharny
Date: Fri Oct 30 16:20:42 2009
New Revision: 831373

URL: http://svn.apache.org/viewvc?rev=831373&view=rev
Log:
Fixed the way DS is initialized, as I have introduced the SchemaManager in the whole picture

Modified:
    directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesITest.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/partition/PartitionIT.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/resources/log4j.properties
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationInterceptor.java
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/DefaultSchemaService.java
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaSubentryManager.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/MaxValueCountFilterTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/RelatedProtectedItemFilterTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/authz/support/RestrictedByFilterTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/normalization/NormalizationVisitorTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/schema/SchemaCheckerTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/schema/SchemaServiceTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/security/TlsKeyGeneratorTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/subtree/RefinementEvaluatorTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/subtree/RefinementLeafEvaluatorTest.java
    directory/apacheds/branches/apacheds-schema/core/src/test/java/org/apache/directory/server/core/subtree/SubtreeEvaluatorTest.java
    directory/apacheds/branches/apacheds-schema/jdbm-partition/src/test/java/org/apache/directory/server/core/schema/PartitionSchemaLoaderTest.java
    directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmIndexTest.java
    directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmMasterTableTest.java
    directory/apacheds/branches/apacheds-schema/jdbm-store/src/test/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStoreTest.java
    directory/apacheds/branches/apacheds-schema/ldif-partition/src/test/java/org/apache/directory/server/core/partition/LdifPartitionTest.java
    directory/apacheds/branches/apacheds-schema/server-tools/src/main/java/org/apache/directory/server/tools/DumpCommand.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/main/java/org/apache/directory/server/xdbm/search/impl/EqualityEvaluator.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/AndCursorTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/GreaterEqTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/LessEqTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NestedFilterTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/NotCursorTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OneLevelScopeTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/OrCursorTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/PresenceTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubstringTest.java
    directory/apacheds/branches/apacheds-schema/xdbm-search/src/test/java/org/apache/directory/server/xdbm/search/impl/SubtreeScopeTest.java

Modified: directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/partition/avl/AvlStoreTest.java Fri Oct 30 16:20:42 2009
@@ -59,11 +59,13 @@
 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.SchemaManager;
 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.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.After;
 import org.junit.Before;
@@ -107,15 +109,17 @@
         extractor.extractOrCopy();
         LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
         
-        registries = new Registries();
+        SchemaManager sm = new DefaultSchemaManager( loader );
 
-        List<Throwable> errors = loader.loadAllEnabled( registries, true );
-        
-        if ( errors.size() != 0 )
+        boolean loaded = sm.loadAllEnabled();
+
+        if ( !loaded )
         {
-            fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+            fail( "Schema load failed : " + ExceptionUtils.printErrors( sm.getErrors() ) );
         }
 
+        registries = sm.getRegistries();
+        
         attributeRegistry = registries.getAttributeTypeRegistry();
     }
 

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/DirectoryService.java Fri Oct 30 16:20:42 2009
@@ -20,7 +20,10 @@
 package org.apache.directory.server.core;
 
 
-import org.apache.directory.server.core.LdapPrincipal;
+import java.io.File;
+import java.util.List;
+import java.util.Set;
+
 import org.apache.directory.server.core.changelog.ChangeLog;
 import org.apache.directory.server.core.entry.ServerEntry;
 import org.apache.directory.server.core.entry.ServerEntryFactory;
@@ -37,10 +40,6 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 
-import java.io.File;
-import java.util.List;
-import java.util.Set;
-
 
 /**
  * Provides JNDI service to {@link AbstractContextFactory}.

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java Fri Oct 30 16:20:42 2009
@@ -21,16 +21,12 @@
 
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 import java.util.Set;
-import java.util.Stack;
 
 import javax.naming.NamingException;
 
@@ -43,15 +39,10 @@
 import org.apache.directory.server.core.partition.Partition;
 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.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.LdapSyntax;
-import org.apache.directory.shared.ldap.schema.MatchingRule;
-import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.ObjectClass;
-import org.apache.directory.shared.ldap.schema.SyntaxChecker;
 import org.apache.directory.shared.ldap.schema.parsers.LdapComparatorDescription;
 import org.apache.directory.shared.ldap.schema.parsers.NormalizerDescription;
 import org.apache.directory.shared.ldap.schema.parsers.SyntaxCheckerDescription;
@@ -60,7 +51,6 @@
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.shared.ldap.util.Base64;
-import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -100,7 +90,6 @@
     
     public PartitionSchemaLoader( Partition partition, Registries registries ) throws Exception
     {
-        super( new SchemaEntityFactory() );
         this.partition = partition;
         atRegistry = registries.getAttributeTypeRegistry();
         
@@ -192,73 +181,26 @@
 
     }
     
+    
     /**
-     * Utility method to load all enabled schemas into this registry.
-     * 
-     * @param targetRegistries
-     * @throws NamingException
+     * Helper class used to update the static DNs for each kind of Schema Object
      */
-    public void loadEnabled( Registries targetRegistries ) throws Exception
+    private LdapDN updateDNs( Map<String, LdapDN> staticDNs, String path, Schema schema ) throws NamingException
     {
-        /* 
-         * We need to load all names and oids into the oid registry regardless of
-         * the entity being in an enabled schema.  This is necessary because we 
-         * search for values in the schema partition that represent matchingRules
-         * and other entities that are not loaded.  While searching these values
-         * in disabled schemas normalizers will attempt to equate names with oids
-         * and if there is an unrecognized value by a normalizer then the search 
-         * will fail.
-         * 
-         * For example there is a NameOrNumericOidNormalizer that will reduce a 
-         * numeric OID or a non-numeric OID to it's numeric form using the OID 
-         * registry.  While searching the schema partition for attributeTypes we
-         * might find values of matchingRules in the m-ordering, m-equality, and
-         * m-substr attributes of metaAttributeType definitions.  Now if an entry
-         * references a matchingRule that has not been loaded then the 
-         * NameOrNumericOidNormalizer will bomb out when it tries to resolve 
-         * names of matchingRules in unloaded schemas to OID values using the 
-         * OID registry.  To prevent this we need to load all the OID's in advance
-         * regardless of whether they are used or not.
-         */
-        EntryFilteringCursor cursor = dao.listAllNames();
-        
-        // @TODO WARNING: this does not work figure out what we need to do  
-        // with this OID registry registration below that we commented out.
-        
-        while ( cursor.next() )
-        {
-            ServerEntry entry = cursor.get();
-            String oid = entry.get( mOidAT ).getString();
-            EntryAttribute names = entry.get( mNameAT );
-            //targetRegistries.getOidRegistry().register( oid, oid );
-            
-            for ( Value<?> value:names )
-            {
-                //targetRegistries.getOidRegistry().register( value.getString(), oid );
-            }
-        }
+        LdapDN dn = staticDNs.get( schema.getSchemaName() );
         
-        cursor.close();
-        
-        
-        Map<String, Schema> allSchemaMap = getSchemas();
-        Set<Schema> enabledSchemaSet = new HashSet<Schema>();
-
-        for ( Schema schema: allSchemaMap.values() )
+        if ( dn == null )
         {
-            if ( ! schema.isDisabled() )
-            {
-                LOG.debug( "will attempt to load enabled schema: {}", schema.getSchemaName() );
-                    
-                enabledSchemaSet.add( schema );
-            }
-            else
-            {
-                LOG.debug( "will NOT attempt to load disabled schema: {}", schema.getSchemaName() );
-            }
+            dn = new LdapDN( 
+                path,
+                "cn=" + schema.getSchemaName(),
+                SchemaConstants.OU_SCHEMA );
+            
+            dn.normalize( atRegistry.getNormalizerMapping() );
+            staticDNs.put( schema.getSchemaName(), dn );
         }
-
-        loadWithDependencies( enabledSchemaSet, targetRegistries, true );
+        
+        return dn;
     }
     
     
@@ -335,43 +277,6 @@
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public final List<Throwable> loadWithDependencies( Collection<Schema> schemas, Registries targetRegistries, boolean check ) throws Exception
-    {
-        // Relax the controls at first
-        List<Throwable> errors = new ArrayList<Throwable>();
-        boolean wasRelaxed = targetRegistries.isRelaxed();
-        targetRegistries.setRelaxed( true );
-
-        HashMap<String,Schema> notLoaded = new HashMap<String,Schema>();
-
-        for ( Schema schema : schemas )
-        {
-            notLoaded.put( schema.getSchemaName(), schema );
-        }
-
-        Iterator<Schema> list = notLoaded.values().iterator();
-        
-        while ( list.hasNext() )
-        {
-            Schema schema = list.next();
-            loadDepsFirst( schema, new Stack<String>(), notLoaded, schema, targetRegistries );
-            list = notLoaded.values().iterator();
-        }
-
-        // At the end, check the registries if required
-        if ( check )
-        {
-            errors = targetRegistries.checkRefInteg();
-        }
-        
-        // Restore the Registries isRelaxed flag
-        targetRegistries.setRelaxed( wasRelaxed );
-        
-        return errors;
-    }
 
     /**
      * {@inheritDoc}
@@ -393,281 +298,125 @@
         
         LOG.debug( "loading {} schema ...", schema.getSchemaName() );
         
-        loadComparators( schema, targetRegistries );
-        loadNormalizers( schema, targetRegistries );
-        loadSyntaxCheckers( schema, targetRegistries );
-        loadSyntaxes( schema, targetRegistries );
-        loadMatchingRules( schema, targetRegistries );
-        loadAttributeTypes( schema, targetRegistries );
-        loadObjectClasses( schema, targetRegistries );
-        loadMatchingRuleUses( schema, targetRegistries );
-        loadDitContentRules( schema, targetRegistries );
-        loadNameForms( schema, targetRegistries );
+        loadComparators( schema );
+        loadNormalizers( schema );
+        loadSyntaxCheckers( schema );
+        loadSyntaxes( schema );
+        loadMatchingRules( schema );
+        loadAttributeTypes( schema );
+        loadObjectClasses( schema );
+        loadMatchingRuleUses( schema );
+        loadDitContentRules( schema );
+        loadNameForms( schema );
         
         // order does matter here so some special trickery is needed
         // we cannot load a DSR before the DSRs it depends on are loaded?
         // TODO need to confirm this ( or we must make the class for this and use deferred 
         // resolution until everything is available?
         
-        loadDitStructureRules( schema, targetRegistries );
+        loadDitStructureRules( schema );
         
         notifyListenerOrRegistries( schema, targetRegistries );
     }
 
     
-    private void loadMatchingRuleUses( Schema schema, Registries targetRegistries )
-    {
-        // TODO Auto-generated method stub
-    }
-
-
-    private void loadDitStructureRules( Schema schema, Registries targetRegistries )
-    {
-        // TODO Auto-generated method stub
-    }
-
-
-    private void loadNameForms( Schema schema, Registries targetRegistries )
-    {
-        // TODO Auto-generated method stub
-    }
-
-
-    private void loadDitContentRules( Schema schema, Registries targetRegistries )
-    {
-        // TODO Auto-generated method stub
-    }
-
-
-    private void loadObjectClasses( Schema schema, Registries targetRegistries ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadAttributeTypes( Schema schema ) throws Exception
     {
-        /**
-         * Sometimes search may return child objectClasses before their superiors have
-         * been registered like with attributeTypes.  To prevent this from bombing out
-         * the loader we will defer the registration of elements until later.
-         */
-        LinkedList<ObjectClass> deferred = new LinkedList<ObjectClass>();
-
-        LdapDN dn = staticObjectClassesDNs.get( schema.getSchemaName() );
+        LinkedList<AttributeType> deferred = new LinkedList<AttributeType>();
         
-        if ( dn == null )
-        {
-            dn = new LdapDN( 
-                SchemaConstants.OBJECT_CLASSES_PATH, 
-                "cn", schema.getSchemaName(),
-                SchemaConstants.OU_SCHEMA );
-            
-            dn.normalize( atRegistry.getNormalizerMapping() );
-            staticObjectClassesDNs.put( schema.getSchemaName(), dn );
-        }
+        LdapDN dn = updateDNs( staticAttributeTypeDNs, SchemaConstants.ATTRIBUTES_TYPE_PATH, schema );
         
+        List<Entry> attributeTypeList = new ArrayList<Entry>();
+
+        // Check that we don't have an entry in the Dit for this schema
         if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
         {
-            return;
+            // No : get out, no AttributeType to load
+            return attributeTypeList;
         }
         
-        LOG.debug( "{} schema: loading objectClasses", schema.getSchemaName() );
+        LOG.debug( "{} schema: loading attributeTypes", schema.getSchemaName() );
         
         EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
         
+        // Loop on all the AttributeTypes and add them to the list
         while ( list.next() )
         {
-            ClonedServerEntry result = list.get();
-            LdapDN resultDN = result.getDn();
-            resultDN.normalize( atRegistry.getNormalizerMapping() );
-            ClonedServerEntry entry = lookupPartition( resultDN );
+            ServerEntry result = list.get();
             
-            registerObjectClass( targetRegistries, entry, schema );
+            attributeTypeList.add( result );
         }
         
-        LOG.debug( "Deferred queue size = {}", deferred.size() );
-        
-        if ( LOG.isDebugEnabled() )
-        {
-            StringBuffer buf = new StringBuffer();
-            buf.append( "Deferred queue contains: " );
-            
-            for ( ObjectClass extra : deferred )
-            {
-                buf.append( extra.getName() );
-                buf.append( '[' );
-                buf.append( extra.getOid() );
-                buf.append( "]" );
-                buf.append( "\n" );
-            }
-        }
-        
-        int lastCount = deferred.size();
-        
-        while ( ! deferred.isEmpty() )
-        {
-            LOG.debug( "Deferred queue size = {}", deferred.size() );
-            ObjectClass oc = deferred.removeFirst();
-            Exception lastException = null;
-            
-            try
-            {
-                targetRegistries.getObjectClassRegistry().register( oc );
-            }
-            catch ( Exception ne )
-            {
-                deferred.addLast( oc );
-                lastException = ne;
-            }
-            
-            // if we shrank the deferred list we're doing good and can continue
-            if ( deferred.size() < lastCount )
-            {
-                lastCount = deferred.size();
-            }
-            else
-            {
-                StringBuffer buf = new StringBuffer();
-                buf.append( "A cycle must exist somewhere within the objectClasses of the " );
-                buf.append( schema.getSchemaName() );
-                buf.append( " schema.  We cannot seem to register the following objectClasses:\n" );
-                
-                for ( ObjectClass extra : deferred )
-                {
-                    buf.append( extra.getName() );
-                    buf.append( '[' );
-                    buf.append( extra.getOid() );
-                    buf.append( "]" );
-                    buf.append( "\n" );
-                }
-                
-                NamingException ne = new NamingException( buf.toString() );
-                ne.setRootCause( lastException );
-            }
-        }
+        return attributeTypeList;
     }
 
 
-    private void loadAttributeTypes( Schema schema, Registries targetRegistries ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadComparators( Schema schema ) throws Exception
     {
-        LinkedList<AttributeType> deferred = new LinkedList<AttributeType>();
-        
-        LdapDN dn = staticAttributeTypeDNs.get( schema.getSchemaName() );
-        
-        if ( dn == null )
-        {
-            dn = new LdapDN( 
-                SchemaConstants.ATTRIBUTES_TYPE_PATH,
-                "cn=" + schema.getSchemaName(),
-                SchemaConstants.OU_SCHEMA );
-            
-            dn.normalize( atRegistry.getNormalizerMapping() );
-            staticAttributeTypeDNs.put( schema.getSchemaName(), dn );
-        }
+        LdapDN dn = updateDNs( staticComparatorsDNs, SchemaConstants.COMPARATORS_PATH, schema );
         
+        List<Entry> comparatorList = new ArrayList<Entry>();
+
         if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
         {
-            return;
+            return comparatorList;
         }
         
-        LOG.debug( "{} schema: loading attributeTypes", schema.getSchemaName() );
+        LOG.debug( "{} schema: loading comparators", schema.getSchemaName() );
         
         EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
         
         while ( list.next() )
         {
-            ServerEntry result = list.get();
-            LdapDN resultDN = result.getDn();
-            resultDN.normalize( atRegistry.getNormalizerMapping() );
-            ServerEntry attrs = lookupPartition( resultDN );
-            AttributeType at = factory.getAttributeType( attrs, targetRegistries, schema.getSchemaName() );
+            ClonedServerEntry entry = list.get();
             
-            try
-            {
-                targetRegistries.getAttributeTypeRegistry().register( at );
-            }
-            catch ( Exception ne )
-            {
-                deferred.add( at );
-            }
+            comparatorList.add( entry );
         }
+        
+        return comparatorList;
+    }
 
-        LOG.debug( "Deferred queue size = {}", deferred.size() );
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadDitContentRules( Schema schema ) throws Exception
+    {
+        LOG.error( "DitContentRule loading NYI" );
         
-        if ( LOG.isDebugEnabled() )
-        {
-            StringBuffer buf = new StringBuffer();
-            buf.append( "Deferred queue contains: " );
-            
-            for ( AttributeType extra : deferred )
-            {
-                buf.append( extra.getName() );
-                buf.append( '[' );
-                buf.append( extra.getOid() );
-                buf.append( "]" );
-                buf.append( "\n" );
-            }
-        }
-        
-        int lastCount = deferred.size();
-        
-        while ( ! deferred.isEmpty() )
-        {
-            LOG.debug( "Deferred queue size = {}", deferred.size() );
-            AttributeType at = deferred.removeFirst();
-            Exception lastException = null;
-            
-            try
-            {
-                targetRegistries.getAttributeTypeRegistry().register( at );
-            }
-            catch ( Exception ne )
-            {
-                deferred.addLast( at );
-                lastException = ne;
-            }
-            
-            // if we shrank the deferred list we're doing good and can continue
-            if ( deferred.size() < lastCount )
-            {
-                lastCount = deferred.size();
-            }
-            else
-            {
-                StringBuffer buf = new StringBuffer();
-                buf.append( "A cycle must exist somewhere within the attributeTypes of the " );
-                buf.append( schema.getSchemaName() );
-                buf.append( " schema.  We cannot seem to register the following attributeTypes:\n" );
-                
-                for ( AttributeType extra : deferred )
-                {
-                    buf.append( extra.getName() );
-                    buf.append( '[' );
-                    buf.append( extra.getOid() );
-                    buf.append( "]" );
-                    buf.append( "\n" );
-                }
-                
-                NamingException ne = new NamingException( buf.toString() );
-                ne.setRootCause( lastException );
-            }
-        }
+        return null;
     }
 
 
-    private void loadMatchingRules( Schema schema, Registries targetRegistries ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadDitStructureRules( Schema schema ) throws Exception
     {
-        LdapDN dn = staticMatchingRulesDNs.get( schema.getSchemaName() );
+        LOG.error( "DitStructureRule loading NYI" );
         
-        if ( dn == null )
-        {
-            dn = new LdapDN( 
-                SchemaConstants.MATCHING_RULES_PATH,
-                "cn=" + schema.getSchemaName(),
-                SchemaConstants.OU_SCHEMA );
-            
-            dn.normalize( atRegistry.getNormalizerMapping() );
-            staticMatchingRulesDNs.put( schema.getSchemaName(), dn );
-        }
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadMatchingRules( Schema schema ) throws Exception
+    {
+        LdapDN dn = updateDNs( staticMatchingRulesDNs, SchemaConstants.MATCHING_RULES_PATH, schema );
         
+        List<Entry> matchingRuleList = new ArrayList<Entry>();
+
         if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
         {
-            return;
+            return matchingRuleList;
         }
         
         LOG.debug( "{} schema: loading matchingRules", schema.getSchemaName() );
@@ -676,129 +425,150 @@
         
         while ( list.next() )
         {
-            ServerEntry result = list.get();
-            LdapDN resultDN = result.getDn();
-            resultDN.normalize( atRegistry.getNormalizerMapping() );
-            ServerEntry attrs = lookupPartition( resultDN );
-            MatchingRule mrule = factory.getMatchingRule( attrs, targetRegistries, schema.getSchemaName() );
-            targetRegistries.getMatchingRuleRegistry().register( mrule );
+            ServerEntry entry = list.get();
 
+            matchingRuleList.add( entry );
         }
+        
+        return matchingRuleList;
+    }
+    
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadMatchingRuleUses( Schema schema ) throws Exception
+    {
+        LOG.error( "MatchingRuleUse loading NYI" );
+        
+        return null;
     }
 
 
-    private void loadSyntaxes( Schema schema, Registries targetRegistries ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadNameForms( Schema schema ) throws Exception
     {
-        LdapDN dn = staticSyntaxesDNs.get( schema.getSchemaName() );
+        LOG.error( "NameForm loading NYI" );
         
-        if ( dn == null )
-        {
-            dn = new LdapDN( 
-                SchemaConstants.SYNTAXES_PATH,
-                "cn=" + schema.getSchemaName(),
-                SchemaConstants.OU_SCHEMA );
-            
-            dn.normalize( atRegistry.getNormalizerMapping() );
-            staticSyntaxesDNs.put( schema.getSchemaName(), dn );
-        }
+        return null;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadNormalizers( Schema schema ) throws Exception
+    {
+        LdapDN dn = updateDNs( staticNormalizersDNs, SchemaConstants.NORMALIZERS_PATH, schema );
         
+        List<Entry> normalizerList = new ArrayList<Entry>();
+
         if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
         {
-            return;
+            return normalizerList;
         }
         
-        LOG.debug( "{} schema: loading syntaxes", schema.getSchemaName() );
+        LOG.debug( "{} schema: loading normalizers", schema.getSchemaName() );
         
         EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
         
         while ( list.next() )
         {
-            ServerEntry result = list.get();
-            LdapDN resultDN = result.getDn();
-            resultDN.normalize( atRegistry.getNormalizerMapping() );
-            ServerEntry attrs = lookupPartition( resultDN );
-            LdapSyntax syntax = factory.getSyntax( attrs, targetRegistries, schema.getSchemaName() );
-            targetRegistries.getLdapSyntaxRegistry().register( syntax );
+            ClonedServerEntry entry = list.get();
+            
+            normalizerList.add( entry );
         }
+        
+        return normalizerList;
     }
 
 
-    private void loadSyntaxCheckers( Schema schema, Registries targetRegistries ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadObjectClasses( Schema schema ) throws Exception
     {
-        LdapDN dn = staticSyntaxCheckersDNs.get( schema.getSchemaName() );
-        
-        if ( dn == null )
-        {
-            dn = new LdapDN( 
-                SchemaConstants.SYNTAX_CHECKERS_PATH,
-                "cn=" + schema.getSchemaName(),
-                SchemaConstants.OU_SCHEMA );
-            
-            dn.normalize( atRegistry.getNormalizerMapping() );
-            staticSyntaxCheckersDNs.put( schema.getSchemaName(), dn );
-        }
+        LdapDN dn = updateDNs( staticObjectClassesDNs, SchemaConstants.OBJECT_CLASSES_PATH, schema );
         
+        List<Entry> objectClassList = new ArrayList<Entry>();
+
         if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
         {
-            return;
+            return objectClassList;
         }
         
-        LOG.debug( "{} schema: loading syntaxCsheckers", schema.getSchemaName() );
+        LOG.debug( "{} schema: loading objectClasses", schema.getSchemaName() );
         
         EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
         
         while ( list.next() )
         {
-            ServerEntry result = list.get();
-            LdapDN resultDN = result.getDn();
-            resultDN.normalize( atRegistry.getNormalizerMapping() );
-            ServerEntry attrs = lookupPartition( resultDN );
-            SyntaxChecker sc = factory.getSyntaxChecker( attrs, targetRegistries, schema.getSchemaName() );
-            SyntaxCheckerDescription syntaxCheckerDescription = 
-                getSyntaxCheckerDescription( schema.getSchemaName(), attrs );
-            // @TODO elecharny what should I do with the description
+            ClonedServerEntry entry = list.get();
             
-            targetRegistries.getSyntaxCheckerRegistry().register( sc );
+            objectClassList.add( entry );
         }
+        
+        return objectClassList;
     }
 
 
-    private void loadNormalizers( Schema schema, Registries targetRegistries ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadSyntaxes( Schema schema ) throws Exception
     {
-        LdapDN dn = staticNormalizersDNs.get( schema.getSchemaName() );
+        LdapDN dn = updateDNs( staticSyntaxesDNs, SchemaConstants.SYNTAXES_PATH, schema );
         
-        if ( dn == null )
+        List<Entry> syntaxList = new ArrayList<Entry>();
+
+        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
         {
-            dn = new LdapDN( 
-                SchemaConstants.NORMALIZERS_PATH,
-                "cn=" + schema.getSchemaName(),
-                SchemaConstants.OU_SCHEMA );
+            return syntaxList;
+        }
+        
+        LOG.debug( "{} schema: loading syntaxes", schema.getSchemaName() );
+        
+        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
+        
+        while ( list.next() )
+        {
+            ServerEntry entry = list.get();
             
-            dn.normalize( atRegistry.getNormalizerMapping() );
-            staticNormalizersDNs.put( schema.getSchemaName(), dn );
+            syntaxList.add( entry );
         }
         
+        return syntaxList;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public List<Entry> loadSyntaxCheckers( Schema schema ) throws Exception
+    {
+        LdapDN dn = updateDNs( staticSyntaxCheckersDNs, SchemaConstants.SYNTAX_CHECKERS_PATH, schema );
+        
+        List<Entry> syntaxCheckerList = new ArrayList<Entry>();
+
         if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
         {
-            return;
+            return syntaxCheckerList;
         }
         
-        LOG.debug( "{} schema: loading normalizers", schema.getSchemaName() );
+        LOG.debug( "{} schema: loading syntaxCsheckers", schema.getSchemaName() );
         
         EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
         
         while ( list.next() )
         {
-            ClonedServerEntry result = list.get();
-            LdapDN resultDN = result.getDn();
-            resultDN.normalize( atRegistry.getNormalizerMapping() );
-            ServerEntry attrs = lookupPartition( resultDN );
-            Normalizer normalizer = factory.getNormalizer( attrs, targetRegistries,schema.getSchemaName() );
-            NormalizerDescription normalizerDescription = getNormalizerDescription( schema.getSchemaName(), attrs );
-            // @TODO elecharny what should I do with the description
+            ServerEntry entry = list.get();
             
-            targetRegistries.getNormalizerRegistry().register( normalizer );
+            syntaxCheckerList.add( entry );
         }
+        
+        return syntaxCheckerList;
     }
 
 
@@ -847,46 +617,6 @@
     }
     
     
-    @SuppressWarnings("unchecked")
-    private void loadComparators( Schema schema, Registries targetRegistries ) throws Exception
-    {
-        LdapDN dn = staticComparatorsDNs.get( schema.getSchemaName() );
-        
-        if ( dn == null )
-        {
-            dn = new LdapDN( 
-                SchemaConstants.COMPARATORS_PATH,
-                "cn=" + schema.getSchemaName(),
-                SchemaConstants.OU_SCHEMA );
-            
-            dn.normalize( atRegistry.getNormalizerMapping() );
-            staticComparatorsDNs.put( schema.getSchemaName(), dn );
-        }
-
-        if ( ! partition.hasEntry( new EntryOperationContext( null, dn ) ) )
-        {
-            return;
-        }
-        
-        LOG.debug( "{} schema: loading comparators", schema.getSchemaName() );
-        
-        EntryFilteringCursor list = partition.list( new ListOperationContext( null, dn ) );
-        
-        while ( list.next() )
-        {
-            ClonedServerEntry result = list.get();
-            LdapDN resultDN = result.getDn();
-            resultDN.normalize( atRegistry.getNormalizerMapping() );
-            ClonedServerEntry entry = lookupPartition( resultDN );
-            
-            LdapComparatorDescription comparatorDescription = getLdapComparatorDescription( schema.getSchemaName(), entry );
-            // @TODO elecharny what should I do with description
-            
-            registerComparator( targetRegistries, entry, schema );
-        }
-    }
-
-
     private LdapComparatorDescription getLdapComparatorDescription( String schemaName, ServerEntry entry ) throws Exception
     {
     	LdapComparatorDescription description = new LdapComparatorDescription( getOid( entry ) );
@@ -941,34 +671,6 @@
         return description;
     }
 
-    
-    /**
-     * {@inheritDoc}
-     */
-    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 );
-
-        HashMap<String,Schema> notLoaded = new HashMap<String,Schema>();
-        notLoaded.put( schema.getSchemaName(), schema );                        
-        Properties props = new Properties();
-        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;
-    }
-
 
     /**
      * @return the dao

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/SchemaPartition.java Fri Oct 30 16:20:42 2009
@@ -55,10 +55,10 @@
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.message.control.CascadeControl;
 import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.SchemaUtils;
 import org.apache.directory.shared.ldap.schema.comparators.SerializableComparator;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
-import org.apache.directory.shared.ldap.schema.registries.SchemaLoader;
 import org.apache.directory.shared.ldap.util.DateUtils;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.slf4j.Logger;
@@ -117,8 +117,8 @@
     /** the wrapped Partition */
     private Partition wrapped = new NullPartition();
     
-    /** schema loader: swapped out after {@link SchemaPartition#initialize()} */
-    private SchemaLoader loader;
+    /** schema manager */
+    private SchemaManager schemaManager;
     
     /** registry synchronizer adaptor */
     private RegistrySynchronizerAdaptor synchronizer;
@@ -242,8 +242,7 @@
             wrapped.initialize();
             
             PartitionSchemaLoader partitionLoader = new PartitionSchemaLoader( wrapped, registries );
-            synchronizer = new RegistrySynchronizerAdaptor( registries, partitionLoader );
-            loader = partitionLoader;
+            synchronizer = new RegistrySynchronizerAdaptor( schemaManager );
             
             if ( wrapped instanceof NullPartition )
             {
@@ -261,11 +260,11 @@
         // Load the registries. We use a permissive registries at this point
         // so even if the schema are not ordered or the SchemaObjects are not
         // ordered in the schemas, we can still load them all.
-        List<Throwable> errors = loader.loadAllEnabled( registries, true );
-        
-        if ( errors.size() != 0 )
+        boolean loaded = schemaManager.loadAllEnabled();
+
+        if ( !loaded )
         {
-            throw new RuntimeException( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
+            throw new RuntimeException( "Schema load failed : " + ExceptionUtils.printErrors( schemaManager.getErrors() ) );
         }
         
         schemaModificationDN = new LdapDN( ServerDNConstants.SCHEMA_MODIFICATIONS_DN );
@@ -518,20 +517,20 @@
 
 
     /**
-     * @param loader the loader to set
+     * @param schemaManager the SchemaManager to set
      */
-    public void setLoader( SchemaLoader loader )
+    public void setSchemaManager( SchemaManager schemaManager )
     {
-        this.loader = loader;
+        this.schemaManager = schemaManager;
     }
     
     
     /**
-     * @return The schemapartition loader
+     * @return The schemaManager
      */
-    public SchemaLoader getLoader()
+    public SchemaManager getSchemaManager()
     {
-        return loader;
+        return schemaManager;
     }
     
     

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java Fri Oct 30 16:20:42 2009
@@ -99,19 +99,7 @@
         // Don't inject the modified element if the schema is disabled
         if ( isSchemaEnabled( schemaName ) )
         {
-            atRegistry.register( at );
-            
-            // Update the referenced objects
-            // The Syntax,
-            registries.addReference( at, at.getSyntax() );
-
-            // The Superior if any
-            registries.addReference( at, at.getSuperior() );
-
-            // The MatchingRules
-            registries.addReference( at, at.getEquality() );
-            registries.addReference( at, at.getOrdering() );
-            registries.addReference( at, at.getSubstring() );
+            registries.register( at );
 
             LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java Fri Oct 30 16:20:42 2009
@@ -33,7 +33,6 @@
 import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
 import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
 import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
-import org.apache.directory.server.core.schema.PartitionSchemaLoader;
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
@@ -44,6 +43,7 @@
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.slf4j.Logger;
@@ -118,10 +118,10 @@
     }
 
 
-    public RegistrySynchronizerAdaptor( Registries registries, PartitionSchemaLoader loader ) throws Exception
+    public RegistrySynchronizerAdaptor( SchemaManager schemaManager ) throws Exception
     {
-        this.registries = registries;
-        this.schemaSynchronizer = new SchemaSynchronizer( registries, loader );
+        this.registries = schemaManager.getRegistries();
+        this.schemaSynchronizer = new SchemaSynchronizer( schemaManager );
         this.objectClassAT = this.registries.getAttributeTypeRegistry()
             .lookup( SchemaConstants.OBJECT_CLASS_AT );
         

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java Fri Oct 30 16:20:42 2009
@@ -23,8 +23,6 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
-import java.util.Set;
 
 import javax.naming.NamingException;
 
@@ -37,19 +35,18 @@
 import org.apache.directory.server.core.entry.ServerModification;
 import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
 import org.apache.directory.server.core.partition.ByPassConstants;
-import org.apache.directory.server.core.schema.PartitionSchemaLoader;
 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.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
-import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
 import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 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.SchemaManager;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.SchemaObjectType;
 import org.apache.directory.shared.ldap.schema.SchemaWrapper;
@@ -64,6 +61,9 @@
 
 
 /**
+ * This class handle modifications made on a global schema. Modifications made
+ * on SchemaObjects are handled by the specific shcemaObject synchronizers.
+ * 
  * @TODO poorly implemented - revisit the SchemaChangeHandler for this puppy
  * and do it right.
  *
@@ -76,7 +76,9 @@
     private static final Logger LOG = LoggerFactory.getLogger( SchemaSynchronizer.class );
 
     private final SchemaEntityFactory factory;
-    private final PartitionSchemaLoader loader;
+    //private final PartitionSchemaLoader loader;
+    
+    private final SchemaManager schemaManager;
     
     /** The global registries */
     private final Registries registries;
@@ -106,11 +108,11 @@
      * @param loader The schema loader
      * @throws Exception If something went wrong
      */
-    public SchemaSynchronizer( Registries registries, PartitionSchemaLoader loader ) throws Exception
+    public SchemaSynchronizer( SchemaManager schemaManager ) throws Exception
     {
-        this.registries = registries;
+        this.registries = schemaManager.getRegistries();
+        this.schemaManager = schemaManager;
         disabledAT = registries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_DISABLED_AT );
-        this.loader = loader;
         factory = new SchemaEntityFactory();
         cnAT = registries.getAttributeTypeRegistry().lookup( SchemaConstants.CN_AT );
         dependenciesAT = registries.getAttributeTypeRegistry()
@@ -124,7 +126,11 @@
 
 
     /**
-     * {@inheritDoc}
+     * The only modification done on a schema element is on the m-disabled 
+     * attributeType
+     * 
+     * Depending in the existence of this attribute in the previous entry, we will
+     * have to update the entry or not.
      */
     public boolean modify( ModifyOperationContext opContext, ServerEntry targetEntry, boolean cascade ) throws Exception
     {
@@ -136,6 +142,7 @@
         EntryAttribute disabledInEntry = entry.get( disabledAT );
         Modification disabledModification = ServerEntryUtils.getModificationItem( mods, disabledAT );
         
+        // The attribute might be present, but that does not mean we will change it.
         if ( disabledModification != null )
         {
             // We are trying to modify the m-disabled attribute. 
@@ -144,26 +151,6 @@
             
             hasModification = modifyDisable( opContext, modification, attribute, disabledInEntry );
         }
-
-        // check if the new schema is enabled or disabled
-        boolean isEnabled = false;
-        EntryAttribute disabled = targetEntry.get( disabledAT );
-        
-        if ( disabled == null )
-        {
-            isEnabled = true;
-        }
-        else if ( ! disabled.contains( "TRUE" ) )
-        {
-            isEnabled = true;
-        }
-
-        ServerAttribute dependencies = ServerEntryUtils.getAttribute( mods, dependenciesAT );
-        
-        if ( dependencies != null )
-        {
-            checkForDependencies( isEnabled, targetEntry );
-        }
         
         return hasModification;
     }
@@ -258,7 +245,7 @@
 
         // Before allowing a schema object to be deleted we must check
         // to make sure it's not depended upon by another schema
-        Set<String> dependents = loader.listDependentSchemaNames( schemaName );
+        /*Set<String> dependents = schemaManager.listDependentSchemaNames( schemaName );
         
         if ( ! dependents.isEmpty() )
         {
@@ -271,7 +258,8 @@
         
         // no need to check if schema is enabled or disabled here
         // if not in the loaded set there will be no negative effect
-        registries.schemaUnloaded( loader.getSchema( schemaName ) );
+        registries.schemaUnloaded( schemaManager.getSchema( schemaName ) );
+        */
     }
 
 
@@ -316,8 +304,9 @@
          */
         
         // step [1]
+        /*
         String schemaName = getSchemaName( entry.getDn() );
-        Set<String> dependents = loader.listDependentSchemaNames( schemaName );
+        Set<String> dependents = schemaManager.listDependentSchemaNames( schemaName );
         if ( ! dependents.isEmpty() )
         {
             throw new LdapOperationNotSupportedException( 
@@ -360,6 +349,7 @@
         renameSchema( registries.getNameFormRegistry(), schemaName, newSchemaName );
         renameSchema( registries.getObjectClassRegistry(), schemaName, newSchemaName );
         renameSchema( registries.getLdapSyntaxRegistry(), schemaName, newSchemaName );
+        */
     }
     
 
@@ -560,6 +550,19 @@
 
     private boolean disableSchema( CoreSession session, String schemaName ) throws Exception
     {
+        Schema schema = registries.getLoadedSchema( schemaName );
+
+        if ( schema == null )
+        {
+            // This is not possible. We can't enable a schema which is not loaded.
+            String msg = "Unwilling to enable a not loaded schema: " + schemaName;
+            LOG.error( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        return schemaManager.disable( schemaName );
+
+        /*
         // First check that the schema is not already disabled
         Map<String, Schema> schemas = registries.getLoadedSchemas();
         
@@ -571,7 +574,7 @@
             return SCHEMA_UNCHANGED;
         }
         
-        Set<String> dependents = loader.listEnabledDependentSchemaNames( schemaName );
+        Set<String> dependents = schemaManager.listEnabledDependentSchemaNames( schemaName );
         
         if ( ! dependents.isEmpty() )
         {
@@ -596,6 +599,7 @@
         }
         
         return SCHEMA_MODIFIED;
+        */
     }
     
     
@@ -624,10 +628,11 @@
 
     /**
      * Enabling a schema consist on switching all of its schema element to enable.
+     * We have to do it on a temporary registries.
      */
     private boolean enableSchema( String schemaName ) throws Exception
     {
-        Schema schema = loader.getSchema( schemaName );
+        Schema schema = registries.getLoadedSchema( schemaName );
 
         if ( schema == null )
         {
@@ -637,25 +642,7 @@
             throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
-        for ( SchemaWrapper schemaWrapper : schema.getContent() )
-        {
-            SchemaObject schemaObject = schemaWrapper.get();
-            
-            if ( schemaObject.isDisabled() )
-            {
-                //schemaObject.enable();
-        }
-            // TODO log warning: schemaName + " was already loaded"
-            schema.enable();
-            registries.schemaLoaded( schema );
-            return SCHEMA_UNCHANGED;
-        }
-
-        loader.loadWithDependencies( schema, registries, true );
-        schema = loader.getSchema( schemaName );
-        schema.enable();
-        
-        return SCHEMA_MODIFIED;
+        return schemaManager.enable( schemaName );
     }
 
 
@@ -670,6 +657,7 @@
      */
     private void checkForDependencies( boolean isEnabled, ServerEntry entry ) throws Exception
     {
+        /*
         EntryAttribute dependencies = entry.get( this.dependenciesAT );
 
         if ( dependencies == null )
@@ -696,7 +684,7 @@
         }
         else
         {
-            Set<String> allSchemas = loader.getSchemaNames();
+            Set<String> allSchemas = schemaManager.getSchemaNames();
             
             for ( Value<?> value:dependencies )
             {
@@ -710,6 +698,7 @@
                 }
             }
         }
+        */
     }
 
     

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java Fri Oct 30 16:20:42 2009
@@ -51,10 +51,11 @@
 import org.apache.directory.shared.ldap.entry.client.ClientStringValue;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+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.registries.Registries;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -69,7 +70,6 @@
 public class DefaultServerAttributeTest
 {
     private static LdifSchemaLoader loader;
-    private static Registries registries;
     
     private static AttributeType atCN;
     private static AttributeType atSN;
@@ -120,9 +120,11 @@
         SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
         extractor.extractOrCopy();
     	loader = new LdifSchemaLoader( schemaRepository );
-        registries = new Registries();
+        SchemaManager sm = new DefaultSchemaManager( loader );
 
-        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        sm.loadAllEnabled();
+        
+        List<Throwable> errors = sm.getErrors();
         
         if ( errors.size() != 0 )
         {
@@ -131,10 +133,10 @@
                 ExceptionUtils.printErrors( errors ) );
         }
         
-        atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
-        atC = registries.getAttributeTypeRegistry().lookup( "c" );
-        atSN = registries.getAttributeTypeRegistry().lookup( "sn" );
-        atPwd = registries.getAttributeTypeRegistry().lookup( "userpassword" );
+        atCN = sm.getRegistries().getAttributeTypeRegistry().lookup( "cn" );
+        atC = sm.getRegistries().getAttributeTypeRegistry().lookup( "c" );
+        atSN = sm.getRegistries().getAttributeTypeRegistry().lookup( "sn" );
+        atPwd = sm.getRegistries().getAttributeTypeRegistry().lookup( "userpassword" );
     }
 
     /**

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerEntryTest.java Fri Oct 30 16:20:42 2009
@@ -52,11 +52,13 @@
 import org.apache.directory.shared.ldap.entry.client.DefaultClientEntry;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+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.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -75,8 +77,8 @@
     private static final byte[] BYTES3 = new byte[]{ 'c' };
 
     private static LdifSchemaLoader loader;
-    private static Registries registries;
     private static AttributeTypeRegistry atr;
+    private static Registries registries;
     
     private static AttributeType atObjectClass;
     private static AttributeType atCN;
@@ -109,18 +111,21 @@
         SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
         extractor.extractOrCopy();
         loader = new LdifSchemaLoader( schemaRepository );
-        registries = new Registries();
 
-        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        SchemaManager sm = new DefaultSchemaManager( loader );
+        sm.loadAllEnabled();
+        
+        List<Throwable> errors = sm.getErrors();
         
         if ( errors.size() != 0 )
         {
             fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
         }
 
+        registries = sm.getRegistries(); 
         atr = registries.getAttributeTypeRegistry();
 
-        atObjectClass = registries.getAttributeTypeRegistry().lookup( "objectClass" );
+        atObjectClass = sm.getRegistries().getAttributeTypeRegistry().lookup( "objectClass" );
         atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
         atC = registries.getAttributeTypeRegistry().lookup( "c" );
         atL = registries.getAttributeTypeRegistry().lookup( "l" );

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerEntrySerializerTest.java Fri Oct 30 16:20:42 2009
@@ -31,12 +31,14 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 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.normalizers.DeepTrimToLowerNormalizer;
 import org.apache.directory.shared.ldap.schema.normalizers.OidNormalizer;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
 import org.apache.directory.shared.ldap.util.StringTools;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -76,13 +78,18 @@
         loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
         
-        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        SchemaManager sm = new DefaultSchemaManager( loader );
+        sm.loadAllEnabled();
+        
+        List<Throwable> errors = sm.getErrors();
         
         if ( errors.size() != 0 )
         {
             fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
         }
         
+        registries = sm.getRegistries();
+        
         oids = new HashMap<String, OidNormalizer>();
 
         // DC normalizer

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/ServerModificationTest.java Fri Oct 30 16:20:42 2009
@@ -43,9 +43,11 @@
 import org.apache.directory.shared.ldap.entry.client.ClientModification;
 import org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute;
 import org.apache.directory.shared.ldap.schema.AttributeType;
+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.registries.Registries;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -164,13 +166,17 @@
         loader = new LdifSchemaLoader( schemaRepository );
         registries = new Registries();
         
-        List<Throwable> errors = loader.loadAllEnabled( registries, true );
+        SchemaManager sm = new DefaultSchemaManager( loader );
+        sm.loadAllEnabled();
+        
+        List<Throwable> errors = sm.getErrors();
         
         if ( errors.size() != 0 )
         {
             fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
         }
 
+        registries = sm.getRegistries();
         atCN = registries.getAttributeTypeRegistry().lookup( "cn" );
         atC = registries.getAttributeTypeRegistry().lookup( "c" );
     }

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/main/java/org/apache/directory/server/core/integ/DirectoryServiceFactory.java Fri Oct 30 16:20:42 2009
@@ -37,9 +37,10 @@
 import org.apache.directory.server.core.schema.SchemaPartition;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+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.registries.Registries;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.JarLdifSchemaLoader;
 
 
@@ -74,7 +75,6 @@
             DirectoryService service = new DefaultDirectoryService();
             service.setWorkingDirectory( new File( workingDirectory ) );
             SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
-            Registries registries = service.getRegistries();
             
             // Init the LdifPartition
             LdifPartition ldifPartition = new LdifPartition();
@@ -86,11 +86,15 @@
             SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
             
             schemaPartition.setWrappedPartition( ldifPartition );
-            schemaPartition.setRegistries( registries );
             
             JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+            SchemaManager sm = new DefaultSchemaManager( loader );
 
-            List<Throwable> errors = loader.loadAllEnabled( registries, true );
+            boolean loaded = sm.loadAllEnabled();
+            schemaPartition.setRegistries( sm.getRegistries() );
+            schemaPartition.setSchemaManager( sm );
+            
+            List<Throwable> errors = sm.getErrors();
             
             if ( errors.size() != 0 )
             {
@@ -110,7 +114,7 @@
             systemPartition.setId( "system" );
             ((JdbmPartition)systemPartition).setCacheSize( 500 );
             systemPartition.setSuffix( ServerDNConstants.SYSTEM_DN );
-            systemPartition.setRegistries( registries );
+            systemPartition.setRegistries( sm.getRegistries() );
             ((JdbmPartition)systemPartition).setPartitionDir( new File( workingDirectory, "system" ) );
     
             // Add objectClass attribute for the system partition

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/authz/AutzIntegUtils.java Fri Oct 30 16:20:42 2009
@@ -53,9 +53,10 @@
 import org.apache.directory.server.xdbm.Index;
 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.registries.Registries;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.JarLdifSchemaLoader;
 
 
@@ -87,7 +88,6 @@
             DirectoryService service = new DefaultDirectoryService();
             service.setWorkingDirectory( new File( workingDirectory ) );
             SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
-            Registries registries = service.getRegistries();
             
             // Init the LdifPartition
             LdifPartition ldifPartition = new LdifPartition();
@@ -99,17 +99,23 @@
             SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
             
             schemaPartition.setWrappedPartition( ldifPartition );
-            schemaPartition.setRegistries( registries );
             
             JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+            
+            SchemaManager sm = new DefaultSchemaManager( loader );
 
-            List<Throwable> errors = loader.loadAllEnabled( registries, true );
+            sm.loadAllEnabled();
+            
+            List<Throwable> errors = sm.getErrors();
             
             if ( errors.size() != 0 )
             {
                 fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
             }
 
+            schemaPartition.setRegistries( sm.getRegistries() );
+            schemaPartition.setSchemaManager( sm );
+
             extractor.extractOrCopy();
 
             service.getChangeLog().setEnabled( true );
@@ -123,7 +129,7 @@
             systemPartition.setId( "system" );
             ((JdbmPartition)systemPartition).setCacheSize( 500 );
             systemPartition.setSuffix( ServerDNConstants.SYSTEM_DN );
-            systemPartition.setRegistries( registries );
+            systemPartition.setRegistries( sm.getRegistries() );
             ((JdbmPartition)systemPartition).setPartitionDir( new File( workingDirectory, "system" ) );
     
             // Add objectClass attribute for the system partition
@@ -156,7 +162,6 @@
             DirectoryService service = new DefaultDirectoryService();
             service.setWorkingDirectory( new File( workingDirectory ) );
             SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
-            Registries registries = service.getRegistries();
             
             // Init the LdifPartition
             LdifPartition ldifPartition = new LdifPartition();
@@ -168,16 +173,20 @@
             SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
             
             schemaPartition.setWrappedPartition( ldifPartition );
-            schemaPartition.setRegistries( registries );
             
             JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+            SchemaManager sm = new DefaultSchemaManager( loader );
 
-            List<Throwable> errors = loader.loadAllEnabled( registries, true );
+            sm.loadAllEnabled();
+            
+            List<Throwable> errors = sm.getErrors();
             
             if ( errors.size() != 0 )
             {
                 fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
             }
+            
+            schemaPartition.setRegistries( sm.getRegistries() );
 
             extractor.extractOrCopy();
 
@@ -192,7 +201,7 @@
             systemPartition.setId( "system" );
             ((JdbmPartition)systemPartition).setCacheSize( 500 );
             systemPartition.setSuffix( ServerDNConstants.SYSTEM_DN );
-            systemPartition.setRegistries( registries );
+            systemPartition.setRegistries( sm.getRegistries() );
             ((JdbmPartition)systemPartition).setPartitionDir( new File( workingDirectory, "system" ) );
     
             // Add objectClass attribute for the system partition

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/jndi/MixedCaseITest.java Fri Oct 30 16:20:42 2009
@@ -36,7 +36,6 @@
 import javax.naming.directory.Attribute;
 import javax.naming.directory.Attributes;
 import javax.naming.directory.BasicAttribute;
-import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
@@ -61,9 +60,11 @@
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.exception.LdapNameNotFoundException;
 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.registries.Registries;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.JarLdifSchemaLoader;
 import org.junit.Before;
 import org.junit.Test;
@@ -102,7 +103,6 @@
             DirectoryService service = new DefaultDirectoryService();
             service.setWorkingDirectory( new File( workingDirectory ) );
             SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
-            Registries registries = service.getRegistries();
             
             // Init the LdifPartition
             LdifPartition ldifPartition = new LdifPartition();
@@ -113,17 +113,23 @@
             SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
             
             schemaPartition.setWrappedPartition( ldifPartition );
-            schemaPartition.setRegistries( registries );
             
             JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
 
-            List<Throwable> errors = loader.loadAllEnabled( registries, true );
+            SchemaManager sm = new DefaultSchemaManager( loader );
+            
+            sm.loadAllEnabled();
+            
+            List<Throwable> errors = sm.getErrors();
             
             if ( errors.size() != 0 )
             {
                 fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
             }
-
+            
+            schemaPartition.setRegistries( sm.getRegistries() );
+            schemaPartition.setSchemaManager( sm );
+            
             extractor.extractOrCopy();
 
             service.getChangeLog().setEnabled( true );
@@ -137,7 +143,7 @@
             systemPartition.setId( "system" );
             ((JdbmPartition)systemPartition).setCacheSize( 500 );
             systemPartition.setSuffix( ServerDNConstants.SYSTEM_DN );
-            systemPartition.setRegistries( registries );
+            systemPartition.setRegistries( sm.getRegistries() );
             ((JdbmPartition)systemPartition).setPartitionDir( new File( workingDirectory, "system" ) );
     
             // Add objectClass attribute for the system partition
@@ -201,12 +207,11 @@
 
         String dn = "ou=Test";
 
-        Attributes attributes = new BasicAttributes( true );
-        Attribute attribute = new BasicAttribute( "objectClass" );
-        attribute.add( "top" );
-        attribute.add( "organizationalUnit" );
-        attributes.put( attribute );
-        attributes.put( "ou", "Test" );
+        Attributes attributes = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: organizationalUnit",
+            "ou: Test"
+            );
 
         DirContext ctx = ctxRoot.createSubcontext( dn, attributes );
         assertNotNull( ctx );
@@ -231,13 +236,12 @@
         String dn = "ou=Test";
         String description = "New Value";
 
-        Attributes attributes = new BasicAttributes( true );
-        Attribute attribute = new BasicAttribute( "objectClass" );
-        attribute.add( "top" );
-        attribute.add( "organizationalUnit" );
-        attributes.put( attribute );
-        attributes.put( "ou", "Test" );
-        attributes.put( "description", "Old Value" );
+        Attributes attributes = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: organizationalUnit",
+            "ou: Test",
+            "description: Old Value"
+            );
 
         DirContext ctx = ctxRoot.createSubcontext( dn, attributes );
         assertNotNull( ctx );
@@ -257,7 +261,7 @@
         assertEquals( "The entry returned should be the entry added earlier.", dn + "," + SUFFIX_DN, sr.getName() );
 
         attributes = sr.getAttributes();
-        attribute = attributes.get( "description" );
+        Attribute attribute = attributes.get( "description" );
 
         assertEquals( "The description attribute should contain the new value.", description, attribute.get() );
         assertFalse( "Search should return no more entries.", ne.hasMore() );
@@ -271,12 +275,11 @@
 
         String dn = "ou=Test";
 
-        Attributes attributes = new BasicAttributes( true );
-        Attribute attribute = new BasicAttribute( "objectClass" );
-        attribute.add( "top" );
-        attribute.add( "organizationalUnit" );
-        attributes.put( attribute );
-        attributes.put( "ou", "Test" );
+        Attributes attributes = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: organizationalUnit",
+            "ou: Test"
+            );
 
         DirContext ctx = ctxRoot.createSubcontext( dn, attributes );
         assertNotNull( ctx );

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesITest.java?rev=831373&r1=831372&r2=831373&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesITest.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchWithIndicesITest.java Fri Oct 30 16:20:42 2009
@@ -60,9 +60,10 @@
 import org.apache.directory.server.core.schema.SchemaPartition;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
+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.registries.Registries;
 import org.apache.directory.shared.ldap.util.ExceptionUtils;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
 import org.apache.directory.shared.schema.loader.ldif.JarLdifSchemaLoader;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -146,7 +147,6 @@
             DirectoryService service = new DefaultDirectoryService();
             service.setWorkingDirectory( new File( workingDirectory ) );
             SchemaPartition schemaPartition = service.getSchemaService().getSchemaPartition();
-            Registries registries = service.getRegistries();
             
             // Init the LdifPartition
             LdifPartition ldifPartition = new LdifPartition();
@@ -158,17 +158,21 @@
             SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
             
             schemaPartition.setWrappedPartition( ldifPartition );
-            schemaPartition.setRegistries( registries );
             
             JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
 
-            List<Throwable> errors = loader.loadAllEnabled( registries, true );
+            SchemaManager sm = new DefaultSchemaManager( loader );
+            
+            sm.loadAllEnabled();
+            List<Throwable> errors = sm.getErrors();
             
             if ( errors.size() != 0 )
             {
                 fail( "Schema load failed : " + ExceptionUtils.printErrors( errors ) );
             }
 
+            schemaPartition.setRegistries( sm.getRegistries() );
+            
             extractor.extractOrCopy();
 
             service.getChangeLog().setEnabled( true );
@@ -182,7 +186,7 @@
             systemPartition.setId( "system" );
             ((JdbmPartition)systemPartition).setCacheSize( 500 );
             systemPartition.setSuffix( ServerDNConstants.SYSTEM_DN );
-            systemPartition.setRegistries( registries );
+            systemPartition.setRegistries( sm.getRegistries() );
             ((JdbmPartition)systemPartition).setPartitionDir( new File( workingDirectory, "system" ) );
     
             // Add objectClass attribute for the system partition



Mime
View raw message