directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r885381 [1/2] - in /directory: apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server...
Date Mon, 30 Nov 2009 11:41:08 GMT
Author: elecharny
Date: Mon Nov 30 11:41:06 2009
New Revision: 885381

URL: http://svn.apache.org/viewvc?rev=885381&view=rev
Log:
Applied the change done last thursday, and reveoverd from my defunct laptop. WARNING : it does not compile !

Modified:
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.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/ComparatorSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
    directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
    directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/ObjectClass.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimNormalizer.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDeepTrimToLowerNormalizer.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingDnNormalizer.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/normalizers/CachingNormalizer.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.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/AbstractRegistrySynchronizer.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java Mon Nov 30 11:41:06 2009
@@ -22,6 +22,7 @@
 
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -43,6 +44,7 @@
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.SchemaObjectWrapper;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
 import org.slf4j.Logger;
@@ -98,6 +100,30 @@
     
     
     /**
+     * Applies the added SchemaObject to the given register
+     */
+    protected List<Throwable> applyAdd( List<Throwable> errors, Registries registries, SchemaObject schemaObject ) throws NamingException
+    {
+        // Relax the registries
+        registries.setRelaxed();
+        
+        // Register the SchemaObject in the registries
+        registries.add( schemaObject );
+
+        // Build the SchemaObject references
+        registries.buildReference( errors, schemaObject );
+        
+        // Check the registries now
+        List<Throwable> checkErrors = registries.checkRefInteg();
+        
+        errors.addAll( checkErrors );
+        
+        // return the errors
+        return errors;
+    }
+    
+    
+    /**
      * Tells if the schema the DN references is loaded or not
      *
      * @param dn The SchemaObject's DN 

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=885381&r1=885380&r2=885381&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 Mon Nov 30 11:41:06 2009
@@ -20,6 +20,7 @@
 package org.apache.directory.server.core.schema.registries.synchronizers;
 
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -61,7 +62,7 @@
     {
         super( schemaManager );
     }
-
+    
     
     /**
      * {@inheritDoc}
@@ -87,43 +88,27 @@
         // existing Registries. It may be broken (missing SUP, or such), it will be checked
         // there, if the schema and the AttributeType are both enabled.
         Schema schema = schemaManager.getLoadedSchema( schemaName );
+        List<Throwable> errors = new ArrayList<Throwable>();
         
         if ( schema.isEnabled() && attributeType.isEnabled() )
         {
             // As we may break the registries, work on a cloned registries
             Registries clonedRegistries = schemaManager.getRegistries().clone();
             
-            // Relax the cloned registries
-            clonedRegistries.setRelaxed();
-            
-            // Register the AttributeType in the cloned registries
-            clonedRegistries.register( attributeType );
+            applyAdd( errors, clonedRegistries, attributeType );
             
-            // Associate the AT with its schema
-            clonedRegistries.associateWithSchema( attributeType );
-
-            // Apply the registries to the newly created AT
-            attributeType.applyRegistries( clonedRegistries );
+            // Remove the cloned registries
+            clonedRegistries.clear();
             
-            // Update the cross references for AT
-            clonedRegistries.addCrossReferences( attributeType );
-            
-            // Check the registries now
-            List<Throwable> errors = clonedRegistries.checkRefInteg();
-            
-            // If we didn't get any error, swap the registries
-            if ( errors.size() == 0 )
+            // If we didn't get any error, apply the addition to the real retistries
+            if ( errors.isEmpty() )
             {
-                clonedRegistries.setStrict();
-                schemaManager.swapRegistries( clonedRegistries  );
+                // Apply the addition to the real registries
+                applyAdd( errors, schemaManager.getRegistries(), attributeType );
             }
             else
             {
                 // We have some error : reject the addition and get out
-                // Destroy the cloned registries
-                schemaManager.destroy( clonedRegistries );
-                
-                // The schema is disabled. We still have to update the backend
                 String msg = "Cannot add the AttributeType " + entry.getDn().getUpName() + " into the registries, "+
                     "the resulting registries would be inconsistent :" + StringTools.listToString( errors );
                 LOG.info( msg );
@@ -225,7 +210,7 @@
             {
                 // We have some error : reject the deletion and get out
                 // Destroy the cloned registries
-                schemaManager.destroy( clonedRegistries );
+                clonedRegistries.clear();
                 
                 // The schema is disabled. We still have to update the backend
                 String msg = "Cannot delete the AttributeType " + entry.getDn().getUpName() + " into the registries, "+

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.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/ComparatorSynchronizer.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java Mon Nov 30 11:41:06 2009
@@ -118,38 +118,29 @@
         // existing Registries. It will be checked there, if the schema and the 
         // LdapComparator are both enabled.
         Schema schema = schemaManager.getLoadedSchema( schemaName );
-        
+        List<Throwable> errors = null;
+
         if ( schema.isEnabled() && comparator.isEnabled() )
         {
-            // At this point, as we may break the registries, work on a cloned registries
+            // As we may break the registries, work on a cloned registries
             Registries clonedRegistries = schemaManager.getRegistries().clone();
             
-            // Relax the cloned registries
-            clonedRegistries.setRelaxed();
-            
-            // Associates this Comparator with the schema
-            clonedRegistries.register( comparator );
+            errors = applyAdd( clonedRegistries, comparator );
             
-            // Associate the Comparator with its schema
-            clonedRegistries.associateWithSchema( comparator );
-
-            // Apply the registries to the newly created Comparator
-            comparator.applyRegistries( clonedRegistries );
-            
-            // Check the registries now
-            List<Throwable> errors = clonedRegistries.checkRefInteg();
+            // Remove the cloned registries
+            clonedRegistries.clear();
             
             // If we didn't get any error, swap the registries
-            if ( errors.size() == 0 )
+            if ( errors.isEmpty() )
             {
-                clonedRegistries.setStrict();
-                schemaManager.swapRegistries( clonedRegistries  );
+                // Apply the addition to the real registries
+                schemaManager.getRegistries().applyAdd( comparator );
             }
             else
             {
                 // We have some error : reject the addition and get out
                 // Destroy the cloned registries
-                schemaManager.destroy( clonedRegistries );
+                clonedRegistries.clear();
                 
                 // The schema is disabled. We still have to update the backend
                 String msg = "Cannot add the Comparator " + entry.getDn().getUpName() + " into the registries, "+
@@ -233,7 +224,7 @@
             {
                 // We have some error : reject the deletion and get out
                 // Destroy the cloned registries
-                schemaManager.destroy( clonedRegistries );
+                clonedRegistries.clear();
 
                 String msg = "There is at least one MatchingRule using the Comparator with OID " + comparator.getOid();
                 LOG.debug( msg );
@@ -260,7 +251,7 @@
             {
                 // We have some error : reject the deletion and get out
                 // Destroy the cloned registries
-                schemaManager.destroy( clonedRegistries );
+                clonedRegistries.clear();
                 
                 // The schema is disabled. We still have to update the backend
                 String msg = "Cannot delete the Comparator " + entry.getDn().getUpName() + " into the registries, "+

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.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/MatchingRuleSynchronizer.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java Mon Nov 30 11:41:06 2009
@@ -152,7 +152,7 @@
             {
                 // We have some error : reject the addition and get out
                 // Destroy the cloned registries
-                schemaManager.destroy( clonedRegistries );
+                clonedRegistries.clear();
                 
                 // The schema is disabled. We still have to update the backend
                 String msg = "Cannot add the MatchingRule " + entry.getDn().getUpName() + " into the registries, "+
@@ -226,7 +226,7 @@
             {
                 // We have some error : reject the deletion and get out
                 // Destroy the cloned registries
-                schemaManager.destroy( clonedRegistries );
+                clonedRegistries.clear();
                 
                 // The schema is disabled. We still have to update the backend
                 String msg = "Cannot delete the MatchingRule " + entry.getDn().getUpName() + " into the registries, "+

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/operations/search/SearchIT.java Mon Nov 30 11:41:06 2009
@@ -54,6 +54,7 @@
 import org.apache.directory.shared.ldap.message.AliasDerefMode;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -153,6 +154,11 @@
     public static DirectoryService service;
     public static LdapContext sysRoot;
 
+    @BeforeClass
+    public static void setup() throws Exception
+    {
+    }
+    
     
     /**
      * @param sysRoot the system root to add entries to
@@ -161,6 +167,8 @@
     @Before
     public void createData() throws Exception
     {
+        service.getSchemaManager().enable( "nis" );
+
         sysRoot = getSystemContext( service ); 
             
         /*

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/main/java/org/apache/directory/shared/schema/DefaultSchemaManager.java Mon Nov 30 11:41:06 2009
@@ -198,22 +198,6 @@
     //-----------------------------------------------------------------------
     // API methods
     //-----------------------------------------------------------------------
-    /**
-     * {@inheritDoc}
-     */
-    public void destroy( Registries registries ) throws NamingException
-    {
-        if ( registries == null )
-        {
-            return;
-        }
-        else
-        {
-            registries.clear();
-        }
-    }
-
-    
     /***
      * {@inheritDoc}
      */
@@ -235,7 +219,7 @@
             registries = targetRegistries;
             
             // Delete the old registries to avoid memory leaks
-            destroy( oldRegistries );
+            oldRegistries.clear();
             
             return true;
         }
@@ -301,8 +285,27 @@
             load( clonedRegistries, schema  );
         }
         
+        List<Throwable> errors = clonedRegistries.checkRefInteg();
+        
+        // Destroy the clonedRegistry
+        clonedRegistries.clear();
+        
+        if ( errors.isEmpty() )
+        {
+            // No error, inject the schema in the current registries 
+            for ( Schema schema:schemas )
+            {
+                schema.enable();
+                load( registries, schema  );
+            }
+            
+            errors = registries.checkRefInteg();
+        }
+        
+        return errors.isEmpty();
+        
         // Swap the registries if it is consistent
-        return swapRegistries( clonedRegistries );
+        //return swapRegistries( clonedRegistries );
     }
 
 
@@ -607,10 +610,8 @@
         {
             if ( registries.isDisabledAccepted() || ( schema.isEnabled() && schemaObject.isEnabled() ) )
             {
-                registries.register( schemaObject );
+                registries.add( schemaObject );
 
-                // Associate the SchemaObject with its schema
-                registries.associateWithSchema( schemaObject );
             }
             else
             {
@@ -621,10 +622,7 @@
         {
             if ( schema.isEnabled() && schemaObject.isEnabled() )
             {
-                registries.register( schemaObject );
-
-                // Associate the SchemaObject with its schema
-                registries.associateWithSchema( schemaObject );
+                registries.add( schemaObject );
             }
             else
             {
@@ -719,7 +717,7 @@
         Registries clonedRegistries = cloneRegistries();
         clonedRegistries.setRelaxed();
 
-        //Load the schemas
+        // Load the schemas
         for ( Schema schema : schemas )
         {
             loadDepsFirst( schema, clonedRegistries );
@@ -872,7 +870,7 @@
                 if ( !loaded )
                 {
                     // We got an error : exit
-                    destroy( clonedRegistries );
+                    clonedRegistries.clear();
                     return false;
                 }
                 
@@ -882,20 +880,20 @@
                 if ( errors.size() != 0 )
                 {
                     // We got an error : exit
-                    destroy( clonedRegistries );
+                    clonedRegistries.clear();
                     return false;
                 }
             }
             catch ( Exception e )
             {
                 // We got an error : exit
-                destroy( clonedRegistries );
+                clonedRegistries.clear();
                 return false;
             }
         }
         
         // We can now delete the cloned registries before exiting
-        destroy( clonedRegistries );
+        clonedRegistries.clear();
         
         return true;
     }

Modified: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java (original)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerTest.java Mon Nov 30 11:41:06 2009
@@ -23,11 +23,13 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.directory.server.schema.loader.ldif.LdifSchemaLoaderTest;
 import org.apache.directory.shared.ldap.entry.Entry;
+import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
@@ -146,12 +148,14 @@
     
     private void checkSyntaxes( List<Entry> syntaxes, SchemaManager schemaManager, Registries expectedRegistries ) throws Exception
     {
+        List<Throwable> errors = new ArrayList<Throwable>();
+        
         for ( Entry entry : syntaxes )
         {
             LdapSyntax expectedLdapSyntax = factory.getSyntax( schemaManager, entry, schemaManager.getRegistries(), "system" );
             LdapSyntax syntax = schemaManager.getLdapSyntaxRegistry().lookup( expectedLdapSyntax.getOid() );
             
-            expectedLdapSyntax.applyRegistries( expectedRegistries );
+            expectedLdapSyntax.applyRegistries( errors, expectedRegistries );
             
             if ( !expectedLdapSyntax.equals( syntax ) )
             {
@@ -165,12 +169,14 @@
     
     private void checkMatchingRules( List<Entry> matchingRules, SchemaManager schemaManager, Registries expectedRegistries ) throws Exception
     {
+        List<Throwable> errors = new ArrayList<Throwable>();
+        
         for ( Entry entry : matchingRules )
         {
             MatchingRule expectedMatchingRule = factory.getMatchingRule( schemaManager, entry, schemaManager.getRegistries(), "system" );
             MatchingRule matchingRule = schemaManager.getMatchingRuleRegistry().lookup( expectedMatchingRule.getOid() );
             
-            expectedMatchingRule.applyRegistries( expectedRegistries );
+            expectedMatchingRule.applyRegistries( errors, expectedRegistries );
             
             if ( !expectedMatchingRule.equals( matchingRule ) )
             {
@@ -182,6 +188,19 @@
     }
     
     
+    private SchemaManager loadSystem() throws Exception
+    {
+        JarLdifSchemaLoader loader = new JarLdifSchemaLoader();
+        SchemaManager schemaManager = new DefaultSchemaManager( loader );
+
+        String schemaName = "system";
+        
+        schemaManager.loadWithDeps( schemaName );
+        
+        return schemaManager;
+    }
+    
+    
     /**
      * We will load the System schema, and test that the schemaManager is consistent
      */
@@ -214,4 +233,22 @@
         
         // Test ATs
     }
+    
+    
+    @Test
+    public void testAddAttributeType() throws Exception
+    {
+    	SchemaManager schemaManager = loadSystem();
+    	
+    	AttributeType attributeType = new AttributeType( "1.1.0" );
+    	attributeType.setEqualityOid( "2.5.13.1" );
+    	attributeType.setOrderingOid( null );
+    	attributeType.setSubstringOid( null );
+    	attributeType.setSuperior( (String)null );
+    	
+    	schemaManager.register( attributeType );
+    	
+    	// Check that the AT has been correctly added
+    	
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java Mon Nov 30 11:41:06 2009
@@ -20,14 +20,18 @@
 package org.apache.directory.shared.ldap.schema;
 
 
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.schema.registries.LdapSyntaxRegistry;
-import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -138,6 +142,9 @@
  */
 public class AttributeType extends SchemaObject implements Cloneable
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( AttributeType.class );
+
     /** The serialVersionUID */
     public static final long serialVersionUID = 1L;
     
@@ -198,80 +205,488 @@
     
     
     /**
-     * Inject the registries into this Object, updating the references to
-     * other SchemaObject.
-     * 
-     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR, SYNTAX), 
-     * an exception is thrown.
-     *
-     * @param registries The Registries
-     * @exception If the AttributeType is not valid 
+     * Build the Superior AttributeType reference for an AttributeType
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    private void buildSuperior(List<Throwable> errors, Registries registries )
     {
-        if ( registries != null )
+        AttributeType superior = null;
+        AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
+        
+        if ( superiorOid != null )
         {
-            AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
+            // This AT has a superior
+            try
+            {
+                superior = attributeTypeRegistry.lookup( superiorOid );
+            }
+            catch ( Exception e )
+            {
+                // Not allowed.
+                String msg = "Cannot find the SUPERIOR object " + superiorOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                
+                // Get out now
+                return;
+            }
             
-            if ( superiorOid != null )
+            if ( superior != null )
             {
-                superior = atRegistry.lookup( superiorOid );
+                this.superior = superior;
+                
+                // Recursively update the superior if not already done. We don't recurse
+                // if the superior's superior is not null, as it means it has already been
+                // handled.
+                if ( //( ( registries.getUsing( superior ) == null ) || registries.getUsing( superior ).isEmpty() ) && 
+                     ( superior.getSuperior() == null ) )
+                {
+                    registries.buildReference( errors, superior );
+                }
+                
+                // Update the descendant MAP
+                try
+                {
+                    attributeTypeRegistry.registerDescendants( this, superior );
+                }
+                catch ( NamingException ne )
+                {
+                    errors.add( ne );
+                    LOG.info( ne.getMessage() );
+                }
+                
+                // Check for cycles now
+                Set<String> superiors = new HashSet<String>();
+                superiors.add( oid );
+                AttributeType tmp = superior;
+                
+                while ( tmp != null )
+                {
+                    if ( superiors.contains( tmp.getOid() ) )
+                    {
+                        // There is a cycle : bad bad bad !
+                        // Not allowed.
+                        String msg = "A cycle has been detected in the superior hierarchyOid" + 
+                            " while building cross-references for the " + getName() + 
+                            " AttributeType.";
+
+                        Throwable error = new LdapSchemaViolationException( 
+                            msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                        errors.add( error );
+                        LOG.info( msg );
+                        
+                        break;
+                    }
+                    else
+                    {
+                        superiors.add( tmp.getOid() );
+                        tmp = tmp.getSuperior();
+                    }
+                }
+                
+                superiors.clear();
+                
+                return;
             }
+            else
+            {
+                // Not allowed.
+                String msg = "Cannot find the SUPERIOR object " + superiorOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                
+                // Get out now
+                return;
+            }
+        }
+        else
+        {
+            // No superior, just return
+            return;
+        }
+    }
+
+    
+    /**
+     * Build the SYNTAX reference for an AttributeType
+     */
+    private void buildSyntax( List<Throwable> errors, Registries registries )
+    {
+        if ( syntaxOid != null )
+        {
+            LdapSyntax syntax = null;
             
-            MatchingRuleRegistry mrRegistry = registries.getMatchingRuleRegistry();
+            try
+            {
+                syntax = registries.getLdapSyntaxRegistry().lookup( syntaxOid );
+            }
+            catch ( NamingException ne )
+            {
+                // Not allowed.
+                String msg = "Cannot find a Syntax object " + syntaxOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                return;
+            }
             
-            if ( equalityOid != null )
+            if ( syntax != null )
             {
-                equality = mrRegistry.lookup( equalityOid );
+                // Update the Syntax reference
+                this.syntax = syntax;
             }
-            else if ( superior != null )
+            else
             {
-                // We may have a superior with an EQUALITY MR 
-                equality = superior.getEquality();
+                // Not allowed.
+                String msg = "Cannot find a Syntax object " + syntaxOid + 
+                " while building cross-references for the " + getName() + 
+                " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                return;
             }
+        }
+        else
+        {
+            // We inherit from the superior's syntax, if any
+            if ( superior != null )
+            {
+                this.syntax = superior.getSyntax();
+            }
+            else
+            {
+                // Not allowed.
+                String msg = "The AttributeType " + getName() + " must have " +
+                    "a syntax OID or a superior, it does not have any.";
+    
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                return;
+            }
+        }
+    }
+    
+    
+    /**
+     * Build the EQUALITY MR reference for an AttributeType
+     */
+    private void buildEquality( List<Throwable> errors, Registries registries )
+    {
+        // The equality MR. It can be null
+        if ( equalityOid != null )
+        {
+            MatchingRule equality = null;
             
-            if ( orderingOid != null )
+            try
             {
-                ordering = mrRegistry.lookup( orderingOid );
+                equality = registries.getMatchingRuleRegistry().lookup( equalityOid );
             }
-            else if ( superior != null )
+            catch ( NamingException ne )
             {
-                // We may have a superior with an ORDERING MR 
-                ordering = superior.getOrdering();
+                // Not allowed.
+                String msg = "Cannot find an Equality MatchingRule object for " + equalityOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                return;
             }
             
-            if ( substringOid != null )
+            if ( equality != null )
             {
-                substring = mrRegistry.lookup( substringOid );
+                this.equality = equality;
             }
-            else if ( superior != null )
+            else
+            {
+                // Not allowed.
+                String msg = "Cannot find an EQUALITY MatchingRule instance for " + equalityOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+            }
+        }
+        else
+        {
+            // If the AT has a superior, take its Equality MR if any
+            if ( ( superior != null ) && ( superior.getEquality() != null ) )
             {
-                // We may have a superior with an SUBSTR MR 
-                substring = superior.getSubstring();
+                this.equality = superior.getEquality();
             }
+        }
+    }
+    
+    
+    /**
+     * Build the ORDERING MR reference for an AttributeType
+     */
+    private void buildOrdering( List<Throwable> errors, Registries registries )
+    {
+        if ( orderingOid != null )
+        {
+            MatchingRule ordering = null;
             
-            LdapSyntaxRegistry lsRegistry = registries.getLdapSyntaxRegistry();
+            try
+            {
+                ordering = registries.getMatchingRuleRegistry().lookup( orderingOid );
+            }
+            catch ( NamingException ne )
+            {
+                // Not allowed.
+                String msg = "Cannot find a Ordering MatchingRule object for " + orderingOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                return;
+            }
+            
+            if ( ordering != null )
+            {
+                this.ordering = ordering;
+            }
+            else
+            {
+                // Not allowed.
+                String msg = "Cannot find an ORDERING MatchingRule instance for " + orderingOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+            }
+        }
+        else
+        {
+            // If the AT has a superior, take its Ordering MR if any
+            if ( ( superior != null ) && ( superior.getOrdering() != null ) )
+            {
+                this.ordering = superior.getOrdering();
+            }
+        }
+    }
+
+    
+    /**
+     * Build the SUBSTR MR reference for an AttributeType
+     */
+    private void buildSubstring( List<Throwable> errors, Registries registries )
+    {
+        // The Substring MR. It can be null
+        if ( substringOid != null )
+        {
+            MatchingRule substring = null;
             
-            if ( syntaxOid != null )
+            try
+            {
+                substring = registries.getMatchingRuleRegistry().lookup( substringOid );
+            }
+            catch ( NamingException ne )
             {
-                syntax = lsRegistry.lookup( syntaxOid );
+                // Not allowed.
+                String msg = "Cannot find a SUBSTR MatchingRule object for " + substringOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                return;
             }
-            else  if ( superior != null )
+            
+            if ( substring != null )
             {
-                syntax = superior.getSyntax();
+                this.substring = substring;
             }
             else
             {
-                // This is an error: an AttributeType must have at least a SYNTAX or a SUP
-                throw new LdapSchemaViolationException( "The created AttributeType must have a SUP or a SYNTAX element", 
-                    ResultCodeEnum.UNWILLING_TO_PERFORM );
+                // Not allowed.
+                String msg = "Cannot find a SUBSTR MatchingRule instance for " + substringOid + 
+                    " while building cross-references for the " + getName() + 
+                    " AttributeType.";
+
+                Throwable error = new LdapSchemaViolationException( 
+                    msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                errors.add( error );
+                LOG.info( msg );
+                return;
+            }
+        }
+        else
+        {
+            // If the AT has a superior, take its Substring MR if any
+            if ( ( superior != null ) && ( superior.getSubstring() != null ) )
+            {
+                this.substring = superior.getSubstring();
+            }
+        }
+    }
+
+    
+    /**
+     * Check the constraints for the Usage field.
+     */
+    private void checkUsage( List<Throwable> errors, Registries registries )
+    {
+        // Check that the AT usage is the same that its superior
+        if ( ( superior != null ) && ( usage != superior.getUsage() ) )
+        {
+            // This is an error
+            String msg = "The attributeType " + getName() + " must have the same USAGE than its superior"; 
+
+            Throwable error = new LdapSchemaViolationException( 
+                msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+            errors.add( error );
+            LOG.info( msg );
+            return;
+        }
+        
+        // Now, check that the AttributeType's USAGE does not conflict
+        if ( !isUserModifiable() && ( usage == UsageEnum.USER_APPLICATIONS ) )
+        {
+            // Cannot have a not user modifiable AT which is not an operational AT
+            String msg = "The attributeType " + getName() + " is a USER-APPLICATION attribute, " +
+                "it must be USER-MODIFIABLE"; 
+            
+            Throwable error = new LdapSchemaViolationException( 
+                msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+            errors.add( error );
+            LOG.info( msg );
+        }
+    }
+    
+    
+    /**
+     * Check the constraints for the Collective field.
+     */
+    private void checkCollective( List<Throwable> errors, Registries registries )
+    {
+        if ( superior != null )
+        {
+            if ( superior.isCollective() )
+            {
+                // An AttributeType will be collective if its superior is collective
+                this.isCollective = true;
             }
+        }
+
+        if ( isCollective() && ( usage != UsageEnum.USER_APPLICATIONS ) )
+        {
+            // An AttributeType which is collective must be a USER attributeType
+            String msg = "The attributeType " + getName() + " is a COLLECTIVE AttributeType, " +
+                ", it must be a USER-APPLICATION attributeType too.";
+            
+            Throwable error = new LdapSchemaViolationException( 
+                msg, ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+            errors.add( error );
+            LOG.info( msg );
+        }
+    }
+    
+    
+    /**
+     * Inject the registries into this Object, updating the references to
+     * other SchemaObject.
+     * 
+     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR, SYNTAX), 
+     * an exception is thrown.
+     *
+     * @param registries The Registries
+     * @exception If the AttributeType is not valid 
+     */
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
+    {
+        if ( registries != null )
+        {
+            AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
+            
+            // The superior
+            buildSuperior( errors, registries );
+            
+            // The Syntax
+            buildSyntax( errors, registries );
+            
+            // The EQUALITY matching rule
+            buildEquality( errors, registries );
+            
+            // The ORDERING matching rule
+            buildOrdering( errors, registries );
+            
+            // The SUBSTR matching rule
+            buildSubstring( errors, registries );
+            
+            // Check the USAGE
+            checkUsage( errors, registries );
+            
+            // Check the COLLECTIVE element
+            checkCollective( errors, registries );
             
             // Inject the attributeType into the oid/normalizer map
-            atRegistry.addMappingFor( this );
+            attributeTypeRegistry.addMappingFor( this );
     
             // Register this AttributeType into the Descendant map
-            atRegistry.registerDescendants( this, this.getSuperior() );
+            attributeTypeRegistry.registerDescendants( this, superior );
+
+            /**
+             * Add the AT references (using and usedBy) : 
+             * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
+             * AT -> S
+             * AT -> AT
+             */
+            if ( equality != null )
+            {
+               registries. addReference( this, equality );
+            }
+            
+            if ( ordering != null )
+            {
+                registries.addReference( this, ordering );
+            }
+            
+            if ( substring != null )
+            {
+                registries.addReference( this, substring );
+            }
+            
+            if ( syntax != null )
+            {
+                registries.addReference( this, syntax );
+            }
+            
+            if ( superior != null )
+            {
+                registries.addReference( this, superior );
+            }
         }
     }
     
@@ -502,6 +917,20 @@
             this.superiorOid = superior.getOid();
         }
     }
+    
+
+    /**
+     * Sets the superior oid for this AttributeType
+     *
+     * @param superior The superior oid for this AttributeType
+     */
+    public void setSuperior( String superiorOid )
+    {
+        if ( !isReadOnly )
+        {
+            this.superiorOid = superiorOid;
+        }
+    }
 
 
     /**

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=885381&r1=885380&r2=885381&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 Nov 30 11:41:06 2009
@@ -20,6 +20,8 @@
 package org.apache.directory.shared.ldap.schema;
 
 
+import java.util.List;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.registries.Registries;
@@ -193,7 +195,7 @@
      *
      * @param registries The Registries
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
@@ -207,6 +209,13 @@
                 // No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker
                 syntaxChecker = new OctetStringSyntaxChecker( oid );
             }
+
+            // Add the references for S :
+            // S -> SC
+            if ( syntaxChecker != null )
+            {
+                registries.addReference( this, syntaxChecker );
+            }
         }
     }
 

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java Mon Nov 30 11:41:06 2009
@@ -19,6 +19,10 @@
  */
 package org.apache.directory.shared.ldap.schema;
 
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
 /**
  * An abstract class used to manage the ADS specific SchemaObject, which can
  * contain some compiled Java class to implement the specific logic.
@@ -113,6 +117,18 @@
     }
     
     
+    /**
+     * {@inheritDoc}
+     */
+    public void registerOid( SchemaObject schemaObject, Registries registries ) throws NamingException
+    {
+        // Do nothing : the current SchemaObject ha sthe same OID than the one it is realted to
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
     public LoadableSchemaObject copy()
     {
         return null;

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=885381&r1=885380&r2=885381&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 Nov 30 11:41:06 2009
@@ -20,6 +20,8 @@
 package org.apache.directory.shared.ldap.schema;
 
 
+import java.util.List;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
@@ -115,7 +117,7 @@
      *
      * @param registries The Registries
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
@@ -152,6 +154,28 @@
                 throw new LdapSchemaViolationException( "The created MatchingRule must refers to an existing SYNTAX element", 
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
+            
+            /**
+             * Add the MR references (using and usedBy) : 
+             * MR -> C
+             * MR -> N
+             * MR -> S
+             */
+            if ( ldapComparator != null )
+            {
+                registries.addReference( this, ldapComparator );
+            }
+            
+            if ( normalizer != null )
+            {
+                registries.addReference( this, normalizer );
+            }
+            
+            if ( ldapSyntax != null )
+            {
+                registries.addReference( this, ldapSyntax );
+            }
+            
         }
     }
     

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/Normalizer.java Mon Nov 30 11:41:06 2009
@@ -23,7 +23,6 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.entry.Value;
-import org.apache.directory.shared.ldap.schema.registries.Registries;
 
 
 /**
@@ -79,17 +78,6 @@
     
     
     /**
-     * Associate the registries to the normalizer, if needed.
-     *
-     * @param registries The Registries
-     */
-    public void applyRegistries( Registries registries ) throws NamingException
-    {
-        // Do nothing. The extended class will store the Registries if needed
-    }
-
-    
-    /**
      * Store the SchemaManager in this instance. It may be necessary for some
      * normalizer which needs to have access to the oidNormalizer Map.
      *

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=885381&r1=885380&r2=885381&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 Nov 30 11:41:06 2009
@@ -127,7 +127,7 @@
      * @throws Exception on failure
      *
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
@@ -163,6 +163,26 @@
                     mustAttributeTypes.add( atRegistry.lookup( atRegistry.getOidByName( mustAttributeTypeName ) ) );
                 }
             }
+            
+            /**
+             * Add the OC references (using and usedBy) : 
+             * OC -> AT (MAY and MUST)
+             * OC -> OC (SUPERIORS)
+             */
+            for ( AttributeType mayAttributeType : mayAttributeTypes )
+            {
+                registries.addReference( this, mayAttributeType );
+            }
+
+            for ( AttributeType mustAttributeType : mustAttributeTypes )
+            {
+                registries.addReference( this, mustAttributeType );
+            }
+            
+            for ( ObjectClass superiorObjectClass : superiors )
+            {
+                registries.addReference( this, superiorObjectClass );
+            }
         }
     }
 

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaManager.java Mon Nov 30 11:41:06 2009
@@ -515,16 +515,6 @@
     
     
     /**
-     * Delete the given registries and all its content. This method is called
-     * to avoid memory leaks.
-     *
-     * @param registries The registries to be deleted
-     * @exception If something went wrong
-     */
-    public void destroy( Registries registries ) throws NamingException;
-    
-    
-    /**
      * @return The errors obtained when checking the registries
      */
     List<Throwable> getErrors();

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java?rev=885381&r1=885380&r2=885381&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/SchemaObject.java Mon Nov 30 11:41:06 2009
@@ -205,9 +205,10 @@
      * Inject the registries into this Object, updating the references to
      * other SchemaObject
      *
+     * @param errors The errors we got
      * @param registries The Registries
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
         // do nothing
     }
@@ -721,6 +722,20 @@
     
     
     /**
+     * Register the given SchemaObject into the given registries' globalOidRegistry
+     *
+     * @param schemaObject the SchemaObject we want to register
+     * @param registries The registries in which we want it to be stored
+     * @throws NamingException If the OID is invalid
+     */
+    public void registerOid( SchemaObject schemaObject, Registries registries ) throws NamingException
+    {
+        // Add the SchemaObject into the globalOidRegistry
+        registries.getGlobalOidRegistry().register( this );
+    }
+    
+    
+    /**
      * Copy the current SchemaObject on place
      *
      * @return The copied SchemaObject
@@ -744,6 +759,7 @@
         }
     }
 
+    
     /**
      * Copy a SchemaObject.
      * 

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=885381&r1=885380&r2=885381&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 Nov 30 11:41:06 2009
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.schema.normalizers;
 
+import java.util.List;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.registries.Registries;
@@ -48,8 +50,8 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
-        super.applyRegistries( registries );
+        super.applyRegistries( errors, 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=885381&r1=885380&r2=885381&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 Nov 30 11:41:06 2009
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.schema.normalizers;
 
+import java.util.List;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.registries.Registries;
@@ -48,8 +50,8 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
-        super.applyRegistries( registries );
+        super.applyRegistries( errors, 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=885381&r1=885380&r2=885381&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 Nov 30 11:41:06 2009
@@ -19,6 +19,8 @@
  */
 package org.apache.directory.shared.ldap.schema.normalizers;
 
+import java.util.List;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.SchemaManager;
@@ -49,9 +51,9 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
-        super.applyRegistries( registries );
+        super.applyRegistries( errors, 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=885381&r1=885380&r2=885381&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 Nov 30 11:41:06 2009
@@ -20,6 +20,8 @@
 package org.apache.directory.shared.ldap.schema.normalizers;
 
 
+import java.util.List;
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.entry.Value;
@@ -155,9 +157,9 @@
     /**
      * {@inheritDoc}
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
-        normalizer.applyRegistries( registries );
+        normalizer.applyRegistries( errors, registries );
     }
     
     



Mime
View raw message