directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r819577 - /directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/
Date Mon, 28 Sep 2009 15:05:45 GMT
Author: elecharny
Date: Mon Sep 28 15:05:44 2009
New Revision: 819577

URL: http://svn.apache.org/viewvc?rev=819577&view=rev
Log:
Update the SchemaObject synchronizers so that when a SchemaObject is added or removed from a schema, the list of contained SO in this schema is updated

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/DitContentRuleSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.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-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.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/ObjectClassSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxCheckerSynchronizer.java
    directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.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=819577&r1=819576&r2=819577&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 Sep 28 15:05:44 2009
@@ -32,15 +32,19 @@
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
 import org.apache.directory.shared.ldap.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.shared.ldap.schema.SchemaWrapper;
 import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
 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;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -51,6 +55,9 @@
  */
 public abstract class AbstractRegistrySynchronizer implements RegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( AbstractRegistrySynchronizer.class );
+
     /** The global registries */
     protected final Registries registries;
     
@@ -73,6 +80,13 @@
     }
     
     
+    /**
+     * Tells if the schema the DN references is loaded or not
+     *
+     * @param dn The SchemaObject's DN 
+     * @return true if the schema is loaded
+     * @throws Exception If The DN is not a SchemaObject DN
+     */
     protected boolean isSchemaLoaded( LdapDN dn ) throws Exception
     {
         return registries.isSchemaLoaded( getSchemaName( dn ) );
@@ -80,6 +94,18 @@
     
     
     /**
+     * Tells if the schemaName is loaded or not
+     *
+     * @param schemaName The schema we want to check
+     * @return true if the schema is loaded
+     */
+    protected boolean isSchemaLoaded( String schemaName )
+    {
+        return registries.isSchemaLoaded( schemaName );
+    }
+    
+    
+    /**
      * Tells if a schema is loaded and enabled 
      *
      * @param schemaName The schema we want to check
@@ -149,7 +175,84 @@
                 ResultCodeEnum.OTHER );
         }
     }
+
     
+    /**
+     * Add a new SchemaObject to the schema registry, assuming that
+     * it has an associated schema and that this schema is loaded
+     */
+    protected void addToSchema( SchemaObject schemaObject, String schemaName ) throws Exception
+    {
+        if ( isSchemaLoaded( schemaName ) )
+        {
+            Set<SchemaWrapper> schemaObjects = registries.getObjectBySchemaname().get( schemaName );
+            
+            if ( schemaObjects == null )
+            {
+                schemaObjects = registries.addSchema( schemaName );
+            }
+            
+            SchemaWrapper schemaWrapper = new SchemaWrapper( schemaObject );
+            
+            if ( schemaObjects.contains( schemaWrapper ) )
+            {
+                String msg = "Cannot inject " + schemaObject.getName() + " into " + schemaName + 
+                " as this schema already contains this element";
+                LOG.warn( msg );
+            
+                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+            }
+            
+            schemaObjects.add( schemaWrapper );
+            LOG.debug( "The SchemaObject {} has been added to the schema {}", schemaObject, schemaName   );
+        }
+        else
+        {
+            String msg = "Cannot inject " + schemaObject.getName() + " into " + schemaName + 
+            " as this schema is not loaded";
+            LOG.warn( msg );
+        
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+    }
+
+    
+    
+    
+    /**
+     * Delete a SchemaObject from the schema registry, assuming that
+     * it has an associated schema and that this schema is loaded
+     */
+    protected void deleteFromSchema( SchemaObject schemaObject, String schemaName ) throws Exception
+    {
+        if ( isSchemaLoaded( schemaName ) )
+        {
+            Set<SchemaWrapper> schemaObjects = registries.getObjectBySchemaname().get( schemaName );
+
+            SchemaWrapper schemaWrapper = new SchemaWrapper( schemaObject );
+            
+            if ( !schemaObjects.contains( schemaWrapper ) )
+            {
+                String msg = "Cannot remove " + schemaObject.getName() + " from " + schemaName + 
+                " as this schema does not contain this element";
+                LOG.warn( msg );
+            
+                throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+            }
+            
+            schemaObjects.remove( schemaWrapper );
+            LOG.debug(  "The SchemaObject {} has been removed from the schema {}", schemaObject, schemaName );
+        }
+        else
+        {
+            String msg = "Cannot inject " + schemaObject.getName() + " into " + schemaName + 
+            " as this schema is not loaded";
+            LOG.warn( msg );
+        
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+    }
+
     
     protected abstract boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) 
         throws Exception;

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=819577&r1=819576&r2=819577&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 Sep 28 15:05:44 2009
@@ -33,6 +33,8 @@
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -44,15 +46,55 @@
  */
 public class AttributeTypeSynchronizer extends AbstractRegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( AttributeTypeSynchronizer.class );
+
+    /** A reference to the AttributeType registry */
     private final AttributeTypeRegistry atRegistry;
 
-    
+    /**
+     * Creates a new instance of AttributeTypeSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     public AttributeTypeSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
         this.atRegistry = registries.getAttributeTypeRegistry();
     }
 
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws Exception
+    {
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
+        parentDn.remove( parentDn.size() - 1 );
+        
+        checkNewParent( parentDn );
+        checkOidIsUnique( entry );
+        
+        String schemaName = getSchemaName( dn );
+        AttributeType at = factory.getAttributeType( entry, registries, schemaName );
+        
+        addToSchema( at, schemaName );
+        
+        if ( isSchemaEnabled( schemaName ) )
+        {
+            // Don't inject the modified element if the schema is disabled
+            atRegistry.register( at );
+            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
+        }
+        else
+        {
+            registerOids( at );
+            LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName );
+        }
+    }
+
 
     public boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) 
         throws Exception
@@ -77,57 +119,47 @@
     }
     
     
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
-    {
-        LdapDN parentDn = ( LdapDN ) name.clone();
-        parentDn.remove( parentDn.size() - 1 );
-        checkNewParent( parentDn );
-        checkOidIsUnique( entry );
-        
-        String schemaName = getSchemaName( name );
-        AttributeType at = factory.getAttributeType( entry, registries, schemaName );
-        
-        if ( isSchemaEnabled( schemaName ) )
-        {
-            // Don't inject the modified element if the schema is disabled
-            atRegistry.register( at );
-        }
-        else
-        {
-            registerOids( at );
-        }
-    }
-
-
     /**
-     * Delete the attributeType, if it has no descendant.
-     * 
-     * @param entry the AttributeType entry to delete
-     * @param cascade unused
-     * @exception Exception if the deletion failed
+     * {@inheritDoc}
      */
     public void delete( ServerEntry entry, boolean cascade ) throws Exception
     {
         String schemaName = getSchemaName( entry.getDn() );
-        AttributeType at = factory.getAttributeType( entry, registries, schemaName );
+        AttributeType attributeType = factory.getAttributeType( entry, registries, schemaName );
         
+        if ( !isSchemaLoaded( schemaName ) )
+        {
+            // Cannot remove an AT from a not loaded schema
+            String msg = "Cannot delete " + entry.getDn().getUpName() + ", from the not loade schema " +
+                schemaName;
+            LOG.warn( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
         if ( isSchemaEnabled( schemaName ) )
         {
             // Check that the entry has no descendant
-            if ( atRegistry.hasDescendants( at.getOid() ) )
+            if ( atRegistry.hasDescendants( attributeType.getOid() ) )
             {
                 String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
                     " dependant AttributeTypes";
-                
+                LOG.warn( msg );
                 throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
-            
+        }
+
+        deleteFromSchema( attributeType, schemaName );
+
+        if ( isSchemaEnabled( schemaName ) )
+        {
             // Don't inject the modified element if the schema is disabled
-            atRegistry.unregister( at.getOid() );
+            atRegistry.unregister( attributeType.getOid() );
+            LOG.debug( "Removed {} from the enabled schema {}", attributeType, schemaName );
         }
         else
         {
-            unregisterOids( at );
+            unregisterOids( attributeType );
+            LOG.debug( "Removed {} from the disabled schema {}", attributeType, schemaName );
         }
     }
 
@@ -187,7 +219,25 @@
         String newOid = ( String ) newRn.getValue();
         targetEntry.put( MetaSchemaConstants.M_OID_AT, newOid );
         checkOidIsUnique( newOid );
-        AttributeType at = factory.getAttributeType( targetEntry, registries, newSchemaName );
+        AttributeType newAt = factory.getAttributeType( targetEntry, registries, newSchemaName );
+
+        
+        if ( !isSchemaLoaded( oldSchemaName ) )
+        {
+            String msg = "Cannot move a schemaObject from a not loaded schema " + oldSchemaName;
+            LOG.warn( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        if ( !isSchemaLoaded( newSchemaName ) )
+        {
+            String msg = "Cannot move a schemaObject to a not loaded schema " + newSchemaName;
+            LOG.warn( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        deleteFromSchema( oldAt, oldSchemaName );
+        addToSchema( newAt, newSchemaName );
 
         if ( isSchemaEnabled( oldSchemaName ) )
         {
@@ -200,11 +250,11 @@
 
         if ( isSchemaEnabled( newSchemaName ) )
         {
-            atRegistry.register( at );
+            atRegistry.register( newAt );
         }
         else
         {
-            registerOids( at );
+            registerOids( newAt );
         }
     }
 
@@ -216,7 +266,24 @@
         String oldSchemaName = getSchemaName( oriChildName );
         String newSchemaName = getSchemaName( newParentName );
         AttributeType oldAt = factory.getAttributeType( entry, registries, oldSchemaName );
-        AttributeType at = factory.getAttributeType( entry, registries, newSchemaName );
+        AttributeType newAt = factory.getAttributeType( entry, registries, newSchemaName );
+        
+        if ( !isSchemaLoaded( oldSchemaName ) )
+        {
+            String msg = "Cannot move a schemaObject from a not loaded schema " + oldSchemaName;
+            LOG.warn( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        if ( !isSchemaLoaded( newSchemaName ) )
+        {
+            String msg = "Cannot move a schemaObject to a not loaded schema " + newSchemaName;
+            LOG.warn( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        deleteFromSchema( oldAt, oldSchemaName );
+        addToSchema( newAt, newSchemaName );
         
         if ( isSchemaEnabled( oldSchemaName ) )
         {
@@ -229,11 +296,11 @@
         
         if ( isSchemaEnabled( newSchemaName ) )
         {
-            atRegistry.register( at );
+            atRegistry.register( newAt );
         }
         else
         {
-            registerOids( at );
+            registerOids( newAt );
         }
     }
     

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=819577&r1=819576&r2=819577&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 Sep 28 15:05:44 2009
@@ -35,6 +35,8 @@
 import org.apache.directory.shared.ldap.schema.registries.ComparatorRegistry;
 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;
 
 
 /**
@@ -46,10 +48,22 @@
  */
 public class ComparatorSynchronizer extends AbstractRegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( ComparatorSynchronizer.class );
+
+    /** The Comparator registry */
     private final ComparatorRegistry comparatorRegistry;
+    
+    /** The MatchingRule registry */
     private final MatchingRuleRegistry matchingRuleRegistry;
 
     
+    /**
+     * Creates a new instance of ComparatorSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     public ComparatorSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -78,20 +92,27 @@
     }
     
 
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws Exception
     {
-        LdapDN parentDn = ( LdapDN ) name.clone();
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
         checkNewParent( parentDn );
         checkOidIsUniqueForComparator( entry );
         LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
         
-        String schemaName = getSchemaName( name );
+        String schemaName = getSchemaName( dn );
         comparator.setSchemaName( schemaName );
         
+        addToSchema( comparator, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             comparatorRegistry.register( comparator );
+            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }
     }
 
@@ -102,18 +123,30 @@
     public void delete( ServerEntry entry, boolean cascade ) throws Exception
     {
         String oid = getOid( entry );
+        String schemaName = getSchemaName( entry.getDn() ); 
         
         if ( matchingRuleRegistry.contains( oid ) )
         {
-            throw new LdapOperationNotSupportedException( "The comparator with OID " + oid 
+            String msg = "The comparator with OID " + oid 
                 + " cannot be deleted until all " 
-                + "matchingRules using that comparator have also been deleted.", 
+                + "matchingRules using that comparator have also been deleted.";
+            LOG.warn(  msg  );
+            throw new LdapOperationNotSupportedException( msg, 
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
+        LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+
+        deleteFromSchema( comparator, schemaName );
+
         if ( comparatorRegistry.contains( oid ) )
         {
             comparatorRegistry.unregister( oid );
+            LOG.debug( "Removed {} from the enabled schema {}", comparator, schemaName );
+        }
+        else
+        {
+            LOG.debug( "Removed {} from the disabled schema {}", comparator, schemaName );
         }
     }
 

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.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/DitContentRuleSynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java Mon Sep 28 15:05:44 2009
@@ -38,6 +38,12 @@
 public class DitContentRuleSynchronizer extends AbstractRegistrySynchronizer
 {
 
+    /**
+     * Creates a new instance of DitContentRuleSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     protected DitContentRuleSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -57,10 +63,10 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#add(org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+    /**
+     * {@inheritDoc}
      */
-    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    public void add( ServerEntry entry ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.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/DitStructureRuleSynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java Mon Sep 28 15:05:44 2009
@@ -37,7 +37,12 @@
  */
 public class DitStructureRuleSynchronizer extends AbstractRegistrySynchronizer
 {
-
+    /**
+     * Creates a new instance of DitStructureSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     protected DitStructureRuleSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -59,11 +64,10 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#add(
-     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+    /**
+     * {@inheritDoc}
      */
-    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    public void add( ServerEntry entry ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

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=819577&r1=819576&r2=819577&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 Sep 28 15:05:44 2009
@@ -32,6 +32,8 @@
 import org.apache.directory.shared.ldap.schema.MatchingRule;
 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;
 
 
 /**
@@ -43,9 +45,19 @@
  */
 public class MatchingRuleSynchronizer extends AbstractRegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( MatchingRuleSynchronizer.class );
+
+    /** The matchingRule registry */
     private final MatchingRuleRegistry matchingRuleRegistry;
 
     
+    /**
+     * Creates a new instance of MatchingRuleSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     public MatchingRuleSynchronizer( Registries registries ) 
         throws Exception
     {
@@ -76,23 +88,31 @@
     }
 
 
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws Exception
     {
-        LdapDN parentDn = ( LdapDN ) name.clone();
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
         checkNewParent( parentDn );
         checkOidIsUnique( entry );
         
-        String schemaName = getSchemaName( name );
+        String schemaName = getSchemaName( dn );
         MatchingRule mr = factory.getMatchingRule( entry, registries, schemaName );
         
+        addToSchema( mr, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             matchingRuleRegistry.register( mr );
+            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }
         else
         {
             registerOids( mr );
+            LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName );
         }
     }
 
@@ -103,15 +123,19 @@
     public void delete( ServerEntry entry, boolean cascade ) throws Exception
     {
         String schemaName = getSchemaName( entry.getDn() );
-        MatchingRule mr = factory.getMatchingRule( entry, registries, schemaName );
+        MatchingRule matchingRule = factory.getMatchingRule( entry, registries, schemaName );
+        
+        deleteFromSchema( matchingRule, schemaName );
         
         if ( isSchemaEnabled( schemaName ) )
         {
-            matchingRuleRegistry.unregister( mr.getOid() );
+            matchingRuleRegistry.unregister( matchingRule.getOid() );
+            LOG.debug( "Removed {} from the enabled schema {}", matchingRule, schemaName );
         }
         else
         {
-            unregisterOids( mr );
+            unregisterOids( matchingRule );
+            LOG.debug( "Removed {} from the disabled schema {}", matchingRule, schemaName );
         }
     }
 

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.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/MatchingRuleUseSynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java Mon Sep 28 15:05:44 2009
@@ -37,7 +37,12 @@
  */
 public class MatchingRuleUseSynchronizer extends AbstractRegistrySynchronizer
 {
-
+    /**
+     * Creates a new instance of MatchingRuleUseSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     protected MatchingRuleUseSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -54,7 +59,10 @@
     }
 
 
-    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.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/NameFormSynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java Mon Sep 28 15:05:44 2009
@@ -37,6 +37,12 @@
  */
 public class NameFormSynchronizer extends AbstractRegistrySynchronizer
 {
+    /**
+     * Creates a new instance of NameFormSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     protected NameFormSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -56,11 +62,10 @@
     }
 
 
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#add(
-     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+    /**
+     * {@inheritDoc}
      */
-    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    public void add( ServerEntry entry ) throws NamingException
     {
         // TODO Auto-generated method stub
     }

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=819577&r1=819576&r2=819577&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 Mon Sep 28 15:05:44 2009
@@ -35,6 +35,8 @@
 import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
 import org.apache.directory.shared.ldap.schema.registries.NormalizerRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -45,10 +47,22 @@
  */
 public class NormalizerSynchronizer extends AbstractRegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( NormalizerSynchronizer.class );
+
+    /** The normalizer registry */
     private final NormalizerRegistry normalizerRegistry;
+    
+    /** The matchingRule registry */
     private final MatchingRuleRegistry matchingRuleRegistry;
     
 
+    /**
+     * Creates a new instance of NormalizerSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     public NormalizerSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -77,21 +91,28 @@
     }
 
 
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws Exception
     {
-        LdapDN parentDn = ( LdapDN ) name.clone();
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
         checkNewParent( parentDn );
         checkOidIsUniqueForNormalizer( entry );
         
         Normalizer normalizer = factory.getNormalizer( entry, registries );
         
-        String schemaName = getSchemaName( name );
+        String schemaName = getSchemaName( dn );
         normalizer.setSchemaName( schemaName );
         
+        addToSchema( normalizer, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             normalizerRegistry.register( normalizer );
+            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }
     }
 
@@ -101,23 +122,30 @@
      */
     public void delete( ServerEntry entry, boolean cascade ) throws Exception
     {
-        delete( getOid( entry ), cascade );
-    }
-
-
-    public void delete( String oid, boolean cascade ) throws NamingException
-    {
+        String schemaName = getSchemaName( entry.getDn() );
+        Normalizer normalizer = factory.getNormalizer( entry, registries );
+        String oid = normalizer.getOid();
+        
         if ( matchingRuleRegistry.contains( oid ) )
         {
-            throw new LdapOperationNotSupportedException( "The normalizer with OID " + oid 
+            String msg = "The normalizer with OID " + oid 
                 + " cannot be deleted until all " 
-                + "matchingRules using that normalizer have also been deleted.", 
+                + "matchingRules using that normalizer have also been deleted.";
+            LOG.warn(  msg  );
+            throw new LdapOperationNotSupportedException( msg, 
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
+        deleteFromSchema( normalizer, schemaName );
+
         if ( normalizerRegistry.contains( oid ) )
         {
             normalizerRegistry.unregister( oid );
+            LOG.debug( "Removed {} from the enabled schema {}", normalizer, schemaName );
+        }
+        else
+        {
+            LOG.debug( "Removed {} from the enabled schema {}", normalizer, schemaName );
         }
     }
     

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.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/ObjectClassSynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ObjectClassSynchronizer.java Mon Sep 28 15:05:44 2009
@@ -33,6 +33,8 @@
 import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -43,9 +45,19 @@
  */
 public class ObjectClassSynchronizer extends AbstractRegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( ObjectClassSynchronizer.class );
+
+    /** The ObjectClass registry */
     private final ObjectClassRegistry objectClassRegistry;
 
 
+    /**
+     * Creates a new instance of ObjectClassSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     public ObjectClassSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -71,23 +83,31 @@
     }
 
 
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws Exception
     {
-        LdapDN parentDn = ( LdapDN ) name.clone();
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
         checkNewParent( parentDn );
         checkOidIsUnique( entry );
         
-        String schemaName = getSchemaName( name );
+        String schemaName = getSchemaName( dn );
         ObjectClass oc = factory.getObjectClass( entry, registries, schemaName );
 
+        addToSchema( oc, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             objectClassRegistry.register( oc );
+            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }
         else
         {
             registerOids( oc );
+            LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName );
         }
     }
 
@@ -98,24 +118,40 @@
     public void delete( ServerEntry entry, boolean cascade ) throws Exception
     {
         String schemaName = getSchemaName( entry.getDn() );
-        ObjectClass oc = factory.getObjectClass( entry, registries, schemaName );
+        ObjectClass objectClass = factory.getObjectClass( entry, registries, schemaName );
+
+        if ( !isSchemaLoaded( schemaName ) )
+        {
+            // Cannot remove an AT from a not loaded schema
+            String msg = "Cannot delete " + entry.getDn().getUpName() + ", from the not loade schema " +
+                schemaName;
+            LOG.warn( msg );
+            throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
 
         if ( isSchemaEnabled( schemaName ) )
         {
             // Check that the entry has no descendant
-            if ( objectClassRegistry.hasDescendants( oc.getOid() ) )
+            if ( objectClassRegistry.hasDescendants( objectClass.getOid() ) )
             {
                 String msg = "Cannot delete " + entry.getDn().getUpName() + ", as there are some " +
                     " dependant ObjectClasses";
                 
                 throw new LdapOperationNotSupportedException( msg, ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
-            
-            objectClassRegistry.unregister( oc.getOid() );
+        }
+
+        deleteFromSchema( objectClass, schemaName );
+
+        if ( isSchemaEnabled( schemaName ) )
+        {
+            objectClassRegistry.unregister( objectClass.getOid() );
+            LOG.debug( "Removed {} from the enabled schema {}", objectClass, schemaName );
         }
         else
         {
-            unregisterOids( oc );
+            unregisterOids( objectClass );
+            LOG.debug( "Removed {} from the disabled schema {}", objectClass, schemaName );
         }
     }
 

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.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/RegistrySynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizer.java Mon Sep 28 15:05:44 2009
@@ -45,7 +45,13 @@
     static final boolean SCHEMA_UNCHANGED = false;
     
     
-    void add( LdapDN name, ServerEntry entry ) throws Exception;
+    /**
+     * Adds a new SchemaObject to its registry
+     *
+     * @param entry The SchemObject to add
+     * @throws Exception If the addition failed
+     */
+    void add( ServerEntry entry ) throws Exception;
     
     
     /**

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/RegistrySynchronizerAdaptor.java Mon Sep 28 15:05:44 2009
@@ -44,10 +44,8 @@
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 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.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.ObjectClass;
-import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.registries.ObjectClassRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.slf4j.Logger;
@@ -69,6 +67,7 @@
  */
 public class RegistrySynchronizerAdaptor
 {
+    /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( RegistrySynchronizerAdaptor.class );
 
     // indices of handlers and object ids into arrays
@@ -164,18 +163,16 @@
             if ( objectClass2synchronizerMap.containsKey( oid ) )
             {
                 RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
-                LdapDN dn = opContext.getDn();
                 ServerEntry entry = opContext.getEntry();
-                synchronizer.add( dn, entry );
+                synchronizer.add( entry );
                 return;
             }
         }
         
         if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
         {
-            LdapDN dn = opContext.getDn();
             ServerEntry entry = opContext.getEntry();
-            schemaSynchronizer.add( dn, entry );
+            schemaSynchronizer.add( entry );
             return;
         }
         
@@ -415,18 +412,4 @@
         
         throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
     }
-
-    
-    /* (non-Javadoc)
-     * @see org.apache.directory.server.core.schema.SchemaChangeManager#getSchema(org.apache.directory.shared.ldap.schema.SchemaObject)
-     */
-    public String getSchema( SchemaObject schemaObject ) 
-    {
-        if ( schemaObject.getExtensions().containsKey( MetaSchemaConstants.X_SCHEMA ) )
-        {
-            return schemaObject.getExtensions().get( MetaSchemaConstants.X_SCHEMA ).get( 0 );
-        }
-        
-        return MetaSchemaConstants.SCHEMA_OTHER;
-    }
 }

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SchemaSynchronizer.java Mon Sep 28 15:05:44 2009
@@ -27,7 +27,6 @@
 
 import javax.naming.NamingException;
 
-import org.apache.commons.lang.NotImplementedException;
 import org.apache.directory.server.constants.ServerDNConstants;
 import org.apache.directory.server.core.entry.ServerAttribute;
 import org.apache.directory.server.core.entry.ServerEntry;
@@ -46,10 +45,13 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
+import org.apache.directory.shared.ldap.schema.SchemaWrapper;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.registries.Schema;
 import org.apache.directory.shared.ldap.schema.registries.SchemaObjectRegistry;
 import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -61,6 +63,9 @@
  */
 public class SchemaSynchronizer implements RegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( SchemaSynchronizer.class );
+
     private final SchemaEntityFactory factory;
     private final PartitionSchemaLoader loader;
     
@@ -211,9 +216,10 @@
      * @param name the dn of the new metaSchema object
      * @param entry the attributes of the new metaSchema object
      */
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    public void add( ServerEntry entry ) throws Exception
     {
-        LdapDN parentDn = ( LdapDN ) name.clone();
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
         parentDn.normalize( registries.getAttributeTypeRegistry().getNormalizerMapping() );
 
@@ -288,10 +294,13 @@
         // Before allowing a schema object to be deleted we must check
         // to make sure it's not depended upon by another schema
         Set<String> dependents = loader.listDependentSchemaNames( schemaName );
+        
         if ( ! dependents.isEmpty() )
         {
+            String msg = "Cannot delete schema that has dependents: " + dependents; 
+            LOG.warn( msg );
             throw new LdapOperationNotSupportedException(
-                "Cannot delete schema that has dependents: " + dependents,
+                msg,
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
@@ -521,16 +530,15 @@
         
         schema.disable();
         
-        // @TODO elecharny
-        
-        if ( "blah".equals( "blah" ) )
+        Set<SchemaWrapper> content = registries.getLoadedSchema( schemaName ).getContent(); 
+
+        for ( SchemaWrapper schemaWrapper : content )
         {
-            throw new NotImplementedException( "We have to disable the schema on partition" +
-                    " and we have to implement the unload method below." );
+            SchemaObject schemaObject = schemaWrapper.get();
+            
+            System.out.println( "Disabling " + schemaObject.getName() );
         }
         
-        // registries.unload( schemaName );
-        
         return SCHEMA_MODIFIED;
     }
 

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=819577&r1=819576&r2=819577&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 Mon Sep 28 15:05:44 2009
@@ -35,6 +35,8 @@
 import org.apache.directory.shared.ldap.schema.registries.LdapSyntaxRegistry;
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 import org.apache.directory.shared.ldap.schema.registries.SyntaxCheckerRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 
 /**
@@ -46,10 +48,22 @@
  */
 public class SyntaxCheckerSynchronizer extends AbstractRegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( SyntaxCheckerSynchronizer.class );
+
+    /** The SyntaxChecker registry */
     private final SyntaxCheckerRegistry syntaxCheckerRegistry;
+    
+    /** The Syntax registry */
     private final LdapSyntaxRegistry ldapSyntaxRegistry;
     
 
+    /**
+     * Creates a new instance of SyntaxCheckerSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     public SyntaxCheckerSynchronizer( Registries registries ) throws Exception
     {
         super( registries );
@@ -78,9 +92,13 @@
     }
 
 
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws Exception
     {
-        LdapDN parentDn = ( LdapDN ) name.clone();
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
         checkNewParent( parentDn );
         String oid = getOid( entry );
@@ -93,12 +111,15 @@
         
         SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries );
 
-        String schemaName = getSchemaName( name );
+        String schemaName = getSchemaName( dn );
         syntaxChecker.setSchemaName( schemaName );
 
+        addToSchema( syntaxChecker, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             syntaxCheckerRegistry.register( syntaxChecker );
+            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }
     }
 
@@ -112,17 +133,26 @@
         
         if ( ldapSyntaxRegistry.contains( oid ) )
         {
-            throw new LdapOperationNotSupportedException( "The syntaxChecker with OID " + oid 
+            String msg = "The syntaxChecker with OID " + oid 
                 + " cannot be deleted until all " 
-                + "syntaxes using this syntaxChecker have also been deleted.", 
+                + "syntaxes using this syntaxChecker have also been deleted.";
+            throw new LdapOperationNotSupportedException( msg, 
                 ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
         String schemaName = getSchemaName( entry.getDn() );
 
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, registries );
+        deleteFromSchema( syntaxChecker, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             syntaxCheckerRegistry.unregister( oid );
+            LOG.debug( "Removed {} from the enabled schema {}", syntaxChecker, schemaName );
+        }
+        else
+        {
+            LOG.debug( "Removed {} from the disabled schema {}", syntaxChecker, schemaName );
         }
     }
 

Modified: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.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/SyntaxSynchronizer.java?rev=819577&r1=819576&r2=819577&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java (original)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/SyntaxSynchronizer.java Mon Sep 28 15:05:44 2009
@@ -41,6 +41,8 @@
 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;
 
 
 /**
@@ -52,9 +54,19 @@
  */
 public class SyntaxSynchronizer extends AbstractRegistrySynchronizer
 {
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( SyntaxSynchronizer.class );
+
+    /** The Synatx registry */
     private final LdapSyntaxRegistry syntaxRegistry;
 
     
+    /**
+     * Creates a new instance of SyntaxSynchronizer.
+     *
+     * @param registries The global registries
+     * @throws Exception If the initialization failed
+     */
     public SyntaxSynchronizer( Registries registries ) 
         throws Exception
     {
@@ -81,23 +93,31 @@
     }
 
     
-    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    /**
+     * {@inheritDoc}
+     */
+    public void add( ServerEntry entry ) throws Exception
     {
-        LdapDN parentDn = ( LdapDN ) name.clone();
+        LdapDN dn = entry.getDn();
+        LdapDN parentDn = ( LdapDN ) dn.clone();
         parentDn.remove( parentDn.size() - 1 );
         checkNewParent( parentDn );
         checkOidIsUnique( entry );
         
-        String schemaName = getSchemaName( name );
+        String schemaName = getSchemaName( dn );
         LdapSyntax syntax = factory.getSyntax( entry, registries, schemaName );
 
+        addToSchema( syntax, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             syntaxRegistry.register( syntax );
+            LOG.debug( "Added {} into the enabled schema {}", dn.getUpName(), schemaName );
         }
         else
         {
             registerOids( syntax );
+            LOG.debug( "Added {} into the disabled schema {}", dn.getUpName(), schemaName );
         }
     }
 
@@ -172,20 +192,26 @@
         
         if ( dependees.size() != 0 )
         {
-            throw new LdapOperationNotSupportedException( "The syntax with OID " + oid 
-              + " cannot be deleted until all entities" 
-              + " using this syntax have also been deleted.  The following dependees exist: " 
-              + getNames( dependees ), 
+            String msg = "The syntax with OID " + oid 
+                + " cannot be deleted until all entities" 
+                + " using this syntax have also been deleted.  The following dependees exist: " 
+                + getNames( dependees );
+            LOG.warn(  msg  );
+            throw new LdapOperationNotSupportedException( msg, 
               ResultCodeEnum.UNWILLING_TO_PERFORM );
         }
         
+        deleteFromSchema( syntax, schemaName );
+
         if ( isSchemaEnabled( schemaName ) )
         {
             syntaxRegistry.unregister( oid );
+            LOG.debug( "Removed {} from the enabled schema {}", syntax, schemaName );
         }
         else
         {
             unregisterOids( syntax );
+            LOG.debug( "Removed {} from the enabled schema {}", syntax, schemaName );
         }
     }
 



Mime
View raw message