directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r891463 - in /directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers: ComparatorSynchronizer.java NormalizerSynchronizer.java SyntaxCheckerSynchronizer.java
Date Wed, 16 Dec 2009 22:48:17 GMT
Author: elecharny
Date: Wed Dec 16 22:48:16 2009
New Revision: 891463

URL: http://svn.apache.org/viewvc?rev=891463&view=rev
Log:
Add some fix for C/N/SC addition in the server

Modified:
    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/NormalizerSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java

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=891463&r1=891462&r2=891463&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
Wed Dec 16 22:48:16 2009
@@ -38,7 +38,6 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.LdapComparator;
 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;
@@ -126,23 +125,9 @@
 
         if ( schema.isEnabled() && comparator.isEnabled() )
         {
-            // As we may break the registries, work on a cloned registries
-            Registries clonedRegistries = schemaManager.getRegistries().clone();
-
-            // Inject the newly created Comparator in the cloned registries
-            clonedRegistries.add( errors, comparator );
-
-            // Remove the cloned registries
-            clonedRegistries.clear();
-
-            // If we didn't get any error, add the Comparator into the real registries
-            if ( errors.isEmpty() )
+            if ( schemaManager.add( comparator ) )
             {
-                // Apply the addition to the real registries
-                schemaManager.getRegistries().add( errors, comparator );
-
                 LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName
);
-
             }
             else
             {
@@ -224,58 +209,34 @@
 
         if ( schema.isEnabled() && comparator.isEnabled() )
         {
-            // As we may break the registries, work on a cloned registries
-            Registries clonedRegistries = schemaManager.getRegistries().clone();
-
-            // Relax the cloned registries
-            clonedRegistries.setRelaxed();
-
-            // Before removing a comparator, we have to check that there are no MR pointing
-            // on it, as it won't be done during the integrity check : in this case, the
-            // check will create a default comparator instead of raising an error...
-            if ( clonedRegistries.getMatchingRuleRegistry().contains( comparator.getOid()
) )
-            {
-                // We have some error : reject the deletion and get out
-                // Destroy the cloned registries
-                clonedRegistries.clear();
-
-                String msg = "There is at least one MatchingRule using the Comparator with
OID " + comparator.getOid();
-                LOG.debug( msg );
-
-                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
-            }
-
-            // Remove this Comparator from the Registries
-            clonedRegistries.delete( errors, comparator );
-
-            // Remove the Comparator from the schema/SchemaObject Map
-            clonedRegistries.dissociateFromSchema( comparator );
-
-            // Check the registries now
-            errors = clonedRegistries.checkRefInteg();
-
-            // If we didn't get any error, swap the registries
-            if ( errors.size() == 0 )
+            if ( schemaManager.delete( comparator ) )
             {
-                clonedRegistries.setStrict();
-                //schemaManager.swapRegistries( clonedRegistries );
+                LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName
);
             }
             else
             {
-                // We have some error : reject the deletion and get out
-                // Destroy the cloned registries
-                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, "
                     + "the resulting registries would be inconsistent :" + StringTools.listToString(
errors );
                 LOG.info( msg );
-                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
             }
         }
         else
         {
             // Should not be there...
+            // At least, we register the OID in the globalOidRegistry, and associates it
with the
+            // schema
+            schemaManager.getRegistries().associateWithSchema( errors, comparator );
+
+            if ( !errors.isEmpty() )
+            {
+                String msg = "Cannot add the AttributeType " + entry.getDn().getUpName()
+ " into the registries, "
+                    + "we have got some errors :" + StringTools.listToString( errors );
+
+                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
+            }
+
+            LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName
);
         }
     }
 

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.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/NormalizerSynchronizer.java?rev=891463&r1=891462&r2=891463&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java
Wed Dec 16 22:48:16 2009
@@ -37,7 +37,6 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.Normalizer;
 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;
@@ -123,30 +122,16 @@
 
         if ( schema.isEnabled() && normalizer.isEnabled() )
         {
-            // As we may break the registries, work on a cloned registries
-            Registries clonedRegistries = schemaManager.getRegistries().clone();
-
-            // Inject the newly created Normalizer in the cloned registries
-            clonedRegistries.add( errors, normalizer );
-
-            // Remove the cloned registries
-            clonedRegistries.clear();
-
-            // If we didn't get any error, add the Normalizer into the real registries
-            if ( errors.isEmpty() )
+            if ( schemaManager.add( normalizer ) )
             {
-                // Apply the addition to the real registries
-                schemaManager.getRegistries().add( errors, normalizer );
-
                 LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName
);
             }
             else
             {
-                // We have some error : reject the addition and get out
-                String msg = "Cannot add the Normalizer " + entry.getDn().getUpName() + "
into the registries, "
+                String msg = "Cannot delete the Normalizer " + 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
);
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
             }
         }
         else

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.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/SyntaxCheckerSynchronizer.java?rev=891463&r1=891462&r2=891463&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java
Wed Dec 16 22:48:16 2009
@@ -125,30 +125,16 @@
 
         if ( schema.isEnabled() && syntaxChecker.isEnabled() )
         {
-            // As we may break the registries, work on a cloned registries
-            Registries clonedRegistries = schemaManager.getRegistries().clone();
-
-            // Inject the newly created SyntaxChecker in the cloned registries
-            clonedRegistries.add( errors, syntaxChecker );
-
-            // Remove the cloned registries
-            clonedRegistries.clear();
-
-            // If we didn't get any error, add the SyntaxChecker into the real registries
-            if ( errors.isEmpty() )
+            if ( schemaManager.add( syntaxChecker ) )
             {
-                // Apply the addition to the real registries
-                schemaManager.getRegistries().add( errors, syntaxChecker );
-
                 LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName
);
             }
             else
             {
-                // We have some error : reject the addition and get out
-                String msg = "Cannot add the SyntaxChecker " + entry.getDn().getUpName()
+ " into the registries, "
+                String msg = "Cannot delete the SyntaxChecker " + 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
);
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM
);
             }
         }
         else



Mime
View raw message