directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r881788 - 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/core/...
Date Wed, 18 Nov 2009 14:30:23 GMT
Author: elecharny
Date: Wed Nov 18 14:30:23 2009
New Revision: 881788

URL: http://svn.apache.org/viewvc?rev=881788&view=rev
Log:
Fixed the Add and Del operations for the MatchingRule schemaObject

Modified:
    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/MatchingRuleSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.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/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=881788&r1=881787&r2=881788&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
Wed Nov 18 14:30:23 2009
@@ -96,7 +96,7 @@
             // Relax the cloned registries
             clonedRegistries.setRelaxed();
             
-            // Associates this AttributeType with the schema
+            // Register the AttributeType in the cloned registries
             clonedRegistries.register( attributeType );
             
             // Associate the AT with its schema

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=881788&r1=881787&r2=881788&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
Wed Nov 18 14:30:23 2009
@@ -29,6 +29,7 @@
 import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 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;
@@ -36,6 +37,7 @@
 import org.apache.directory.shared.ldap.schema.SchemaManager;
 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.StringTools;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -110,63 +112,65 @@
         // Build the new MatchingRule from the given entry
         String schemaName = getSchemaName( dn );
         
-        // At this point, as we may break the registries, work on a cloned registries
-        Registries clonedRegistries = schemaManager.getRegistries().clone();
-        
-        // Relax the cloned registries
-        clonedRegistries.setRelaxed();
-        
         MatchingRule matchingRule = factory.getMatchingRule( schemaManager, entry, schemaManager.getRegistries(),
schemaName );
-        
-        List<Throwable> errors = clonedRegistries.checkRefInteg();
-        
-        if ( errors.size() == 0 )
-        {
-            // Update the references
-            clonedRegistries.buildReferences();
-            
-            clonedRegistries.setStrict();
-            schemaManager.swapRegistries( clonedRegistries  );
-        }
-        else
-        {
-            // We have some error : reject the addition and get out
-            return;
-        }
-        
+
         // At this point, the constructed MatchingRule has not been checked against the 
-        // existing Registries. It may be broken (missing SYNTAX), it will be checked
+        // existing Registries. It may be broken (missing SUP, or such), it will be checked
         // there, if the schema and the MatchingRule are both enabled.
         Schema schema = schemaManager.getLoadedSchema( schemaName );
-
+        
         if ( schema.isEnabled() && matchingRule.isEnabled() )
         {
-            matchingRule.applyRegistries( schemaManager.getRegistries() );
-        }
+            // As we may break the registries, work on a cloned registries
+            Registries clonedRegistries = schemaManager.getRegistries().clone();
+            
+            // Relax the cloned registries
+            clonedRegistries.setRelaxed();
+            
+            // Register the MatchingRule in the cloned registries
+            clonedRegistries.register( matchingRule );
         
-        // Associates this MatchingRule with the schema
-        addToSchema( matchingRule, schemaName );
+            // Associate the MatchingRule with its schema
+            clonedRegistries.associateWithSchema( matchingRule );
 
-        // Don't inject the modified element if the schema is disabled
-        if ( isSchemaEnabled( schemaName ) )
-        {
-            // Update the referenced and referencing objects
-            // The Syntax
-            schemaManager.getRegistries().addReference( matchingRule, matchingRule.getSyntax()
);
+            // Apply the registries to the newly created MatchingRule
+            matchingRule.applyRegistries( clonedRegistries );
             
-            // The Normalizer
-            schemaManager.getRegistries().addReference( matchingRule, matchingRule.getNormalizer()
);
+            // Update the cross references for MatchingRule
+            clonedRegistries.addCrossReferences( matchingRule );
             
-            // The Comparator
-            schemaManager.getRegistries().addReference( matchingRule, matchingRule.getLdapComparator()
);
+            // Check the registries now
+            List<Throwable> errors = clonedRegistries.checkRefInteg();
             
-            schemaManager.register( matchingRule );
-            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName
);
+            // If we didn't get any error, swap the registries
+            if ( errors.size() == 0 )
+            {
+                clonedRegistries.setStrict();
+                schemaManager.swapRegistries( clonedRegistries  );
+            }
+            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 MatchingRule " + entry.getDn().getUpName() +
" into the registries, "+
+                    "the resulting registries would be inconsistent :" + StringTools.listToString(
errors );
+                LOG.info( msg );
+                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
+            }
         }
         else
         {
+            // At least, we register the OID in the globalOidRegistry, and associates it
with the
+            // schema
+
+            // Associate the MatchingRule with its schema
+            schemaManager.getRegistries().associateWithSchema( matchingRule );
+
+            // And register the macthingRule in the globalOidregistry
             registerOids( matchingRule );
-            LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName
);
         }
     }
 
@@ -183,41 +187,61 @@
         // The parent DN must be ou=matchingrules,cn=<schemaName>,ou=schema
         checkParent( parentDn, schemaManager, SchemaConstants.MATCHING_RULE );
 
-        // Get the MatchingRule from the given entry ( it has been grabbed from the server
earlier)
+        // Test that the Oid exists
+        MatchingRule matchingRule = (MatchingRule)checkOidExists( entry );
+        
+        // Get the SchemaName
         String schemaName = getSchemaName( entry.getDn() );
-        MatchingRule matchingRule = factory.getMatchingRule( schemaManager, entry, schemaManager.getRegistries(),
schemaName );
-        String oid = matchingRule.getOid();
         
-        // Applies the Registries to this MatchingRule 
+        // Get the schema 
         Schema schema = schemaManager.getLoadedSchema( schemaName );
-
-        if ( schema.isEnabled() && matchingRule.isEnabled() )
-        {
-            matchingRule.applyRegistries( schemaManager.getRegistries() );
-        }
         
-        deleteFromSchema( matchingRule, schemaName );
-        
-        if ( schemaManager.getMatchingRuleRegistry().contains( oid ) )
+        if ( schema.isEnabled() && matchingRule.isEnabled() )
         {
-            // Update the referenced and referencing objects
-            // The Syntax
-            schemaManager.getRegistries().delReference( matchingRule, matchingRule.getSyntax()
);
+            // As we may break the registries, work on a cloned registries
+            Registries clonedRegistries = schemaManager.getRegistries().clone();
             
-            // The Normalizer
-            schemaManager.getRegistries().delReference( matchingRule, matchingRule.getNormalizer()
);
+            // Relax the cloned registries
+            clonedRegistries.setRelaxed();
             
-            // The Comparator
-            schemaManager.getRegistries().delReference( matchingRule, matchingRule.getLdapComparator()
);
+            // Remove this MatchingRule from the Registries
+            clonedRegistries.unregister( matchingRule );
+            
+            // Remove the MatchingRule from the schema/SchemaObject Map
+            clonedRegistries.dissociateFromSchema( matchingRule );
 
-            // Update the registry
-            schemaManager.unregisterMatchingRule( matchingRule.getOid() );
+            // Update the cross references for MatchingRule
+            clonedRegistries.delCrossReferences( matchingRule );
+            
+            // Check the registries now
+            List<Throwable> errors = clonedRegistries.checkRefInteg();
             
-            LOG.debug( "Removed {} from the enabled schema {}", matchingRule, schemaName
);
+            // If we didn't get any error, swap the registries
+            if ( errors.size() == 0 )
+            {
+                clonedRegistries.setStrict();
+                schemaManager.swapRegistries( clonedRegistries  );
+            }
+            else
+            {
+                // We have some error : reject the deletion and get out
+                // Destroy the cloned registries
+                schemaManager.destroy( clonedRegistries );
+                
+                // The schema is disabled. We still have to update the backend
+                String msg = "Cannot delete the MatchingRule " + entry.getDn().getUpName()
+ " into the registries, "+
+                    "the resulting registries would be inconsistent :" + StringTools.listToString(
errors );
+                LOG.info( msg );
+                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
+            }
         }
         else
         {
             unregisterOids( matchingRule );
+            
+            // Remove the MatchingRule from the schema/SchemaObject Map
+            schemaManager.getRegistries().dissociateFromSchema( matchingRule );
+            
             LOG.debug( "Removed {} from the disabled schema {}", matchingRule, schemaName
);
         }
     }

Modified: directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java?rev=881788&r1=881787&r2=881788&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-integ/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerIT.java
Wed Nov 18 14:30:23 2009
@@ -45,6 +45,7 @@
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.comparators.StringComparator;
 import org.apache.directory.shared.ldap.util.AttributeUtils;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -93,15 +94,40 @@
         return new LdapDN( "ou=matchingRules,cn=" + schemaName );
     }
     
+    private LdapDN getComparatorContainer( String schemaName ) throws Exception
+    {
+        return new LdapDN( "ou=comparators,cn=" + schemaName );
+    }
+    
+    
+    private void createComparator() throws Exception
+    {
+        Attributes attrs = AttributeUtils.createAttributes( 
+            "objectClass: top",
+            "objectClass: metaTop",
+            "objectClass: metaComparator",
+            "m-fqcn: " + StringComparator.class.getName(),
+            "m-oid: " + OID,
+            "m-description: A test comparator" );
+        
+        LdapDN dn = getComparatorContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+        
+        // Addition
+        getSchemaContext( service ).createSubcontext( dn, attrs );
+    }
+    
     
     // ----------------------------------------------------------------------
     // Test all core methods with normal operational pathways
     // ----------------------------------------------------------------------
-
-
+    // Test Add operation
+    // ----------------------------------------------------------------------
     @Test
     public void testAddMatchingRuleToEnabledSchema() throws Exception
     {
+        createComparator();
+        
         Attributes attrs = AttributeUtils.createAttributes( 
             "objectClass: top",
             "objectClass: metaTop",
@@ -112,10 +138,17 @@
 
         LdapDN dn = getMatchingRuleContainer( "apachemeta" );
         dn.add( "m-oid" + "=" + OID );
+        
+        // Pre-checks
+        assertFalse( isOnDisk( dn ) );
+        assertFalse( service.getSchemaManager().getAttributeTypeRegistry().contains( OID
) );
+
+        // Addition
         getSchemaContext( service ).createSubcontext( dn, attrs );
         
-        assertTrue( schemaManager.getMatchingRuleRegistry().contains( OID ) );
-        assertEquals( schemaManager.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta"
);
+        // Post-checks
+        assertTrue( service.getSchemaManager().getMatchingRuleRegistry().contains( OID )
);
+        assertEquals( service.getSchemaManager().getMatchingRuleRegistry().getSchemaName(
OID ), "apachemeta" );
         assertTrue( isOnDisk( dn ) );
     }
     
@@ -123,6 +156,8 @@
     @Test
     public void testAddMatchingRuleToDisabledSchema() throws Exception
     {
+        createComparator();
+        
         Attributes attrs = AttributeUtils.createAttributes( 
             "objectClass: top",
             "objectClass: metaTop",
@@ -144,6 +179,8 @@
     @Test
     public void testAddMatchingRuleToUnloadedSchema() throws Exception
     {
+        createComparator();
+        
         Attributes attrs = AttributeUtils.createAttributes( 
             "objectClass: top",
             "objectClass: metaTop",
@@ -162,7 +199,7 @@
         }
         catch( NameNotFoundException nnfe )
         {
-            // Excpected result
+            // Expected result
         }
         
         assertFalse( "adding new matchingRule to disabled schema should not register it into
the registries", 
@@ -170,7 +207,10 @@
         assertFalse( isOnDisk( dn ) );
     }
     
-
+    
+    // ----------------------------------------------------------------------
+    // Test Delete operation
+    // ----------------------------------------------------------------------
     @Test
     public void testDeleteMatchingRuleFromEnabledSchema() throws Exception
     {
@@ -219,6 +259,72 @@
     }
 
 
+    // ----------------------------------------------------------------------
+    // Test Modify operation
+    // ----------------------------------------------------------------------
+    @Test
+    public void testModifyMatchingRuleWithModificationItems() throws Exception
+    {
+        testAddMatchingRuleToEnabledSchema();
+        
+        MatchingRule mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
+        assertEquals( mr.getDescription(), DESCRIPTION0 );
+        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
+
+        LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+        
+        ModificationItem[] mods = new ModificationItem[2];
+        Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
+        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
+        attr = new BasicAttribute( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
+        mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
+        getSchemaContext( service ).modifyAttributes( dn, mods );
+
+        assertTrue( "matchingRule OID should still be present", 
+            schemaManager.getMatchingRuleRegistry().contains( OID ) );
+        
+        assertEquals( "matchingRule schema should be set to apachemeta", 
+            schemaManager.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
+        
+        mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
+        assertEquals( mr.getDescription(), DESCRIPTION1 );
+        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
+    }
+
+    
+    @Test
+    public void testModifyMatchingRuleWithAttributes() throws Exception
+    {
+        testAddMatchingRuleToEnabledSchema();
+        
+        MatchingRule mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
+        assertEquals( mr.getDescription(), DESCRIPTION0 );
+        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
+
+        LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+        dn.add( "m-oid" + "=" + OID );
+        
+        Attributes mods = new BasicAttributes( true );
+        mods.put( "m-description", DESCRIPTION1 );
+        mods.put( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
+        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods
);
+
+        assertTrue( "matchingRule OID should still be present", 
+            schemaManager.getMatchingRuleRegistry().contains( OID ) );
+        
+        assertEquals( "matchingRule schema should be set to apachemeta", 
+            schemaManager.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
+
+        mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
+        assertEquals( mr.getDescription(), DESCRIPTION1 );
+        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Test Rename operation
+    // ----------------------------------------------------------------------
     @Test
     public void testRenameMatchingRule() throws Exception
     {
@@ -245,7 +351,10 @@
         assertTrue( schemaManager.getMatchingRuleRegistry().contains( NEW_OID ) );
     }
 
-
+    
+    // ----------------------------------------------------------------------
+    // Test Move operation
+    // ----------------------------------------------------------------------
     @Test
     @Ignore
     public void testMoveMatchingRule() throws Exception
@@ -293,66 +402,6 @@
     }
 
 
-    @Test
-    public void testModifyMatchingRuleWithModificationItems() throws Exception
-    {
-        testAddMatchingRuleToEnabledSchema();
-        
-        MatchingRule mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
-        assertEquals( mr.getDescription(), DESCRIPTION0 );
-        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
-
-        LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( "m-oid" + "=" + OID );
-        
-        ModificationItem[] mods = new ModificationItem[2];
-        Attribute attr = new BasicAttribute( "m-description", DESCRIPTION1 );
-        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        attr = new BasicAttribute( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
-        mods[1] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
-        getSchemaContext( service ).modifyAttributes( dn, mods );
-
-        assertTrue( "matchingRule OID should still be present", 
-            schemaManager.getMatchingRuleRegistry().contains( OID ) );
-        
-        assertEquals( "matchingRule schema should be set to apachemeta", 
-            schemaManager.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
-        
-        mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
-        assertEquals( mr.getDescription(), DESCRIPTION1 );
-        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
-    }
-
-    
-    @Test
-    public void testModifyMatchingRuleWithAttributes() throws Exception
-    {
-        testAddMatchingRuleToEnabledSchema();
-        
-        MatchingRule mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
-        assertEquals( mr.getDescription(), DESCRIPTION0 );
-        assertEquals( mr.getSyntax().getOid(), SchemaConstants.INTEGER_SYNTAX );
-
-        LdapDN dn = getMatchingRuleContainer( "apachemeta" );
-        dn.add( "m-oid" + "=" + OID );
-        
-        Attributes mods = new BasicAttributes( true );
-        mods.put( "m-description", DESCRIPTION1 );
-        mods.put( "m-syntax", SchemaConstants.DIRECTORY_STRING_SYNTAX );
-        getSchemaContext( service ).modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods
);
-
-        assertTrue( "matchingRule OID should still be present", 
-            schemaManager.getMatchingRuleRegistry().contains( OID ) );
-        
-        assertEquals( "matchingRule schema should be set to apachemeta", 
-            schemaManager.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
-
-        mr = schemaManager.getMatchingRuleRegistry().lookup( OID );
-        assertEquals( mr.getDescription(), DESCRIPTION1 );
-        assertEquals( mr.getSyntax().getOid(), SchemaConstants.DIRECTORY_STRING_SYNTAX );
-    }
-    
-
     // ----------------------------------------------------------------------
     // Test move, rename, and delete when a MR exists and uses the Normalizer
     // ----------------------------------------------------------------------

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java?rev=881788&r1=881787&r2=881788&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
Wed Nov 18 14:30:23 2009
@@ -826,6 +826,33 @@
         }
     }
     
+    
+    
+    /**
+     * Delete the MR references (using and usedBy) : 
+     * MR -> C
+     * MR -> N
+     * MR -> S
+     */
+    public void delCrossReferences( MatchingRule matchingRule )
+    {
+        if ( matchingRule.getLdapComparator() != null )
+        {
+            delReference( matchingRule, matchingRule.getLdapComparator() );
+        }
+        
+        if ( matchingRule.getNormalizer() != null )
+        {
+            delReference( matchingRule, matchingRule.getNormalizer() );
+        }
+        
+        if ( matchingRule.getSyntax() != null )
+        {
+            delReference( matchingRule, matchingRule.getSyntax() );
+        }
+    }
+
+    
     /**
      * Build the MatchingRule references
      */
@@ -1383,18 +1410,35 @@
 
     /**
      * Check if the Comparator, Normalizer and the syntax are 
-     * existing for a matchingRule
+     * existing for a matchingRule. The Comparator and Normalizer aren't checked,
+     * as they have been defaulted to NoOp comparator and Normalizer if they
+     * were missing when the Matchingrule has been created.
      */
     private void resolve( MatchingRule matchingRule, List<Throwable> errors )
     {
-        // A Matching rule must point to a valid Syntax
-        try
+        // Process the Syntax. It can't be null
+        String syntaxOid = matchingRule.getSyntaxOid();
+        
+        if ( syntaxOid != null )
         {
-            matchingRule.applyRegistries( this );
+            // Check if the Syntax is present in the registries
+            try
+            {
+                ldapSyntaxRegistry.lookup( syntaxOid );
+            }
+            catch ( NamingException ne )
+            {
+                // This MR's syntax has not been loaded into the Registries.
+                errors.add( ne );
+            }
         }
-        catch ( NamingException e )
+        else
         {
-            errors.add( e );
+            // This is an error. 
+            Throwable error = new LdapSchemaViolationException( 
+                "The MatchingRule " + matchingRule.getOid() + " does not have a syntax."
+
+                " This is invalid", ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+            errors.add( error );
         }
     }
 



Mime
View raw message