directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r811964 [1/2] - in /directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries: ./ synchronizers/
Date Mon, 07 Sep 2009 01:29:40 GMT
Author: akarasulu
Date: Mon Sep  7 01:29:38 2009
New Revision: 811964

URL: http://svn.apache.org/viewvc?rev=811964&view=rev
Log:
adding decoupled registry synchronizers which are used by the schema partition to synchronize changes on disk with in memory schema data structures

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

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AbstractRegistrySynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,174 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.exception.LdapNamingException;
+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.registries.Registries;
+import org.apache.directory.shared.schema.loader.ldif.SchemaEntityFactory;
+
+//import javax.naming.NamingException;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.NamingException;
+
+
+/**
+ * An abstract registry synchronizer with some reused functionality.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public abstract class AbstractRegistrySynchronizer implements RegistrySynchronizer
+{
+    protected final Registries registries;
+    protected final AttributeType m_oidAT;
+    protected final SchemaEntityFactory factory;
+
+    
+    protected AbstractRegistrySynchronizer( Registries targetRegistries ) throws Exception
+    {
+        this.registries = targetRegistries;
+        this.m_oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+        this.factory = new SchemaEntityFactory();
+    }
+    
+    
+    protected boolean isSchemaLoaded( LdapDN dn ) throws Exception
+    {
+        return registries.isSchemaLoaded( getSchemaName( dn ) );
+    }
+    
+    
+    protected String getSchemaName( LdapDN dn ) throws NamingException
+    {
+        if ( dn.size() < 2 )
+        {
+            throw new NamingException( "At least two name components are expected for the dn" );
+        }
+        
+        Rdn rdn = dn.getRdn( 1 );
+        return ( String ) rdn.getValue();
+    }
+
+
+    protected void checkOidIsUnique( ServerEntry entry ) throws Exception
+    {
+        String oid = getOid( entry );
+
+        if ( registries.getOidRegistry().hasOid( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema entity is not unique.",
+                ResultCodeEnum.OTHER );
+        }
+    }
+
+
+    protected void checkOidIsUnique( SchemaObject schemaObject ) throws Exception
+    {
+        String oid = schemaObject.getOid();
+
+        if ( registries.getOidRegistry().hasOid( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema entity is not unique.",
+                ResultCodeEnum.OTHER );
+        }
+    }
+
+
+    protected void checkOidIsUnique( String oid ) throws Exception
+    {
+        if ( registries.getOidRegistry().hasOid( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema entity is not unique.",
+                ResultCodeEnum.OTHER );
+        }
+    }
+    
+    
+    protected abstract boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) 
+        throws Exception;
+    
+    
+    public final boolean modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry entry, ServerEntry targetEntry, 
+        boolean cascade ) throws Exception
+    {
+        return modify( name, entry, targetEntry, cascade );
+    }
+
+
+    public final boolean modify( LdapDN name, List<Modification> mods, ServerEntry entry,
+        ServerEntry targetEntry, boolean cascade ) throws Exception
+    {
+        return modify( name, entry, targetEntry, cascade );
+    }
+
+    
+    protected Set<String> getOids( Set<ServerEntry> results ) throws Exception
+    {
+        Set<String> oids = new HashSet<String>( results.size() );
+        
+        for ( ServerEntry result : results )
+        {
+            LdapDN dn = result.getDn();
+            dn.normalize( this.registries.getAttributeTypeRegistry().getNormalizerMapping() );
+            oids.add( ( String ) dn.getRdn().getValue() );
+        }
+        
+        return oids;
+    }
+    
+    
+    protected String getOid( ServerEntry entry ) throws Exception
+    {
+        EntryAttribute oid = entry.get( m_oidAT );
+        
+        if ( oid == null )
+        {
+            return null;
+        }
+        
+        return oid.getString();
+    }
+    
+    
+    protected void unregisterOids( String oid ) throws Exception
+    {
+        registries.getOidRegistry().unregister( oid );
+    }
+    
+    
+    protected void registerOids( SchemaObject obj ) throws Exception
+    {
+        registries.getOidRegistry().register( obj );
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/AttributeTypeSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,208 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.entry.ServerEntry;
+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.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.registries.AttributeTypeRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
+
+/**
+ * A handler for operations performed to add, delete, modify, rename and 
+ * move schema normalizers.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class AttributeTypeSynchronizer extends AbstractRegistrySynchronizer
+{
+    private final AttributeTypeRegistry atRegistry;
+
+    
+    public AttributeTypeSynchronizer( Registries registries ) throws Exception
+    {
+        super( registries );
+        this.atRegistry = registries.getAttributeTypeRegistry();
+    }
+
+
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) 
+        throws Exception
+    {
+        String schemaName = getSchemaName( name );
+        String oid = getOid( entry );
+        AttributeType at = factory.getAttributeType( targetEntry, registries, schemaName );
+        
+        if ( registries.isSchemaLoaded( schemaName ) )
+        {
+            atRegistry.unregister( oid );
+            atRegistry.register( at );
+            
+            return SCHEMA_MODIFIED;
+        }
+        
+        return SCHEMA_UNCHANGED;
+    }
+    
+    
+    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 ( registries.isSchemaLoaded( schemaName ) )
+        {
+            atRegistry.register( at );
+        }
+        else
+        {
+            registerOids( at );
+        }
+    }
+
+
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws Exception
+    {
+        String schemaName = getSchemaName( name );
+        AttributeType at = factory.getAttributeType( entry, registries, schemaName );
+        
+        if ( registries.isSchemaLoaded( schemaName ) )
+        {
+            atRegistry.unregister( at.getOid() );
+        }
+        unregisterOids( at.getOid() );
+    }
+
+
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws Exception
+    {
+        String schemaName = getSchemaName( name );
+        AttributeType oldAt = factory.getAttributeType( entry, registries, schemaName );
+
+        ServerEntry targetEntry = ( ServerEntry ) entry.clone();
+        String newOid = ( String ) newRdn.getValue();
+        checkOidIsUnique( newOid );
+        targetEntry.put( MetaSchemaConstants.M_OID_AT, newOid );
+        AttributeType at = factory.getAttributeType( targetEntry, registries, schemaName );
+
+        if ( registries.isSchemaLoaded( schemaName ) )
+        {
+            atRegistry.unregister( oldAt.getOid() );
+            atRegistry.register( at );
+        }
+        else
+        {
+            registerOids( at );
+        }
+        
+        unregisterOids( oldAt.getOid() );
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
+        ServerEntry entry, boolean cascade ) throws Exception
+    {
+        checkNewParent( newParentName );
+        String oldSchemaName = getSchemaName( oriChildName );
+        String newSchemaName = getSchemaName( newParentName );
+        AttributeType oldAt = factory.getAttributeType( entry, registries, oldSchemaName );
+        ServerEntry targetEntry = ( ServerEntry ) entry.clone();
+        String newOid = ( String ) newRn.getValue();
+        targetEntry.put( MetaSchemaConstants.M_OID_AT, newOid );
+        checkOidIsUnique( newOid );
+        AttributeType at = factory.getAttributeType( targetEntry, registries, newSchemaName );
+
+        if ( registries.isSchemaLoaded( oldSchemaName ) )
+        {
+            atRegistry.unregister( oldAt.getOid() );
+        }
+        unregisterOids( oldAt.getOid() );
+
+        if ( registries.isSchemaLoaded( newSchemaName ) )
+        {
+            atRegistry.register( at );
+        }
+        else
+        {
+            registerOids( at );
+        }
+    }
+
+
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, boolean cascade ) 
+        throws Exception
+    {
+        checkNewParent( newParentName );
+        String oldSchemaName = getSchemaName( oriChildName );
+        String newSchemaName = getSchemaName( newParentName );
+        AttributeType oldAt = factory.getAttributeType( entry, registries, oldSchemaName );
+        AttributeType at = factory.getAttributeType( entry, registries, newSchemaName );
+        
+        if ( registries.isSchemaLoaded( oldSchemaName ) )
+        {
+            atRegistry.unregister( oldAt.getOid() );
+        }
+        
+        if ( registries.isSchemaLoaded( newSchemaName ) )
+        {
+            atRegistry.register( at );
+        }
+    }
+    
+    
+    private void checkNewParent( LdapDN newParent ) throws NamingException
+    {
+        if ( newParent.size() != 3 )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent dn of a attributeType should be at most 3 name components in length.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        Rdn rdn = newParent.getRdn();
+        if ( ! registries.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) )
+        {
+            throw new LdapInvalidNameException( "The parent entry of a attributeType should be an organizationalUnit.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( SchemaConstants.ATTRIBUTE_TYPES_AT ) )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent entry of a attributeType should have a relative name of ou=attributeTypes.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/ComparatorSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,238 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+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.LdapComparator;
+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;
+
+
+/**
+ * A handler for operations performed to add, delete, modify, rename and 
+ * move schema comparators.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class ComparatorSynchronizer extends AbstractRegistrySynchronizer
+{
+    private final ComparatorRegistry comparatorRegistry;
+    private final MatchingRuleRegistry matchingRuleRegistry;
+
+    
+    public ComparatorSynchronizer( Registries registries ) throws Exception
+    {
+        super( registries );
+        this.comparatorRegistry = registries.getComparatorRegistry();
+        this.matchingRuleRegistry = registries.getMatchingRuleRegistry();
+    }
+
+    
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+    {
+        String oid = getOid( entry );
+        LdapComparator<?> comparator = factory.getLdapComparator( targetEntry, registries );
+        
+        if ( isSchemaLoaded( name ) )
+        {
+            comparatorRegistry.unregister( oid );
+            comparatorRegistry.register( comparator );
+            
+            return SCHEMA_MODIFIED;
+        }
+        
+        return SCHEMA_UNCHANGED;
+    }
+    
+
+    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    {
+        LdapDN parentDn = ( LdapDN ) name.clone();
+        parentDn.remove( parentDn.size() - 1 );
+        checkNewParent( parentDn );
+        checkOidIsUniqueForComparator( entry );
+        LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+        
+        if ( isSchemaLoaded( name ) )
+        {
+            comparatorRegistry.register( comparator );
+        }
+    }
+
+
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws Exception
+    {
+        String oid = getOid( entry );
+        if ( matchingRuleRegistry.contains( oid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The comparator with OID " + oid 
+                + " cannot be deleted until all " 
+                + "matchingRules using that comparator have also been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        if ( comparatorRegistry.contains( oid ) )
+        {
+            comparatorRegistry.unregister( oid );
+        }
+    }
+
+    
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws Exception
+    {
+        String oldOid = getOid( entry );
+
+        if ( matchingRuleRegistry.contains( oldOid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The comparator with OID " + oldOid 
+                + " cannot have it's OID changed until all " 
+                + "matchingRules using that comparator have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        String oid = ( String ) newRdn.getValue();
+        checkOidIsUniqueForComparator( oid );
+        
+        if ( isSchemaLoaded( name ) )
+        {
+            LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+            comparatorRegistry.unregister( oldOid );
+            comparatorRegistry.register( comparator );
+        }
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRdn, boolean deleteOldRn,
+        ServerEntry entry, boolean cascade ) throws Exception
+    {
+        checkNewParent( newParentName );
+        String oldOid = getOid( entry );
+
+        if ( matchingRuleRegistry.contains( oldOid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The comparator with OID " + oldOid 
+                + " cannot have it's OID changed until all " 
+                + "matchingRules using that comparator have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        String oid = ( String ) newRdn.getValue();
+        checkOidIsUniqueForComparator( oid );
+        
+        LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+
+        if ( isSchemaLoaded( oriChildName ) )
+        {
+            comparatorRegistry.unregister( oldOid );
+        }
+
+        if ( isSchemaLoaded( newParentName ) )
+        {
+            comparatorRegistry.register( comparator );
+        }
+    }
+
+
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, boolean cascade ) 
+        throws Exception
+    {
+        checkNewParent( newParentName );
+        String oid = getOid( entry );
+
+        if ( matchingRuleRegistry.contains( oid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The comparator with OID " + oid 
+                + " cannot be moved to another schema until all " 
+                + "matchingRules using that comparator have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        LdapComparator<?> comparator = factory.getLdapComparator( entry, registries );
+        
+        if ( isSchemaLoaded( oriChildName ) )
+        {
+            comparatorRegistry.unregister( oid );
+        }
+        
+        if ( isSchemaLoaded( newParentName ) )
+        {
+            comparatorRegistry.register( comparator );
+        }
+    }
+    
+    
+    private void checkOidIsUniqueForComparator( String oid ) throws NamingException
+    {
+        if ( registries.getComparatorRegistry().contains( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema comparator is not unique.", 
+                ResultCodeEnum.OTHER );
+        }
+    }
+
+
+    private void checkOidIsUniqueForComparator( ServerEntry entry ) throws Exception
+    {
+        String oid = getOid( entry );
+        
+        if ( registries.getComparatorRegistry().contains( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema comparator is not unique.", 
+                ResultCodeEnum.OTHER );
+        }
+    }
+
+
+    private void checkNewParent( LdapDN newParent ) throws NamingException
+    {
+        if ( newParent.size() != 3 )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent dn of a comparator should be at most 3 name components in length.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        Rdn rdn = newParent.getRdn();
+        if ( ! registries.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) )
+        {
+            throw new LdapInvalidNameException( "The parent entry of a comparator should be an organizationalUnit.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( SchemaConstants.COMPARATORS_AT ) )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent entry of a comparator should have a relative name of ou=comparators.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+    }
+}

Added: directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DefaultRegistrySynchronizer.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/DefaultRegistrySynchronizer.java?rev=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DefaultRegistrySynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DefaultRegistrySynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,469 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.directory.server.core.entry.ClonedServerEntry;
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.server.core.interceptor.context.AddOperationContext;
+import org.apache.directory.server.core.interceptor.context.DeleteOperationContext;
+import org.apache.directory.server.core.interceptor.context.ModifyOperationContext;
+import org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext;
+import org.apache.directory.server.core.interceptor.context.MoveOperationContext;
+import org.apache.directory.server.core.interceptor.context.RenameOperationContext;
+import org.apache.directory.server.core.schema.PartitionSchemaLoader;
+import org.apache.directory.server.core.schema.SchemaPartitionDao;
+import org.apache.directory.shared.ldap.constants.MetaSchemaConstants;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.entry.EntryAttribute;
+import org.apache.directory.shared.ldap.entry.Modification;
+import org.apache.directory.shared.ldap.entry.ModificationOperation;
+import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.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.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;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Central point of control for schemas enforced by the server.  The 
+ * following duties are presently performed by this class:
+ * 
+ * <ul>
+ *   <li>Provide central point of access for all registries: global and SAA specific registries</li>
+ *   <li>Manage enabling and disabling schemas</li>
+ *   <li>Responding to specific schema object changes</li>
+ * </ul>
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DefaultRegistrySynchronizer implements RegistrySynchronizer
+{
+    private static final Logger LOG = LoggerFactory.getLogger( DefaultRegistrySynchronizer.class );
+
+    // indices of handlers and object ids into arrays
+    private static final int COMPARATOR_INDEX = 0;
+    private static final int NORMALIZER_INDEX = 1;
+    private static final int SYNTAX_CHECKER_INDEX = 2;
+    private static final int SYNTAX_INDEX = 3;
+    private static final int MATCHING_RULE_INDEX = 4;
+    private static final int ATTRIBUTE_TYPE_INDEX = 5;
+    private static final int OBJECT_CLASS_INDEX = 6;
+    private static final int MATCHING_RULE_USE_INDEX = 7;
+    private static final int DIT_STRUCTURE_RULE_INDEX = 8;
+    private static final int DIT_CONTENT_RULE_INDEX = 9;
+    private static final int NAME_FORM_INDEX = 10;
+
+    private static final Set<String> VALID_OU_VALUES = new HashSet<String>();
+    private static final String[] META_OBJECT_CLASSES = new String[] {
+        "metaComparator",
+        "metaNormalizer",
+        "metaSyntaxChecker",
+        "metaSyntax",
+        "metaMatchingRule",
+        "metaAttributeType",
+        "metaObjectClass",
+        "metaMatchingRuleUse",
+        "metaDITStructureRule",
+        "metaDITContentRule",
+        "metaNameForm"
+    };
+
+    private final Registries registries;
+    private final AttributeType objectClassAT;
+    private final RegistrySynchronizer[] registrySynchronizers = new RegistrySynchronizer[11];
+    private final Map<String, RegistrySynchronizer> objectClass2synchronizerMap = new HashMap<String, RegistrySynchronizer>();
+    private final SchemaSynchronizer schemaSynchronizer;
+
+    static 
+    {
+        VALID_OU_VALUES.add( SchemaConstants.NORMALIZERS_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.COMPARATORS_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.SYNTAX_CHECKERS_AT.toLowerCase() );
+        VALID_OU_VALUES.add( "syntaxes".toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.MATCHING_RULES_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.MATCHING_RULE_USE_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.ATTRIBUTE_TYPES_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.OBJECT_CLASSES_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.NAME_FORMS_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.DIT_CONTENT_RULES_AT.toLowerCase() );
+        VALID_OU_VALUES.add( SchemaConstants.DIT_STRUCTURE_RULES_AT.toLowerCase() );
+    }
+
+
+    public DefaultRegistrySynchronizer( Registries registries, PartitionSchemaLoader loader, SchemaPartitionDao dao )
+        throws Exception
+    {
+        this.registries = registries;
+        this.schemaSynchronizer = new SchemaSynchronizer( registries );
+        this.objectClassAT = this.registries.getAttributeTypeRegistry()
+            .lookup( SchemaConstants.OBJECT_CLASS_AT );
+        
+        this.registrySynchronizers[COMPARATOR_INDEX] = new ComparatorSynchronizer( registries ); 
+        this.registrySynchronizers[NORMALIZER_INDEX] = new NormalizerSynchronizer( registries );
+        this.registrySynchronizers[SYNTAX_CHECKER_INDEX] = new SyntaxCheckerSynchronizer( registries );
+        this.registrySynchronizers[SYNTAX_INDEX] = new SyntaxSynchronizer( registries );
+        this.registrySynchronizers[MATCHING_RULE_INDEX] = new MatchingRuleSynchronizer( registries );
+        this.registrySynchronizers[ATTRIBUTE_TYPE_INDEX] = new AttributeTypeSynchronizer( registries );
+        this.registrySynchronizers[OBJECT_CLASS_INDEX] = new ObjectClassSynchronizer( registries );
+        this.registrySynchronizers[MATCHING_RULE_USE_INDEX] = new MatchingRuleUseSynchronizer( registries );
+        this.registrySynchronizers[DIT_STRUCTURE_RULE_INDEX] = new DitStructureRuleSynchronizer( registries ); 
+        this.registrySynchronizers[DIT_CONTENT_RULE_INDEX] = new DitContentRuleSynchronizer( registries ); 
+        this.registrySynchronizers[NAME_FORM_INDEX] = new NameFormSynchronizer( registries ); 
+
+        ObjectClassRegistry ocReg = registries.getObjectClassRegistry();
+        for ( int ii = 0; ii < META_OBJECT_CLASSES.length; ii++ )
+        {
+            ObjectClass oc = ocReg.lookup( META_OBJECT_CLASSES[ii] );
+            objectClass2synchronizerMap.put( oc.getOid(), registrySynchronizers[ii] );
+        }
+    }
+
+    
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeManager#add(org.apache.directory.server.core.interceptor.context.AddOperationContext)
+     */
+    public void add( AddOperationContext opContext ) throws Exception
+    {
+        EntryAttribute oc = opContext.getEntry().get( objectClassAT );
+        
+        for ( Value<?> value:oc )
+        {
+
+            String oid = registries.getObjectClassRegistry().getOidByName( value.getString() );
+            
+            if ( objectClass2synchronizerMap.containsKey( oid ) )
+            {
+                RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
+                synchronizer.add( opContext.getDn(), opContext.getEntry() );
+                return;
+            }
+        }
+        
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
+        {
+            schemaSynchronizer.add( opContext.getDn(), opContext.getEntry() );
+            return;
+        }
+        
+        if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) )
+        {
+            if ( opContext.getDn().size() != 3 )
+            {
+                throw new LdapInvalidNameException( 
+                    "Schema entity containers of objectClass organizationalUnit should be 3 name components in length.", 
+                    ResultCodeEnum.NAMING_VIOLATION );
+            }
+            
+            String ouValue = ( String ) opContext.getDn().getRdn().getValue();
+            ouValue = ouValue.trim().toLowerCase();
+            if ( ! VALID_OU_VALUES.contains( ouValue ) )
+            {
+                throw new LdapInvalidNameException( 
+                    "Expecting organizationalUnit with one of the following names: " + VALID_OU_VALUES, 
+                    ResultCodeEnum.NAMING_VIOLATION );
+            }
+            return;
+        }
+
+        throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeManager#delete(org.apache.directory.server.core.interceptor.context.DeleteOperationContext, org.apache.directory.server.core.entry.ClonedServerEntry, boolean)
+     */
+    public void delete( DeleteOperationContext opContext, ClonedServerEntry entry, boolean doCascadeDelete ) 
+        throws Exception
+    {
+        EntryAttribute oc = entry.get( objectClassAT );
+        
+        for ( Value<?> value:oc )
+        {
+            String oid = registries.getObjectClassRegistry().getOidByName( value.getString() );
+            
+            if ( objectClass2synchronizerMap.containsKey( oid ) )
+            {
+                RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
+                synchronizer.delete( opContext.getDn(), entry, doCascadeDelete );
+                return;
+            }
+        }
+
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
+        {
+            schemaSynchronizer.delete( opContext.getDn(), entry, doCascadeDelete );
+            return;
+        }
+        
+        if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) )
+        {
+            if ( opContext.getDn().size() != 3 )
+            {
+                throw new LdapNamingException( 
+                    "Only schema entity containers of objectClass organizationalUnit with 3 name components in length" +
+                    " can be deleted.", ResultCodeEnum.UNWILLING_TO_PERFORM );
+            }
+            
+            String ouValue = ( String ) opContext.getDn().getRdn().getValue();
+            ouValue = ouValue.trim().toLowerCase();
+            if ( ! VALID_OU_VALUES.contains( ouValue ) )
+            {
+                throw new LdapInvalidNameException( 
+                    "Can only delete organizationalUnit entity containers with one of the following names: " 
+                    + VALID_OU_VALUES, ResultCodeEnum.NAMING_VIOLATION );
+            }
+            return;
+        }
+
+        throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeManager#modify(org.apache.directory.server.core.interceptor.context.ModifyOperationContext, org.apache.directory.shared.ldap.entry.ModificationOperation, org.apache.directory.server.core.entry.ServerEntry, org.apache.directory.server.core.entry.ServerEntry, org.apache.directory.server.core.entry.ServerEntry, boolean)
+     */
+    public void modify( ModifyOperationContext opContext, ModificationOperation modOp, ServerEntry mods, 
+        ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+    {
+        EntryAttribute oc = entry.get( objectClassAT );
+        
+        for ( Value<?> value:oc )
+        {
+            String oid = registries.getObjectClassRegistry().getOidByName( value.getString() );
+            
+            if ( objectClass2synchronizerMap.containsKey( oid ) )
+            {
+                RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
+                synchronizer.modify( opContext.getDn(), modOp, mods, entry, targetEntry, cascade );
+                return;
+            }
+        }
+
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
+        {
+            schemaSynchronizer.modify( opContext.getDn(), modOp, mods, entry, targetEntry, cascade );
+            return;
+        }
+        
+        throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeManager#modify(org.apache.directory.server.core.interceptor.context.ModifyOperationContext, org.apache.directory.server.core.entry.ServerEntry, org.apache.directory.server.core.entry.ServerEntry, boolean)
+     */
+    public void modify( ModifyOperationContext opContext, ServerEntry entry, 
+        ServerEntry targetEntry, boolean doCascadeModify ) throws Exception
+    {
+        EntryAttribute oc = entry.get( objectClassAT );
+        
+        for ( Value<?> value:oc )
+        {
+            String oid = registries.getObjectClassRegistry().getOidByName( value.getString() );
+            
+            if ( objectClass2synchronizerMap.containsKey( oid ) )
+            {
+                RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
+                synchronizer.modify( opContext.getDn(), opContext.getModItems(), entry, targetEntry, doCascadeModify );
+                return;
+            }
+        }
+
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
+        {
+            schemaSynchronizer.modify( opContext.getDn(), opContext.getModItems(), entry, targetEntry, doCascadeModify );
+            return;
+        }
+
+        LOG.error( String.format( "Unwilling to perform modify on %s:\n\nEntry:\n%s\n\nModifications:\n%s", 
+            opContext.getDn(), entry, opContext.getModItems() ) );
+        throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeManager#modifyRn(org.apache.directory.server.core.interceptor.context.RenameOperationContext, org.apache.directory.server.core.entry.ServerEntry, boolean)
+     */
+    public void modifyRn( RenameOperationContext opContext, ServerEntry entry, boolean doCascadeModify ) 
+        throws Exception
+    {
+        EntryAttribute oc = entry.get( objectClassAT );
+        
+        for ( Value<?> value:oc )
+        {
+            String oid = registries.getObjectClassRegistry().getOidByName( value.getString() );
+            
+            if ( objectClass2synchronizerMap.containsKey( oid ) )
+            {
+                RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
+                synchronizer.rename( opContext.getDn(), entry, opContext.getNewRdn(), doCascadeModify );
+                return;
+            }
+        }
+
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
+        {
+            schemaSynchronizer.rename( opContext.getDn(), entry, opContext.getNewRdn(), doCascadeModify );
+            return;
+        }
+        
+        throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeManager#replace(org.apache.directory.server.core.interceptor.context.MoveOperationContext, org.apache.directory.server.core.entry.ServerEntry, boolean)
+     */
+    public void replace( MoveOperationContext opContext, ServerEntry entry, boolean cascade ) throws Exception
+    {
+        EntryAttribute oc = entry.get( objectClassAT );
+        
+        for ( Value<?> value:oc )
+        {
+            String oid = registries.getObjectClassRegistry().getOidByName( value.getString() );
+            
+            if ( objectClass2synchronizerMap.containsKey( oid ) )
+            {
+                RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
+                synchronizer.replace( opContext.getDn(), opContext.getParent(), entry, cascade );
+                return;
+            }
+        }
+
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
+        {
+            schemaSynchronizer.replace( opContext.getDn(), opContext.getParent(), entry, cascade );
+            return;
+        }
+        
+        throw new LdapOperationNotSupportedException( ResultCodeEnum.UNWILLING_TO_PERFORM );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeManager#move(org.apache.directory.server.core.interceptor.context.MoveAndRenameOperationContext, org.apache.directory.server.core.entry.ServerEntry, boolean)
+     */
+    public void move( MoveAndRenameOperationContext opContext, ServerEntry entry, boolean cascade ) throws Exception
+    {
+        EntryAttribute oc = entry.get( objectClassAT );
+        
+        for ( Value<?> value:oc )
+        {
+            String oid = registries.getObjectClassRegistry().getOidByName( value.getString() );
+            
+            if ( objectClass2synchronizerMap.containsKey( oid ) )
+            {
+                RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid );
+                synchronizer.move( opContext.getDn(), opContext.getParent(), opContext.getNewRdn(), 
+                    opContext.getDelOldDn(), entry, cascade );
+                return;
+            }
+        }
+
+        if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) )
+        {
+            schemaSynchronizer.move( opContext.getDn(), opContext.getParent(), opContext.getNewRdn(), 
+                opContext.getDelOldDn(), entry, cascade );
+            return;
+        }
+        
+        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;
+    }
+
+
+    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( LdapDN name, ServerEntry entry, boolean cascaded ) throws Exception
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public boolean modify( LdapDN name, ModificationOperation modOp, ServerEntry mods, ServerEntry entry,
+        ServerEntry targetEntry, boolean cascaded ) throws Exception
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    public boolean modify( LdapDN name, List<Modification> mods, ServerEntry entry, ServerEntry targetEntry,
+        boolean cascaded ) throws Exception
+    {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn, ServerEntry entry,
+        boolean cascaded ) throws Exception
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascaded ) throws Exception
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, boolean cascaded )
+        throws Exception
+    {
+        // TODO Auto-generated method stub
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitContentRuleSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,117 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.DITContentRule;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
+import javax.naming.NamingException;
+
+
+/**
+ * A schema entity change handler for DitContentRules.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DitContentRuleSynchronizer extends AbstractRegistrySynchronizer
+{
+
+    protected DitContentRuleSynchronizer( Registries registries ) throws Exception
+    {
+        super( registries );
+        // TODO Auto-generated constructor stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.AbstractSchemaChangeHandler#modify(org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes, javax.naming.directory.Attributes)
+     */
+    @Override
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) 
+        throws NamingException
+    {
+        // TODO Auto-generated method stub
+        return SCHEMA_UNCHANGED;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#add(org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#delete(org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#move(org.apache.directory.shared.ldap.name.LdapDN, org.apache.directory.shared.ldap.name.LdapDN, java.lang.String, boolean, javax.naming.directory.Attributes)
+     */
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
+        ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#move(org.apache.directory.shared.ldap.name.LdapDN, org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, 
+        boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#rename(org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes, java.lang.String)
+     */
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void add( DITContentRule dcr )
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( DITContentRule dcr, boolean cascade )
+    {
+        // TODO Auto-generated method stub
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/DitStructureRuleSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,128 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.DITStructureRule;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
+import javax.naming.NamingException;
+
+
+/**
+ * A schema entity change handler for DitStructureRules.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class DitStructureRuleSynchronizer extends AbstractRegistrySynchronizer
+{
+
+    protected DitStructureRuleSynchronizer( Registries registries ) throws Exception
+    {
+        super( registries );
+        // TODO Auto-generated constructor stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.AbstractSchemaChangeHandler#modify(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes, 
+     * javax.naming.directory.Attributes)
+     */
+    @Override
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, 
+        boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+        return SCHEMA_UNCHANGED;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#add(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#delete(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#move(
+     * org.apache.directory.shared.ldap.name.LdapDN, 
+     * org.apache.directory.shared.ldap.name.LdapDN, 
+     * java.lang.String, boolean, javax.naming.directory.Attributes)
+     */
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
+        ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#move(
+     * org.apache.directory.shared.ldap.name.LdapDN, 
+     * org.apache.directory.shared.ldap.name.LdapDN, 
+     * javax.naming.directory.Attributes)
+     */
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, 
+        boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#rename(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes, java.lang.String)
+     */
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void add( DITStructureRule dsr )
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( DITStructureRule dsr, boolean cascade )
+    {
+        // TODO Auto-generated method stub
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,209 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.entry.ServerEntry;
+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.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.MatchingRule;
+import org.apache.directory.shared.ldap.schema.registries.MatchingRuleRegistry;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
+
+/**
+ * A handler for operations performed to add, delete, modify, rename and 
+ * move schema normalizers.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class MatchingRuleSynchronizer extends AbstractRegistrySynchronizer
+{
+    private final MatchingRuleRegistry matchingRuleRegistry;
+
+    
+    public MatchingRuleSynchronizer( Registries registries ) 
+        throws Exception
+    {
+        super( registries );
+        this.matchingRuleRegistry = registries.getMatchingRuleRegistry();
+    }
+
+
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, 
+        boolean cascade ) throws Exception
+    {
+        String oid = getOid( entry );
+        String schemaName = getSchemaName( name );
+        MatchingRule mr = factory.getMatchingRule( targetEntry, registries, schemaName );
+        
+        if ( registries.isSchemaLoaded( schemaName ) )
+        {
+            matchingRuleRegistry.unregister( oid );
+            matchingRuleRegistry.register( mr );
+            
+            return SCHEMA_MODIFIED;
+        }
+        
+        return SCHEMA_UNCHANGED;
+    }
+
+
+    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 );
+        MatchingRule mr = factory.getMatchingRule( entry, registries, schemaName );
+        
+        if ( registries.isSchemaLoaded( schemaName ) )
+        {
+            matchingRuleRegistry.register( mr );
+        }
+        else
+        {
+            registerOids( mr );
+        }
+    }
+
+
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws Exception
+    {
+        String schemaName = getSchemaName( name );
+        MatchingRule mr = factory.getMatchingRule( entry, registries, schemaName );
+        if ( registries.isSchemaLoaded( schemaName ) )
+        {
+            matchingRuleRegistry.unregister( mr.getOid() );
+        }
+        unregisterOids( mr.getOid() );
+    }
+
+    
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws Exception
+    {
+        String schemaName = getSchemaName( name );
+        MatchingRule oldMr = factory.getMatchingRule( entry, registries, schemaName );
+        ServerEntry targetEntry = ( ServerEntry ) entry.clone();
+        String newOid = ( String ) newRdn.getValue();
+        checkOidIsUnique( newOid );
+        
+        targetEntry.put( MetaSchemaConstants.M_OID_AT, newOid );
+        MatchingRule mr = factory.getMatchingRule( targetEntry, registries, schemaName );
+
+        if ( registries.isSchemaLoaded( schemaName ) )
+        {
+            matchingRuleRegistry.unregister( oldMr.getOid() );
+            matchingRuleRegistry.register( mr );
+        }
+        else
+        {
+            registerOids( mr );
+        }
+
+        unregisterOids( oldMr.getOid() );
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRdn, boolean deleteOldRn, 
+        ServerEntry entry, boolean cascade ) throws Exception
+    {
+        checkNewParent( newParentName );
+        String oldSchemaName = getSchemaName( oriChildName );
+        String newSchemaName = getSchemaName( newParentName );
+        MatchingRule oldMr = factory.getMatchingRule( entry, registries, oldSchemaName );
+        ServerEntry targetEntry = ( ServerEntry ) entry.clone();
+        String newOid = ( String ) newRdn.getValue();
+        checkOidIsUnique( newOid );
+        
+        targetEntry.put( MetaSchemaConstants.M_OID_AT, newOid );
+        MatchingRule mr = factory.getMatchingRule( targetEntry, registries, newSchemaName );
+
+        if ( registries.isSchemaLoaded( oldSchemaName ) )
+        {
+            matchingRuleRegistry.unregister( oldMr.getOid() );
+        }
+        unregisterOids( oldMr.getOid() );
+
+        if ( registries.isSchemaLoaded( newSchemaName ) )
+        {
+            matchingRuleRegistry.register( mr );
+        }
+        else
+        {
+            registerOids( mr );
+        }
+    }
+
+
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, boolean cascade ) 
+        throws Exception
+    {
+        checkNewParent( newParentName );
+        String oldSchemaName = getSchemaName( oriChildName );
+        String newSchemaName = getSchemaName( newParentName );
+        MatchingRule oldMr = factory.getMatchingRule( entry, registries, oldSchemaName );
+        MatchingRule mr = factory.getMatchingRule( entry, registries, newSchemaName );
+        
+        if ( registries.isSchemaLoaded( oldSchemaName ) )
+        {
+            matchingRuleRegistry.unregister( oldMr.getOid() );
+        }
+        
+        if ( registries.isSchemaLoaded( newSchemaName ) )
+        {
+            matchingRuleRegistry.register( mr );
+        }
+    }
+    
+    
+    private void checkNewParent( LdapDN newParent ) throws NamingException
+    {
+        if ( newParent.size() != 3 )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent dn of a matchingRule should be at most 3 name components in length.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        Rdn rdn = newParent.getRdn();
+        if ( ! registries.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) )
+        {
+            throw new LdapInvalidNameException( "The parent entry of a matchingRule should be an organizationalUnit.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( SchemaConstants.MATCHING_RULES_AT ) )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent entry of a syntax should have a relative name of ou=matchingRules.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/MatchingRuleUseSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,99 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
+import javax.naming.NamingException;
+
+
+/**
+ * A schema entity change handler for DitMatchingRuleUses.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MatchingRuleUseSynchronizer extends AbstractRegistrySynchronizer
+{
+
+    protected MatchingRuleUseSynchronizer( Registries registries ) throws Exception
+    {
+        super( registries );
+        // TODO Auto-generated constructor stub
+    }
+
+
+    @Override
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, 
+        boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+        return SCHEMA_UNCHANGED;
+    }
+
+
+    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn, boolean deleteOldRn,
+        ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void replace( LdapDN oriChildName, LdapDN newParentName,
+        ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void add( MatchingRuleUse mru ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( MatchingRuleUse mru, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NameFormSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,123 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.NameForm;
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+
+
+/**
+ * A schema entity change handler for NameForms.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class NameFormSynchronizer extends AbstractRegistrySynchronizer
+{
+    protected NameFormSynchronizer( Registries registries ) throws Exception
+    {
+        super( registries );
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.AbstractSchemaChangeHandler#modify(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes, 
+     * javax.naming.directory.Attributes)
+     */
+    @Override
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, 
+        boolean cascade ) throws NamingException
+    {
+        return SCHEMA_UNCHANGED;
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#add(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void add( LdapDN name, ServerEntry entry ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#delete(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#move(
+     * org.apache.directory.shared.ldap.name.LdapDN, org.apache.directory.shared.ldap.name.LdapDN, 
+     * Rdn, boolean, javax.naming.directory.Attributes)
+     */
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRn,
+        boolean deleteOldRn, ServerEntry entry, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#move(
+     * org.apache.directory.shared.ldap.name.LdapDN, 
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes)
+     */
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, 
+        boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    /* (non-Javadoc)
+     * @see org.apache.directory.server.core.schema.SchemaChangeHandler#rename(
+     * org.apache.directory.shared.ldap.name.LdapDN, javax.naming.directory.Attributes, Rdn, boolean)
+     */
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws NamingException
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void add( NameForm nf )
+    {
+        // TODO Auto-generated method stub
+    }
+
+
+    public void delete( NameForm nf, boolean cascade )
+    {
+        // TODO Auto-generated method stub
+    }
+}

Added: 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=811964&view=auto
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java (added)
+++ directory/apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/synchronizers/NormalizerSynchronizer.java Mon Sep  7 01:29:38 2009
@@ -0,0 +1,243 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you under the Apache License, Version 2.0 (the
+ *   "License"); you may not use this file except in compliance
+ *   with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing,
+ *   software distributed under the License is distributed on an
+ *   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *   KIND, either express or implied.  See the License for the
+ *   specific language governing permissions and limitations
+ *   under the License.
+ *
+ */
+package org.apache.directory.server.core.schema.registries.synchronizers;
+
+
+import javax.naming.NamingException;
+
+import org.apache.directory.server.core.entry.ServerEntry;
+import org.apache.directory.shared.ldap.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+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.Normalizer;
+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;
+
+
+/**
+ *
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class NormalizerSynchronizer extends AbstractRegistrySynchronizer
+{
+    private final NormalizerRegistry normalizerRegistry;
+    private final MatchingRuleRegistry matchingRuleRegistry;
+    
+
+    public NormalizerSynchronizer( Registries registries ) throws Exception
+    {
+        super( registries );
+        this.normalizerRegistry = registries.getNormalizerRegistry();
+        this.matchingRuleRegistry = registries.getMatchingRuleRegistry();
+    }
+    
+    
+    protected boolean modify( LdapDN name, ServerEntry entry, ServerEntry targetEntry, boolean cascade ) throws Exception
+    {
+        String oid = getOid( entry );
+        Normalizer normalizer = factory.getNormalizer( targetEntry, registries );
+        
+        if ( isSchemaLoaded( name ) )
+        {
+            normalizerRegistry.unregister( oid );
+            normalizerRegistry.register( normalizer );
+            
+            return SCHEMA_MODIFIED;
+        }
+        
+        return SCHEMA_UNCHANGED;
+    }
+
+
+    public void add( LdapDN name, ServerEntry entry ) throws Exception
+    {
+        LdapDN parentDn = ( LdapDN ) name.clone();
+        parentDn.remove( parentDn.size() - 1 );
+        checkNewParent( parentDn );
+        checkOidIsUniqueForNormalizer( entry );
+        
+        Normalizer normalizer = factory.getNormalizer( entry, registries );
+        
+        if ( isSchemaLoaded( name ) )
+        {
+            normalizerRegistry.register( normalizer );
+        }
+    }
+
+
+    public void delete( LdapDN name, ServerEntry entry, boolean cascade ) throws Exception
+    {
+        delete( getOid( entry ), cascade );
+    }
+
+
+    public void delete( String oid, boolean cascade ) throws NamingException
+    {
+        if ( matchingRuleRegistry.contains( oid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The normalizer with OID " + oid 
+                + " cannot be deleted until all " 
+                + "matchingRules using that normalizer have also been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        if ( normalizerRegistry.contains( oid ) )
+        {
+            normalizerRegistry.unregister( oid );
+        }
+    }
+    
+
+    public void rename( LdapDN name, ServerEntry entry, Rdn newRdn, boolean cascade ) throws Exception
+    {
+        String oldOid = getOid( entry );
+
+        if ( matchingRuleRegistry.contains( oldOid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The normalizer with OID " + oldOid 
+                + " cannot have it's OID changed until all " 
+                + "matchingRules using that normalizer have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        String oid = ( String ) newRdn.getValue();
+        checkOidIsUniqueForNormalizer( oid );
+        
+        if ( isSchemaLoaded( name ) )
+        {
+            Normalizer normalizer = factory.getNormalizer( entry, registries );
+            normalizerRegistry.unregister( oldOid );
+            normalizerRegistry.register( normalizer );
+        }
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Rdn newRdn, boolean deleteOldRn,
+        ServerEntry entry, boolean cascade ) throws Exception
+    {
+        checkNewParent( newParentName );
+        String oldOid = getOid( entry );
+
+        if ( matchingRuleRegistry.contains( oldOid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The normalizer with OID " + oldOid 
+                + " cannot have it's OID changed until all " 
+                + "matchingRules using that normalizer have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        String oid = ( String ) newRdn.getValue();
+        checkOidIsUniqueForNormalizer( oid );
+        Normalizer normalizer = factory.getNormalizer( entry, registries );
+
+        if ( isSchemaLoaded( oriChildName ) )
+        {
+            normalizerRegistry.unregister( oldOid );
+        }
+
+        if ( isSchemaLoaded( newParentName ) )
+        {
+            normalizerRegistry.register( normalizer );
+        }
+    }
+
+
+    public void replace( LdapDN oriChildName, LdapDN newParentName, ServerEntry entry, boolean cascade ) 
+        throws Exception
+    {
+        checkNewParent( newParentName );
+        String oid = getOid( entry );
+
+        if ( matchingRuleRegistry.contains( oid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The normalizer with OID " + oid 
+                + " cannot be moved to another schema until all " 
+                + "matchingRules using that normalizer have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        Normalizer normalizer = factory.getNormalizer( entry, registries );
+        
+        if ( isSchemaLoaded( oriChildName ) )
+        {
+            normalizerRegistry.unregister( oid );
+        }
+        
+        if ( isSchemaLoaded( newParentName ) )
+        {
+            normalizerRegistry.register( normalizer );
+        }
+    }
+
+    
+    private void checkOidIsUniqueForNormalizer( String oid ) throws NamingException
+    {
+        if ( registries.getNormalizerRegistry().contains( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema normalizer is not unique.", 
+                ResultCodeEnum.OTHER );
+        }
+    }
+
+
+    private void checkOidIsUniqueForNormalizer( ServerEntry entry ) throws Exception
+    {
+        String oid = getOid( entry );
+        
+        if ( registries.getNormalizerRegistry().contains( oid ) )
+        {
+            throw new LdapNamingException( "Oid " + oid + " for new schema normalizer is not unique.", 
+                ResultCodeEnum.OTHER );
+        }
+    }
+
+
+    private void checkNewParent( LdapDN newParent ) throws NamingException
+    {
+        if ( newParent.size() != 3 )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent dn of a normalizer should be at most 3 name components in length.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        Rdn rdn = newParent.getRdn();
+
+        if ( ! registries.getAttributeTypeRegistry().getOidByName( rdn.getNormType() ).equals( SchemaConstants.OU_AT_OID ) )
+        {
+            throw new LdapInvalidNameException( "The parent entry of a normalizer should be an organizationalUnit.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( SchemaConstants.NORMALIZERS_AT ) )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent entry of a normalizer should have a relative name of ou=normalizers.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+    }
+}



Mime
View raw message