directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r887926 [2/4] - in /directory: apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/ apacheds/branches/apacheds-schema/core-api/src/main/java/org/apache/directory/server/core/schema/registries/syn...
Date Mon, 07 Dec 2009 14:06:57 GMT
Added: directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java?rev=887926&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java (added)
+++ directory/shared/branches/shared-schema/ldap-schema-loader/src/test/java/org/apache/directory/server/schema/SchemaManagerDelTest.java Mon Dec  7 14:06:56 2009
@@ -0,0 +1,649 @@
+/*
+ *  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.schema;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.naming.directory.NoSuchAttributeException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.shared.ldap.exception.LdapSchemaViolationException;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+import org.apache.directory.shared.ldap.schema.UsageEnum;
+import org.apache.directory.shared.ldap.schema.ldif.extractor.SchemaLdifExtractor;
+import org.apache.directory.shared.schema.DefaultSchemaManager;
+import org.apache.directory.shared.schema.loader.ldif.LdifSchemaLoader;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * A test class for SchemaManager, testing the deletion of a SchemaObject.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class SchemaManagerDelTest
+{
+    // A directory in which the ldif files will be stored
+    private static String workingDirectory;
+
+    // The schema repository
+    private static File schemaRepository;
+
+
+    @BeforeClass
+    public static void setup() throws Exception
+    {
+        workingDirectory = System.getProperty( "workingDirectory" );
+
+        if ( workingDirectory == null )
+        {
+            String path = SchemaManagerDelTest.class.getResource( "" ).getPath();
+            int targetPos = path.indexOf( "target" );
+            workingDirectory = path.substring( 0, targetPos + 6 );
+        }
+
+        schemaRepository = new File( workingDirectory, "schema" );
+
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( schemaRepository );
+
+        SchemaLdifExtractor extractor = new SchemaLdifExtractor( new File( workingDirectory ) );
+        extractor.extractOrCopy();
+    }
+
+
+    @AfterClass
+    public static void cleanup() throws IOException
+    {
+        // Cleanup the target directory
+        FileUtils.deleteDirectory( schemaRepository );
+    }
+
+
+    private SchemaManager loadSystem() throws Exception
+    {
+        LdifSchemaLoader loader = new LdifSchemaLoader( schemaRepository );
+        SchemaManager schemaManager = new DefaultSchemaManager( loader );
+
+        String schemaName = "system";
+
+        schemaManager.loadWithDeps( schemaName );
+
+        return schemaManager;
+    }
+
+
+    private boolean isATPresent( SchemaManager schemaManager, String oid )
+    {
+        try
+        {
+            AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( oid );
+
+            return attributeType != null;
+        }
+        catch ( NoSuchAttributeException nsae )
+        {
+            return false;
+        }
+        catch ( NamingException ne )
+        {
+            return false;
+        }
+    }
+
+
+    //=========================================================================
+    // For each test, we will check many different things.
+    // If the test is successful, we want to know if the SchemaObject
+    // Registry has shrunk : its size must be one lower. If the SchemaObject
+    // is not loadable, then the GlobalOidRegistry must also have grown.
+    //=========================================================================
+    // AttributeType deletion tests
+    //-------------------------------------------------------------------------
+    // First, not defined descendant
+    //-------------------------------------------------------------------------
+    /**
+     * Try to delete an AttributeType not existing in the schemaManager
+     */
+    @Test
+    public void testDelNonExistentAttributeType() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+
+        // It should not fail
+        assertFalse( schemaManager.delete( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertFalse( errors.isEmpty() );
+
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Delete an existing AT not referecend by any object
+     */
+    @Test
+    public void testDelExistingAttributeTypeNoReference() throws Exception
+    {
+        // First inject such an AT
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+
+        // It should not fail
+        assertTrue( schemaManager.add( attributeType ) );
+
+        assertTrue( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+
+        // Now delete it
+        // It should not fail
+        assertTrue( schemaManager.delete( attributeType ) );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType which is Collective, and userApplication AT
+     */
+    @Test
+    public void testAddAttributeTypeNoSupCollectiveUser() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+        attributeType.setCollective( true );
+
+        // It should not fail
+        assertTrue( schemaManager.add( attributeType ) );
+
+        assertTrue( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType which is Collective, but an operational AT
+     */
+    @Test
+    public void testAddAttributeTypeNoSupCollectiveOperational() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );
+        attributeType.setCollective( true );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType which is a NO-USER-MODIFICATION and userApplication
+     */
+    @Test
+    public void testAddAttributeTypeNoSupNoUserModificationUserAplication() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+        attributeType.setUserModifiable( false );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType which is a NO-USER-MODIFICATION and is operational
+     */
+    @Test
+    public void testAddAttributeTypeNoSupNoUserModificationOpAttr() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
+        attributeType.setUserModifiable( false );
+
+        // It should not fail
+        assertTrue( schemaManager.add( attributeType ) );
+
+        assertTrue( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType with an invalid EQUALITY MR
+     */
+    @Test
+    public void testAddAttributeTypeNoSupInvalidEqualityMR() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "0.0" );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType with an invalid ORDERING MR
+     */
+    @Test
+    public void testAddAttributeTypeNoSupInvalidOrderingMR() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( null );
+        attributeType.setOrderingOid( "0.0" );
+        attributeType.setSubstringOid( null );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType with an invalid SUBSTR MR
+     */
+    @Test
+    public void testAddAttributeTypeNoSupInvalidSubstringMR() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( null );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( "0.0" );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType with valid MRs
+     */
+    @Test
+    public void testAddAttributeTypeNoSupValidMR() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( "2.5.13.1" );
+        attributeType.setSubstringOid( "2.5.13.1" );
+        attributeType.setSyntaxOid( "1.3.6.1.4.1.1466.115.121.1.26" );
+        attributeType.setUsage( UsageEnum.USER_APPLICATIONS );
+
+        // It should not fail
+        assertTrue( schemaManager.add( attributeType ) );
+
+        assertTrue( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType which already exist
+     */
+    @Test
+    public void testAddAttributeTypeAlreadyExist() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "2.5.18.4" );
+        attributeType.setEqualityOid( "2.5.13.1" );
+        attributeType.setOrderingOid( "2.5.13.1" );
+        attributeType.setSubstringOid( "2.5.13.1" );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        // The AT must be there
+        assertTrue( isATPresent( schemaManager, "2.5.18.4" ) );
+
+        // Check that it hasen't changed
+        AttributeType original = schemaManager.lookupAttributeTypeRegistry( "2.5.18.4" );
+        assertEquals( "distinguishedNameMatch", original.getEqualityOid() );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    //-------------------------------------------------------------------------
+    // Then, with a superior
+    //-------------------------------------------------------------------------
+    /**
+     * Try to inject an AttributeType with a superior and no Syntax : it should
+     * take its superior' syntax and MR
+     */
+    @Test
+    public void testAddAttributeTypeSupNoSyntaxNoSuperior() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( null );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSuperiorOid( "2.5.18.4" );
+        attributeType.setUsage( UsageEnum.DIRECTORY_OPERATION );
+
+        // It should not fail
+        assertTrue( schemaManager.add( attributeType ) );
+
+        AttributeType result = schemaManager.lookupAttributeTypeRegistry( "1.1.0" );
+
+        assertEquals( "1.3.6.1.4.1.1466.115.121.1.12", result.getSyntaxOid() );
+        assertEquals( "2.5.13.1", result.getEqualityOid() );
+        assertEquals( atrSize + 1, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize + 1, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType with a superior and different USAGE
+     */
+    @Test
+    public void testAddAttributeTypeSupDifferentUsage() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( null );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSuperiorOid( "2.5.18.4" );
+        attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType with itself as a superior
+     */
+    @Test
+    public void testAddAttributeTypeSupWithOwnSup() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( null );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSuperiorOid( "1.1.0" );
+        attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+
+    /**
+     * Try to inject an AttributeType with a bad superior
+     */
+    @Test
+    public void testAddAttributeTypeSupBadSup() throws Exception
+    {
+        SchemaManager schemaManager = loadSystem();
+        int atrSize = schemaManager.getAttributeTypeRegistry().size();
+        int goidSize = schemaManager.getOidRegistry().size();
+
+        AttributeType attributeType = new AttributeType( "1.1.0" );
+        attributeType.setEqualityOid( null );
+        attributeType.setOrderingOid( null );
+        attributeType.setSubstringOid( null );
+        attributeType.setSuperiorOid( "0.0" );
+        attributeType.setUsage( UsageEnum.DISTRIBUTED_OPERATION );
+
+        // It should fail
+        assertFalse( schemaManager.add( attributeType ) );
+
+        List<Throwable> errors = schemaManager.getErrors();
+        assertEquals( 1, errors.size() );
+        Throwable error = errors.get( 0 );
+
+        assertTrue( error instanceof LdapSchemaViolationException );
+
+        assertFalse( isATPresent( schemaManager, "1.1.0" ) );
+        assertEquals( atrSize, schemaManager.getAttributeTypeRegistry().size() );
+        assertEquals( goidSize, schemaManager.getOidRegistry().size() );
+    }
+
+    //=========================================================================
+    // Comparator addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // DITContentRule addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // DITStructureRule addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // MatchingRule addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // MatchingRuleUse addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // NameForm addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // Normalizer addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // ObjectClass addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // Syntax addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+    //=========================================================================
+    // SyntaxChecker addition tests
+    //-------------------------------------------------------------------------
+    // TODO
+
+}

Added: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java?rev=887926&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AbstractSchemaObject.java Mon Dec  7 14:06:56 2009
@@ -0,0 +1,857 @@
+/*
+ *  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.shared.ldap.schema;
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.schema.registries.Registries;
+import org.apache.directory.shared.ldap.util.StringTools;
+
+
+/**
+ * Most schema objects have some common attributes. This class
+ * contains the minimum set of properties exposed by a SchemaObject.<br> 
+ * We have 11 types of SchemaObjects :
+ * <li> AttributeType
+ * <li> DitCOntentRule
+ * <li> DitStructureRule
+ * <li> LdapComparator (specific to ADS)
+ * <li> LdapSyntaxe
+ * <li> MatchingRule
+ * <li> MatchingRuleUse
+ * <li> NameForm
+ * <li> Normalizer (specific to ADS)
+ * <li> ObjectClass
+ * <li> SyntaxChecker (specific to ADS)
+ * <br>
+ * <br>
+ * This class provides accessors and setters for the following attributes, 
+ * which are common to all those SchemaObjects :
+ * <li>oid : The numeric OID 
+ * <li>description : The SchemaObject description
+ * <li>obsolete : Tells if the schema object is obsolete
+ * <li>extensions : The extensions, a key/Values map
+ * <li>schemaObjectType : The SchemaObject type (see upper)
+ * <li>schema : The schema the SchemaObject is associated with (it's an extension).
+ * Can be null
+ * <li>isEnabled : The SchemaObject status (it's related to the schema status)
+ * <li>isReadOnly : Tells if the SchemaObject can be modified or not
+ * <br><br>
+ * Some of those attributes are not used by some Schema elements, even if they should
+ * have been used. Here is the list :
+ * <b>name</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
+ * <b>numericOid</b> : DitStructureRule, 
+ * <b>obsolete</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 885381 $
+ */
+public abstract class AbstractSchemaObject implements SchemaObject
+{
+    /** The serialVersionUID */
+    public static final long serialVersionUID = 1L;
+
+    /** The SchemaObject numeric OID */
+    protected String oid;
+
+    /** The optional names for this SchemaObject */
+    protected List<String> names;
+
+    /** Whether or not this SchemaObject is enabled */
+    protected boolean isEnabled = true;
+
+    /** Whether or not this SchemaObject can be modified */
+    protected boolean isReadOnly = false;
+
+    /** Whether or not this SchemaObject is obsolete */
+    protected boolean isObsolete = false;
+
+    /** A short description of this SchemaObject */
+    protected String description;
+
+    /** The SchemaObject specification */
+    protected String specification;
+
+    /** The name of the schema this object is associated with */
+    protected String schemaName;
+
+    /** The SchemaObjectType */
+    protected SchemaObjectType objectType;
+
+    /** A map containing the list of supported extensions */
+    protected Map<String, List<String>> extensions;
+
+
+    /**
+     * A constructor for a SchemaObject instance. It must be 
+     * invoked by the inherited class.
+     * 
+     * @param objectType The SchemaObjectType to create
+     */
+    protected AbstractSchemaObject( SchemaObjectType objectType, String oid )
+    {
+        this.objectType = objectType;
+        this.oid = oid;
+        extensions = new HashMap<String, List<String>>();
+        names = new ArrayList<String>();
+    }
+
+
+    /**
+     * Constructor used when a generic reusable SchemaObject is assigned an
+     * OID after being instantiated.
+     * 
+     * @param objectType The SchemaObjectType to create
+     */
+    protected AbstractSchemaObject( SchemaObjectType objectType )
+    {
+        this.objectType = objectType;
+        extensions = new HashMap<String, List<String>>();
+        names = new ArrayList<String>();
+    }
+
+
+    /**
+     * Gets usually what is the numeric object identifier assigned to this
+     * SchemaObject. All schema objects except for MatchingRuleUses have an OID
+     * assigned specifically to then. A MatchingRuleUse's OID really is the OID
+     * of it's MatchingRule and not specific to the MatchingRuleUse. This
+     * effects how MatchingRuleUse objects are maintained by the system.
+     * 
+     * @return an OID for this SchemaObject or its MatchingRule if this
+     *         SchemaObject is a MatchingRuleUse object
+     */
+    public String getOid()
+    {
+        return oid;
+    }
+
+
+    /**
+     * A special method used when renaming an SchemaObject: we may have to
+     * change it's OID
+     * @param oid The new OID
+     */
+    public void setOid( String oid )
+    {
+        this.oid = oid;
+    }
+
+
+    /**
+     * Gets short names for this SchemaObject if any exists for it, otherwise,
+     * returns an empty list.
+     * 
+     * @return the names for this SchemaObject
+     */
+    public List<String> getNames()
+    {
+        if ( names != null )
+        {
+            return Collections.unmodifiableList( names );
+        }
+        else
+        {
+            return Collections.emptyList();
+        }
+    }
+
+
+    /**
+     * Gets the first name in the set of short names for this SchemaObject if
+     * any exists for it.
+     * 
+     * @return the first of the names for this SchemaObject or the oid
+     * if one does not exist
+     */
+    public String getName()
+    {
+        if ( ( names != null ) && ( names.size() != 0 ) )
+        {
+            return names.get( 0 );
+        }
+        else
+        {
+            return oid;
+        }
+    }
+
+
+    /**
+     * Inject this SchemaObject to the given registries, updating the references to
+     * other SchemaObject
+     *
+     * @param errors The errors we got
+     * @param registries The Registries
+     */
+    public void addToRegistries( List<Throwable> errors, Registries registries ) throws NamingException
+    {
+        // do nothing
+    }
+
+
+    /**
+     * Remove this SchemaObject from the given registries, updating the references to
+     * other SchemaObject
+     *
+     * @param errors The errors we got
+     * @param registries The Registries
+     */
+    public void removeFromRegistries( List<Throwable> errors, Registries registries ) throws NamingException
+    {
+        // do nothing
+    }
+
+
+    /**
+     * Inject the Registries into the SchemaObject
+     *
+     * @param registries The Registries
+     */
+    public void setRegistries( Registries registries )
+    {
+        // do nothing
+    }
+
+
+    /**
+     * Add a new name to the list of names for this SchemaObject. The name
+     * is lowercased and trimmed.
+     *  
+     * @param names The names to add
+     */
+    public void addName( String... names )
+    {
+        if ( !isReadOnly )
+        {
+            // We must avoid duplicated names, as names are case insensitive
+            Set<String> lowerNames = new HashSet<String>();
+
+            // Fills a set with all the existing names
+            for ( String name : this.names )
+            {
+                lowerNames.add( StringTools.toLowerCase( name ) );
+            }
+
+            for ( String name : names )
+            {
+                if ( name != null )
+                {
+                    String lowerName = StringTools.toLowerCase( name );
+                    // Check that the lower cased names is not already present
+                    if ( !lowerNames.contains( lowerName ) )
+                    {
+                        this.names.add( name );
+                        lowerNames.add( lowerName );
+                    }
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Sets the list of names for this SchemaObject. The names are
+     * lowercased and trimmed.
+     *  
+     * @param names The list of names. Can be empty
+     */
+    public void setNames( List<String> names )
+    {
+        if ( names == null )
+        {
+            return;
+        }
+
+        if ( !isReadOnly )
+        {
+            this.names = new ArrayList<String>( names.size() );
+
+            for ( String name : names )
+            {
+                if ( name != null )
+                {
+                    this.names.add( name );
+                }
+            }
+        }
+    }
+
+
+    /**
+     * Gets a short description about this SchemaObject.
+     * 
+     * @return a short description about this SchemaObject
+     */
+    public String getDescription()
+    {
+        return description;
+    }
+
+
+    /**
+     * Sets the SchemaObject's description
+     * 
+     * @param description The SchemaObject's description
+     */
+    public void setDescription( String description )
+    {
+        if ( !isReadOnly )
+        {
+            this.description = description;
+        }
+    }
+
+
+    /**
+     * Gets the SchemaObject specification.
+     * 
+     * @return the SchemaObject specification
+     */
+    public String getSpecification()
+    {
+        return specification;
+    }
+
+
+    /**
+     * Sets the SchemaObject's specification
+     * 
+     * @param specification The SchemaObject's specification
+     */
+    public void setSpecification( String specification )
+    {
+        if ( !isReadOnly )
+        {
+            this.specification = specification;
+        }
+    }
+
+
+    /**
+     * Tells if this SchemaObject is enabled.
+     *  
+     * @param schemaEnabled the associated schema status
+     * @return true if the SchemaObject is enabled, or if it depends on 
+     * an enabled schema
+     */
+    public boolean isEnabled()
+    {
+        return isEnabled;
+    }
+
+
+    /**
+     * Tells if this SchemaObject is disabled.
+     *  
+     * @return true if the SchemaObject is disabled
+     */
+    public boolean isDisabled()
+    {
+        return !isEnabled;
+    }
+
+
+    /**
+     * Sets the SchemaObject state, either enabled or disabled.
+     * 
+     * @param enabled The current SchemaObject state
+     */
+    public void setEnabled( boolean enabled )
+    {
+        if ( !isReadOnly )
+        {
+            isEnabled = enabled;
+        }
+    }
+
+
+    /**
+     * Tells if this SchemaObject is ReadOnly.
+     *  
+     * @return true if the SchemaObject is not modifiable
+     */
+    public boolean isReadOnly()
+    {
+        return isReadOnly;
+    }
+
+
+    /**
+     * Sets the SchemaObject readOnly flag
+     * 
+     * @param enabled The current SchemaObject ReadOnly status
+     */
+    public void setReadOnly( boolean isReadOnly )
+    {
+        this.isReadOnly = isReadOnly;
+    }
+
+
+    /**
+     * Gets whether or not this SchemaObject has been inactivated. All
+     * SchemaObjects except Syntaxes allow for this parameter within their
+     * definition. For Syntaxes this property should always return false in
+     * which case it is never included in the description.
+     * 
+     * @return true if inactive, false if active
+     */
+    public boolean isObsolete()
+    {
+        return isObsolete;
+    }
+
+
+    /**
+     * Sets the Obsolete flag.
+     * 
+     * @param obsolete The Obsolete flag state
+     */
+    public void setObsolete( boolean obsolete )
+    {
+        if ( !isReadOnly )
+        {
+            this.isObsolete = obsolete;
+        }
+    }
+
+
+    /**
+     * @return The SchemaObject extensions, as a Map of [extension, values]
+     */
+    public Map<String, List<String>> getExtensions()
+    {
+        return extensions;
+    }
+
+
+    /**
+     * Add an extension with its values
+     * @param key The extension key
+     * @param values The associated values
+     */
+    public void addExtension( String key, List<String> values )
+    {
+        if ( !isReadOnly )
+        {
+            extensions.put( key, values );
+        }
+    }
+
+
+    /**
+     * Add an extensions with their values. (Actually do a copy)
+     * 
+     * @param key The extension key
+     * @param values The associated values
+     */
+    public void setExtensions( Map<String, List<String>> extensions )
+    {
+        if ( !isReadOnly && ( extensions != null ) )
+        {
+            this.extensions = new HashMap<String, List<String>>();
+
+            for ( String key : extensions.keySet() )
+            {
+                List<String> values = new ArrayList<String>();
+
+                for ( String value : extensions.get( key ) )
+                {
+                    values.add( value );
+                }
+
+                this.extensions.put( key, values );
+            }
+
+        }
+    }
+
+
+    /**
+     * The SchemaObject type :
+     * <li> AttributeType
+     * <li> DitCOntentRule
+     * <li> DitStructureRule
+     * <li> LdapComparator (specific to ADS)
+     * <li> LdapSyntaxe
+     * <li> MatchingRule
+     * <li> MatchingRuleUse
+     * <li> NameForm
+     * <li> Normalizer (specific to ADS)
+     * <li> ObjectClass
+     * <li> SyntaxChecker (specific to ADS)
+     * 
+     * @return the SchemaObject type
+     */
+    public SchemaObjectType getObjectType()
+    {
+        return objectType;
+    }
+
+
+    /**
+     * Gets the name of the schema this SchemaObject is associated with.
+     *
+     * @return the name of the schema associated with this schemaObject
+     */
+    public String getSchemaName()
+    {
+        return schemaName;
+    }
+
+
+    /**
+     * Sets the name of the schema this SchemaObject is associated with.
+     * 
+     * @param schemaName the new schema name
+     */
+    public void setSchemaName( String schemaName )
+    {
+        if ( !isReadOnly )
+        {
+            this.schemaName = schemaName;
+        }
+    }
+
+
+    /**
+     * @see Object#hashCode()
+     */
+    public int hashCode()
+    {
+        int h = 37;
+
+        // The OID
+        h += h * 17 + oid.hashCode();
+
+        // The SchemaObject type
+        h += h * 17 + objectType.getValue();
+
+        // The Names, if any
+        if ( ( names != null ) && ( names.size() != 0 ) )
+        {
+            for ( String name : names )
+            {
+                h += h * 17 + name.hashCode();
+            }
+        }
+
+        // The schemaName if any
+        if ( schemaName != null )
+        {
+            h += h * 17 + schemaName.hashCode();
+        }
+
+        h += h * 17 + ( isEnabled ? 1 : 0 );
+        h += h * 17 + ( isReadOnly ? 1 : 0 );
+
+        // The description, if any
+        if ( description != null )
+        {
+            h += h * 17 + description.hashCode();
+        }
+
+        // The extensions, if any
+        for ( String key : extensions.keySet() )
+        {
+            h += h * 17 + key.hashCode();
+
+            List<String> values = extensions.get( key );
+
+            if ( values != null )
+            {
+                for ( String value : values )
+                {
+                    h += h * 17 + value.hashCode();
+                }
+            }
+        }
+
+        return h;
+    }
+
+
+    /**
+     * @see Object#equals(Object)
+     */
+    public boolean equals( Object o1 )
+    {
+        if ( this == o1 )
+        {
+            return true;
+        }
+
+        if ( !( o1 instanceof AbstractSchemaObject ) )
+        {
+            return false;
+        }
+
+        AbstractSchemaObject that = ( AbstractSchemaObject ) o1;
+
+        // Two schemaObject are equals if their oid is equal,
+        // their ObjectType is equal, their names are equals
+        // their schema name is the same, all their flags are equals,
+        // the description is the same and their extensions are equals
+        if ( !compareOid( oid, that.oid ) )
+        {
+            return false;
+        }
+
+        // Compare the names
+        if ( names == null )
+        {
+            if ( that.names != null )
+            {
+                return false;
+            }
+        }
+        else if ( that.names == null )
+        {
+            return false;
+        }
+        else
+        {
+            int nbNames = 0;
+
+            for ( String name : names )
+            {
+                if ( !that.names.contains( name ) )
+                {
+                    return false;
+                }
+
+                nbNames++;
+            }
+
+            if ( nbNames != names.size() )
+            {
+                return false;
+            }
+        }
+
+        if ( schemaName == null )
+        {
+            if ( that.schemaName != null )
+            {
+                return false;
+            }
+        }
+        else
+        {
+            if ( !schemaName.equalsIgnoreCase( that.schemaName ) )
+            {
+                return false;
+            }
+        }
+
+        if ( objectType != that.objectType )
+        {
+            return false;
+        }
+
+        if ( extensions != null )
+        {
+            if ( that.extensions == null )
+            {
+                return false;
+            }
+            else
+            {
+                for ( String key : extensions.keySet() )
+                {
+                    if ( !that.extensions.containsKey( key ) )
+                    {
+                        return false;
+                    }
+
+                    List<String> thisValues = extensions.get( key );
+                    List<String> thatValues = that.extensions.get( key );
+
+                    if ( thisValues != null )
+                    {
+                        if ( thatValues == null )
+                        {
+                            return false;
+                        }
+                        else
+                        {
+                            if ( thisValues.size() != thatValues.size() )
+                            {
+                                return false;
+                            }
+
+                            // TODO compare the values
+                        }
+                    }
+                    else if ( thatValues != null )
+                    {
+                        return false;
+                    }
+                }
+            }
+        }
+        else if ( that.extensions != null )
+        {
+            return false;
+        }
+
+        if ( this.isEnabled != that.isEnabled )
+        {
+            return false;
+        }
+
+        if ( this.isObsolete != that.isObsolete )
+        {
+            return false;
+        }
+
+        if ( this.isReadOnly != that.isReadOnly )
+        {
+            return false;
+        }
+
+        if ( this.description == null )
+        {
+            return that.description == null;
+        }
+        else
+        {
+            return this.description.equalsIgnoreCase( that.description );
+        }
+    }
+
+
+    /**
+     * Register the given SchemaObject into the given registries' globalOidRegistry
+     *
+     * @param schemaObject the SchemaObject we want to register
+     * @param registries The registries in which we want it to be stored
+     * @throws NamingException If the OID is invalid
+     */
+    public void registerOid( SchemaObject schemaObject, Registries registries ) throws NamingException
+    {
+        // Add the SchemaObject into the globalOidRegistry
+        registries.getGlobalOidRegistry().register( schemaObject );
+    }
+
+
+    /**
+     * Copy the current SchemaObject on place
+     *
+     * @return The copied SchemaObject
+     */
+    public abstract SchemaObject copy();
+
+
+    /**
+     * Compare two oids, and return true if they are both null or
+     * equals
+     */
+    protected boolean compareOid( String oid1, String oid2 )
+    {
+        if ( oid1 == null )
+        {
+            return oid2 == null;
+        }
+        else
+        {
+            return oid1.equals( oid2 );
+        }
+    }
+
+
+    /**
+     * Copy a SchemaObject.
+     * 
+     * @return A copy of the current SchemaObject
+     */
+    public SchemaObject copy( SchemaObject original )
+    {
+        // copy the description
+        description = original.getDescription();
+
+        // copy the flags
+        isEnabled = original.isEnabled();
+        isObsolete = original.isObsolete();
+        isReadOnly = original.isReadOnly();
+
+        // copy the names
+        names = new ArrayList<String>();
+
+        for ( String name : original.getNames() )
+        {
+            names.add( name );
+        }
+
+        // copy the extensions
+        extensions = new HashMap<String, List<String>>();
+
+        for ( String key : original.getExtensions().keySet() )
+        {
+            List<String> extensionValues = original.getExtensions().get( key );
+
+            List<String> cloneExtension = new ArrayList<String>();
+
+            for ( String value : extensionValues )
+            {
+                cloneExtension.add( value );
+            }
+
+            extensions.put( key, cloneExtension );
+        }
+
+        // The SchemaName
+        schemaName = original.getSchemaName();
+
+        // The specification
+        specification = original.getSpecification();
+
+        return this;
+    }
+
+
+    /**
+     * Clear the current SchemaObject : remove all the references to other objects, 
+     * and all the Maps. 
+     */
+    public void clear()
+    {
+        // Clear the extensions
+        for ( String extension : extensions.keySet() )
+        {
+            List<String> extensionList = extensions.get( extension );
+
+            extensionList.clear();
+        }
+
+        extensions.clear();
+
+        // Clear the names
+        names.clear();
+    }
+}

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java?rev=887926&r1=887925&r2=887926&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/AttributeType.java Mon Dec  7 14:06:56 2009
@@ -140,7 +140,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class AttributeType extends SchemaObject implements Cloneable
+public class AttributeType extends AbstractSchemaObject implements Cloneable
 {
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( AttributeType.class );
@@ -597,7 +597,7 @@
 
 
     /**
-     * Inject the registries into this Object, updating the references to
+     * Inject the attributeType into the registries, updating the references to
      * other SchemaObject.
      * 
      * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR, SYNTAX), 
@@ -606,7 +606,7 @@
      * @param registries The Registries
      * @exception If the AttributeType is not valid 
      */
-    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
+    public void addToRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
@@ -678,6 +678,62 @@
 
 
     /**
+     * Remove the attributeType from the registries, updating the references to
+     * other SchemaObject.
+     * 
+     * If one of the referenced SchemaObject does not exist (SUP, EQUALITY, ORDERING, SUBSTR, SYNTAX), 
+     * an exception is thrown.
+     *
+     * @param registries The Registries
+     * @exception If the AttributeType is not valid 
+     */
+    public void removeFromRegistries( List<Throwable> errors, Registries registries ) throws NamingException
+    {
+        if ( registries != null )
+        {
+            AttributeTypeRegistry attributeTypeRegistry = registries.getAttributeTypeRegistry();
+
+            // Remove the attributeType from the oid/normalizer map
+            attributeTypeRegistry.removeMappingFor( this );
+
+            // Register this AttributeType into the Descendant map
+            attributeTypeRegistry.unregisterDescendants( this, superior );
+
+            /**
+             * Add the AT references (using and usedBy) : 
+             * AT -> MR (for EQUALITY, ORDERING and SUBSTR)
+             * AT -> S
+             * AT -> AT
+             */
+            if ( equality != null )
+            {
+                registries.delReference( this, equality );
+            }
+
+            if ( ordering != null )
+            {
+                registries.delReference( this, ordering );
+            }
+
+            if ( substring != null )
+            {
+                registries.delReference( this, substring );
+            }
+
+            if ( syntax != null )
+            {
+                registries.delReference( this, syntax );
+            }
+
+            if ( superior != null )
+            {
+                registries.delReference( this, superior );
+            }
+        }
+    }
+
+
+    /**
      * Gets whether or not this AttributeType is single-valued.
      * 
      * @return true if only one value can exist for this AttributeType, false

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java?rev=887926&r1=887925&r2=887926&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITContentRule.java Mon Dec  7 14:06:56 2009
@@ -116,11 +116,11 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DITContentRule extends SchemaObject
+public class DITContentRule extends AbstractSchemaObject
 {
     /** The serialVersionUID */
     public static final long serialVersionUID = 1L;
-    
+
     /** The list of Auxiliary ObjectClass OIDs entries may belong to */
     private List<String> auxObjectClassOids;
 
@@ -138,13 +138,14 @@
 
     /** The list of required AttributeTypes */
     private List<AttributeType> mustAttributeTypes;
-    
+
     /** The list of precluded AttributeType OIDs */
     private List<String> notAttributeTypeOids;
 
     /** The list of precluded AttributeTypes */
     private List<AttributeType> notAttributeTypes;
 
+
     /**
      * Creates a DITContentRule object using a unique OID.
      * 
@@ -153,7 +154,7 @@
     public DITContentRule( String oid )
     {
         super( SchemaObjectType.DIT_CONTENT_RULE, oid );
-        
+
         mayAttributeTypeOids = new ArrayList<String>();
         mustAttributeTypeOids = new ArrayList<String>();
         notAttributeTypeOids = new ArrayList<String>();
@@ -165,7 +166,7 @@
         auxObjectClasses = new ArrayList<ObjectClass>();
     }
 
-    
+
     /**
      * @return the auxObjectClassOids
      */
@@ -174,7 +175,7 @@
         return auxObjectClassOids;
     }
 
-    
+
     /**
      * Add an Auxiliary ObjectClass Oid
      *
@@ -198,14 +199,14 @@
     {
         if ( !isReadOnly )
         {
-            if ( ! auxObjectClassOids.contains( objectClass.getOid() ) )
+            if ( !auxObjectClassOids.contains( objectClass.getOid() ) )
             {
                 auxObjectClasses.add( objectClass );
                 auxObjectClassOids.add( objectClass.getOid() );
             }
         }
     }
-    
+
 
     /**
      * @param auxObjectClassOids the auxObjectClassOids to set
@@ -227,18 +228,18 @@
         if ( !isReadOnly )
         {
             this.auxObjectClasses = auxObjectClasses;
-            
+
             // update the OIDS now
             auxObjectClassOids.clear();
-            
+
             for ( ObjectClass oc : auxObjectClasses )
             {
                 auxObjectClassOids.add( oc.getOid() );
             }
         }
     }
-    
-    
+
+
     /**
      * @return the auxObjectClasses
      */
@@ -247,7 +248,7 @@
         return auxObjectClasses;
     }
 
-    
+
     /**
      * @return the mayAttributeTypeOids
      */
@@ -280,7 +281,7 @@
     {
         if ( !isReadOnly )
         {
-            if ( ! mayAttributeTypeOids.contains( attributeType.getOid() ) )
+            if ( !mayAttributeTypeOids.contains( attributeType.getOid() ) )
             {
                 mayAttributeTypes.add( attributeType );
                 mayAttributeTypeOids.add( attributeType.getOid() );
@@ -288,7 +289,7 @@
         }
     }
 
-    
+
     /**
      * @param mayAttributeTypeOids the mayAttributeTypeOids to set
      */
@@ -299,8 +300,8 @@
             this.mayAttributeTypeOids = mayAttributeTypeOids;
         }
     }
-    
-    
+
+
     /**
      * Sets the list of allowed AttributeTypes
      *
@@ -311,10 +312,10 @@
         if ( !isReadOnly )
         {
             this.mayAttributeTypes = mayAttributeTypes;
-            
+
             // update the OIDS now
             mayAttributeTypeOids.clear();
-            
+
             for ( AttributeType may : mayAttributeTypes )
             {
                 mayAttributeTypeOids.add( may.getOid() );
@@ -340,7 +341,7 @@
         return mustAttributeTypeOids;
     }
 
-    
+
     /**
      * Add a required AttributeType OID
      *
@@ -364,7 +365,7 @@
     {
         if ( !isReadOnly )
         {
-            if ( ! mustAttributeTypeOids.contains( attributeType.getOid() ) )
+            if ( !mustAttributeTypeOids.contains( attributeType.getOid() ) )
             {
                 mustAttributeTypes.add( attributeType );
                 mustAttributeTypeOids.add( attributeType.getOid() );
@@ -384,7 +385,7 @@
         }
     }
 
-    
+
     /**
      * Sets the list of required AttributeTypes
      *
@@ -395,10 +396,10 @@
         if ( !isReadOnly )
         {
             this.mustAttributeTypes = mustAttributeTypes;
-            
+
             // update the OIDS now
             mustAttributeTypeOids.clear();
-            
+
             for ( AttributeType may : mustAttributeTypes )
             {
                 mustAttributeTypeOids.add( may.getOid() );
@@ -448,7 +449,7 @@
     {
         if ( !isReadOnly )
         {
-            if ( ! notAttributeTypeOids.contains( attributeType.getOid() ) )
+            if ( !notAttributeTypeOids.contains( attributeType.getOid() ) )
             {
                 notAttributeTypes.add( attributeType );
                 notAttributeTypeOids.add( attributeType.getOid() );
@@ -468,7 +469,7 @@
         }
     }
 
-    
+
     /**
      * Sets the list of precluded AttributeTypes
      *
@@ -479,10 +480,10 @@
         if ( !isReadOnly )
         {
             this.notAttributeTypes = notAttributeTypes;
-            
+
             // update the OIDS now
             notAttributeTypeOids.clear();
-            
+
             for ( AttributeType not : notAttributeTypes )
             {
                 notAttributeTypeOids.add( not.getOid() );
@@ -498,25 +499,26 @@
     {
         return notAttributeTypes;
     }
-    
-    
+
+
     /**
-     * Inject the registries into this Object, updating the references to
+     * Inject the DITContentRule into the registries, updating the references to
      * other SchemaObject
      *
      * @param registries The Registries
+     * @exception If the addition failed
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void addToRegistries( Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
             AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
             ObjectClassRegistry ocRegistry = registries.getObjectClassRegistry();
-            
+
             if ( mayAttributeTypeOids != null )
             {
                 mayAttributeTypes = new ArrayList<AttributeType>( mayAttributeTypeOids.size() );
-                
+
                 for ( String oid : mayAttributeTypeOids )
                 {
                     mayAttributeTypes.add( atRegistry.lookup( oid ) );
@@ -526,7 +528,7 @@
             if ( mustAttributeTypeOids != null )
             {
                 mustAttributeTypes = new ArrayList<AttributeType>( mustAttributeTypeOids.size() );
-                
+
                 for ( String oid : mustAttributeTypeOids )
                 {
                     mustAttributeTypes.add( atRegistry.lookup( oid ) );
@@ -536,17 +538,17 @@
             if ( notAttributeTypeOids != null )
             {
                 notAttributeTypes = new ArrayList<AttributeType>( notAttributeTypeOids.size() );
-                
+
                 for ( String oid : notAttributeTypeOids )
                 {
                     notAttributeTypes.add( atRegistry.lookup( oid ) );
                 }
             }
-            
+
             if ( auxObjectClassOids != null )
             {
                 auxObjectClasses = new ArrayList<ObjectClass>( auxObjectClassOids.size() );
-                
+
                 for ( String oid : auxObjectClassOids )
                 {
                     auxObjectClasses.add( ocRegistry.lookup( oid ) );
@@ -574,55 +576,55 @@
 
         // Copy the SchemaObject common data
         copy.copy( this );
-        
+
         // copy the AUX ObjectClasses OIDs
         copy.auxObjectClassOids = new ArrayList<String>();
-        
+
         for ( String oid : auxObjectClassOids )
         {
             copy.auxObjectClassOids.add( oid );
         }
-        
+
         // copy the AUX ObjectClasses ( will be empty )
         copy.auxObjectClasses = new ArrayList<ObjectClass>();
-        
+
         // Clone the MAY AttributeTypes OIDs
         copy.mayAttributeTypeOids = new ArrayList<String>();
-        
+
         for ( String oid : mayAttributeTypeOids )
         {
             copy.mayAttributeTypeOids.add( oid );
         }
-        
+
         // Clone the MAY AttributeTypes ( will be empty )
         copy.mayAttributeTypes = new ArrayList<AttributeType>();
-        
+
         // Clone the MUST AttributeTypes OIDs
         copy.mustAttributeTypeOids = new ArrayList<String>();
-        
+
         for ( String oid : mustAttributeTypeOids )
         {
             copy.mustAttributeTypeOids.add( oid );
         }
-        
+
         // Clone the MUST AttributeTypes ( will be empty )
         copy.mustAttributeTypes = new ArrayList<AttributeType>();
-        
+
         // Clone the NOT AttributeTypes OIDs
         copy.notAttributeTypeOids = new ArrayList<String>();
-        
+
         for ( String oid : notAttributeTypeOids )
         {
             copy.notAttributeTypeOids.add( oid );
         }
-        
+
         // Clone the NOT AttributeTypes ( will be empty )
         copy.notAttributeTypes = new ArrayList<AttributeType>();
-        
+
         return copy;
     }
-    
-    
+
+
     /**
      * @see Object#equals(Object)
      */
@@ -637,13 +639,14 @@
         {
             return false;
         }
-        
-        DITContentRule that = (DITContentRule)o;
+
+        DITContentRule that = ( DITContentRule ) o;
 
         // TODO : complete the check
         return true;
     }
-        
+
+
     /**
      * {@inheritDoc}
      */
@@ -651,7 +654,7 @@
     {
         // Clear the common elements
         super.clear();
-        
+
         // Clear the references
         auxObjectClasses.clear();
         auxObjectClassOids.clear();

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java?rev=887926&r1=887925&r2=887926&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/DITStructureRule.java Mon Dec  7 14:06:56 2009
@@ -80,26 +80,27 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class DITStructureRule extends SchemaObject
+public class DITStructureRule extends AbstractSchemaObject
 {
     /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
 
     /** The rule ID. A DSR does not have an OID */
     private int ruleId;
-    
+
     /** The associated NameForm */
     private String form;
 
     /** The list of superiors rules */
     private List<Integer> superRules;
 
+
     /**
      * Creates a new instance of DITStructureRule
      */
     public DITStructureRule( int ruleId )
     {
-        super(  SchemaObjectType.DIT_STRUCTURE_RULE, null );
+        super( SchemaObjectType.DIT_STRUCTURE_RULE, null );
         this.ruleId = ruleId;
         form = null;
         superRules = new ArrayList<Integer>();
@@ -184,14 +185,14 @@
     {
         superRules.add( superRule );
     }
-    
-    
+
+
     /**
      * The DSR does not have an OID, so throw an exception
      */
     public String getOid()
     {
-        throw new NotImplementedException(); 
+        throw new NotImplementedException();
     }
 
 
@@ -213,22 +214,22 @@
 
         // Copy the SchemaObject common data
         copy.copy( this );
-        
+
         // Copy the Superiors rules
         copy.superRules = new ArrayList<Integer>();
-        
+
         // Copy the form
         copy.form = form;
-        
+
         for ( int ruleId : superRules )
         {
             copy.superRules.add( ruleId );
         }
-        
+
         return copy;
     }
-    
-    
+
+
     /**
      * @see Object#equals(Object)
      */
@@ -243,14 +244,14 @@
         {
             return false;
         }
-        
-        DITStructureRule that = (DITStructureRule)o;
-        
+
+        DITStructureRule that = ( DITStructureRule ) o;
+
         // TODO : complete the test
         return true;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -258,7 +259,7 @@
     {
         // Clear the common elements
         super.clear();
-        
+
         // Clear the references
         superRules.clear();
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java?rev=887926&r1=887925&r2=887926&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LdapSyntax.java Mon Dec  7 14:06:56 2009
@@ -71,17 +71,18 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 437007 $
  */
-public class LdapSyntax extends SchemaObject
+public class LdapSyntax extends AbstractSchemaObject
 {
     /** The serialVersionUID */
     public static final long serialVersionUID = 1L;
-    
+
     /** the human readable flag */
     protected boolean isHumanReadable = false;
-    
+
     /** The associated SyntaxChecker */
     protected SyntaxChecker syntaxChecker;
-    
+
+
     /**
      * Creates a Syntax object using a unique OID.
      * 
@@ -110,7 +111,7 @@
      * 
      * @param oid the OID for this Syntax
      */
-    public LdapSyntax( String oid, String description, boolean isHumanReadable  )
+    public LdapSyntax( String oid, String description, boolean isHumanReadable )
     {
         super( SchemaObjectType.LDAP_SYNTAX, oid );
         this.description = description;
@@ -128,7 +129,7 @@
         return isHumanReadable;
     }
 
-    
+
     /**
      * Sets the human readable flag value.
      * 
@@ -136,12 +137,12 @@
      */
     public void setHumanReadable( boolean isHumanReadable )
     {
-        if ( ! isReadOnly )
+        if ( !isReadOnly )
         {
             this.isHumanReadable = isHumanReadable;
         }
     }
-    
+
 
     /**
      * Gets the SyntaxChecker used to validate values in accordance with this
@@ -153,8 +154,8 @@
     {
         return syntaxChecker;
     }
-    
-    
+
+
     /**
      * Sets the associated SyntaxChecker
      *
@@ -162,13 +163,13 @@
      */
     public void setSyntaxChecker( SyntaxChecker syntaxChecker )
     {
-        if ( ! isReadOnly )
+        if ( !isReadOnly )
         {
             this.syntaxChecker = syntaxChecker;
         }
     }
-    
-    
+
+
     /**
      * Update the associated SyntaxChecker, even if the SchemaObject is readOnly
      *
@@ -190,12 +191,13 @@
 
 
     /**
-     * Inject the registries into this Object, updating the references to
+     * Inject the Syntax into the registries, updating the references to
      * other SchemaObject
      *
      * @param registries The Registries
+     * @exception If the addition failed
      */
-    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
+    public void addToRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
@@ -229,17 +231,17 @@
 
         // Copy the SchemaObject common data
         copy.copy( this );
-        
+
         // Copy the HR flag
         copy.isHumanReadable = isHumanReadable;
-        
+
         // All the references to other Registries object are set to null.
         copy.syntaxChecker = null;
-        
+
         return copy;
     }
-    
-    
+
+
     /**
      * @see Object#equals()
      */
@@ -254,20 +256,20 @@
         {
             return false;
         }
-        
-        LdapSyntax that = (LdapSyntax)o;
-        
+
+        LdapSyntax that = ( LdapSyntax ) o;
+
         // IsHR
         if ( isHumanReadable != that.isHumanReadable )
         {
             return false;
         }
-        
+
         // Check the SyntaxChecker (not a equals)
         return syntaxChecker.getOid().equals( that.syntaxChecker.getOid() );
     }
 
-    
+
     /**
      * {@inheritDoc}
      */
@@ -275,7 +277,7 @@
     {
         // Clear the common elements
         super.clear();
-        
+
         // Clear the references
         syntaxChecker = null;
     }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java?rev=887926&r1=887925&r2=887926&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/LoadableSchemaObject.java Mon Dec  7 14:06:56 2009
@@ -19,10 +19,12 @@
  */
 package org.apache.directory.shared.ldap.schema;
 
+
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.registries.Registries;
 
+
 /**
  * An abstract class used to manage the ADS specific SchemaObject, which can
  * contain some compiled Java class to implement the specific logic.
@@ -30,7 +32,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev: 437007 $
  */
-public abstract class LoadableSchemaObject extends SchemaObject
+public abstract class LoadableSchemaObject extends AbstractSchemaObject
 {
     /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
@@ -41,6 +43,7 @@
     /** The base64 encoded bytecode for this schema */
     private String bytecode;
 
+
     /**
      * Constructor to use when the OID is known in advance.
      * 
@@ -87,7 +90,7 @@
      */
     public void setBytecode( String bytecode )
     {
-        if ( ! isReadOnly )
+        if ( !isReadOnly )
         {
             this.bytecode = bytecode;
         }
@@ -110,13 +113,13 @@
      */
     public void setFqcn( String fqcn )
     {
-        if ( ! isReadOnly )
+        if ( !isReadOnly )
         {
             this.fqcn = fqcn;
         }
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -124,8 +127,8 @@
     {
         // Do nothing : the current SchemaObject ha sthe same OID than the one it is realted to
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -133,8 +136,8 @@
     {
         return null;
     }
-    
-    
+
+
     /**
      * @see Object#equals()
      */
@@ -149,12 +152,12 @@
         {
             return false;
         }
-        
-        LoadableSchemaObject that = (LoadableSchemaObject)o;
-        
+
+        LoadableSchemaObject that = ( LoadableSchemaObject ) o;
+
         // Check the byteCode
         // TODO
-        
+
         // Check the FQCN
         if ( fqcn == null )
         {
@@ -164,6 +167,6 @@
         {
             return fqcn.equals( that.fqcn );
         }
-       
+
     }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java?rev=887926&r1=887925&r2=887926&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRule.java Mon Dec  7 14:06:56 2009
@@ -82,7 +82,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class MatchingRule extends SchemaObject
+public class MatchingRule extends AbstractSchemaObject
 {
     /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
@@ -95,10 +95,11 @@
 
     /** The associated LdapSyntax */
     protected LdapSyntax ldapSyntax;
-    
+
     /** The associated LdapSyntax OID */
     private String ldapSyntaxOid;
-    
+
+
     /**
      * Creates a new instance of MatchingRule.
      *
@@ -112,26 +113,27 @@
 
 
     /**
-     * Inject the registries into this Object, updating the references to
+     * Inject the MatchingRule into the registries, updating the references to
      * other SchemaObject
      *
      * @param registries The Registries
+     * @exception If the addition failed
      */
-    public void applyRegistries( List<Throwable> errors, Registries registries ) throws NamingException
+    public void addToRegistries( List<Throwable> errors, Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
             try
             {
                 // Gets the associated Comparator 
-                ldapComparator = (LdapComparator<? super Object>)registries.getComparatorRegistry().lookup( oid );
+                ldapComparator = ( LdapComparator<? super Object> ) registries.getComparatorRegistry().lookup( oid );
             }
             catch ( NamingException ne )
             {
                 // Default to a catch all comparator
                 ldapComparator = new ComparableComparator( oid );
             }
-    
+
             try
             {
                 // Gets the associated Normalizer
@@ -142,7 +144,7 @@
                 // Default to the NoOp normalizer
                 normalizer = new NoOpNormalizer( oid );
             }
-            
+
             try
             {
                 // Get the associated LdapSyntax
@@ -151,10 +153,11 @@
             catch ( NamingException ne )
             {
                 // The Syntax is a mandatory element, it must exist.
-                throw new LdapSchemaViolationException( "The created MatchingRule must refers to an existing SYNTAX element", 
+                throw new LdapSchemaViolationException(
+                    "The created MatchingRule must refers to an existing SYNTAX element",
                     ResultCodeEnum.UNWILLING_TO_PERFORM );
             }
-            
+
             /**
              * Add the MR references (using and usedBy) : 
              * MR -> C
@@ -165,32 +168,32 @@
             {
                 registries.addReference( this, ldapComparator );
             }
-            
+
             if ( normalizer != null )
             {
                 registries.addReference( this, normalizer );
             }
-            
+
             if ( ldapSyntax != null )
             {
                 registries.addReference( this, ldapSyntax );
             }
-            
+
         }
     }
-    
-    
+
+
     /**
      * Gets the LdapSyntax used by this MatchingRule.
      * 
      * @return the LdapSyntax of this MatchingRule
      */
-    public LdapSyntax getSyntax() 
+    public LdapSyntax getSyntax()
     {
         return ldapSyntax;
     }
 
-    
+
     /**
      * Gets the LdapSyntax OID used by this MatchingRule.
      * 
@@ -202,7 +205,7 @@
         return ldapSyntaxOid;
     }
 
-    
+
     /**
      * Sets the Syntax's OID
      *
@@ -216,7 +219,7 @@
         }
     }
 
-    
+
     /**
      * Sets the Syntax
      *
@@ -266,7 +269,7 @@
     {
         if ( !isReadOnly )
         {
-            this.ldapComparator = (LdapComparator<? super Object>)ldapComparator;
+            this.ldapComparator = ( LdapComparator<? super Object> ) ldapComparator;
         }
     }
 
@@ -278,7 +281,7 @@
      */
     public void updateLdapComparator( LdapComparator<?> ldapComparator )
     {
-        this.ldapComparator = (LdapComparator<? super Object>)ldapComparator;
+        this.ldapComparator = ( LdapComparator<? super Object> ) ldapComparator;
     }
 
 
@@ -318,8 +321,8 @@
     {
         this.normalizer = normalizer;
     }
-    
-    
+
+
     /**
      * @see Object#toString()
      */
@@ -327,8 +330,8 @@
     {
         return objectType + " " + DescriptionUtils.getDescription( this );
     }
-    
-    
+
+
     /**
      * Copy an MatchingRule
      */
@@ -343,14 +346,14 @@
         copy.ldapComparator = null;
         copy.ldapSyntax = null;
         copy.normalizer = null;
-        
+
         // Copy the syntax OID
         copy.ldapSyntaxOid = ldapSyntaxOid;
-        
+
         return copy;
     }
-    
-    
+
+
     /**
      * @see Object#equals()
      */
@@ -365,9 +368,9 @@
         {
             return false;
         }
-        
-        MatchingRule that = (MatchingRule)o;
-        
+
+        MatchingRule that = ( MatchingRule ) o;
+
         // Check the Comparator
         if ( ldapComparator != null )
         {
@@ -383,8 +386,7 @@
                 return false;
             }
         }
-            
-        
+
         // Check the Normalizer
         if ( normalizer != null )
         {
@@ -400,17 +402,17 @@
                 return false;
             }
         }
-        
+
         // Check the Syntax
         if ( !compareOid( ldapSyntaxOid, that.ldapSyntaxOid ) )
         {
             return false;
         }
-        
+
         return ldapSyntax.equals( that.ldapSyntax );
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -418,7 +420,7 @@
     {
         // Clear the common elements
         super.clear();
-        
+
         // Clear the references
         ldapComparator = null;
         ldapSyntax = null;

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java?rev=887926&r1=887925&r2=887926&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/MatchingRuleUse.java Mon Dec  7 14:06:56 2009
@@ -85,7 +85,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class MatchingRuleUse extends SchemaObject
+public class MatchingRuleUse extends AbstractSchemaObject
 {
     /** The serialVersionUID */
     private static final long serialVersionUID = 1L;
@@ -95,35 +95,37 @@
 
     /** The list of attributes types the matching rule applies to */
     private List<AttributeType> applicableAttributes;
-    
+
+
     /**
      * Creates a new instance of MatchingRuleUseDescription
      */
     public MatchingRuleUse( String oid )
     {
-        super(  SchemaObjectType.MATCHING_RULE_USE, oid );
-        
+        super( SchemaObjectType.MATCHING_RULE_USE, oid );
+
         applicableAttributeOids = new ArrayList<String>();
         applicableAttributes = new ArrayList<AttributeType>();
     }
-    
+
 
     /**
-     * Inject the registries into this Object, updating the references to
+     * Inject the MatchingRuleUse into the registries, updating the references to
      * other SchemaObject
      *
      * @param registries The Registries
+     * @exception If the addition failed
      */
-    public void applyRegistries( Registries registries ) throws NamingException
+    public void addToRegistries( Registries registries ) throws NamingException
     {
         if ( registries != null )
         {
             AttributeTypeRegistry atRegistry = registries.getAttributeTypeRegistry();
-            
+
             if ( applicableAttributeOids != null )
             {
                 applicableAttributes = new ArrayList<AttributeType>( applicableAttributeOids.size() );
-                
+
                 for ( String oid : applicableAttributeOids )
                 {
                     applicableAttributes.add( atRegistry.lookup( oid ) );
@@ -132,7 +134,7 @@
         }
     }
 
-    
+
     /**
      * @return The matchingRule's list of AttributeType OIDs the MRU applies to
      */
@@ -163,8 +165,8 @@
             this.applicableAttributeOids = applicableAttributeOids;
         }
     }
-    
-    
+
+
     /**
      * Set the matchingRule's AttributeType the MRU applies to.
      *
@@ -175,18 +177,18 @@
         if ( !isReadOnly )
         {
             this.applicableAttributes = applicableAttributes;
-            
+
             // update the OIDS now
             applicableAttributeOids.clear();
-            
+
             for ( AttributeType at : applicableAttributes )
             {
                 applicableAttributeOids.add( at.getOid() );
             }
         }
     }
-    
-    
+
+
     /**
      * Add a matchingRule's AttributeType OIDs the MRU applies to.
      *
@@ -213,7 +215,7 @@
     {
         if ( !isReadOnly )
         {
-            if ( ! applicableAttributeOids.contains( attributeType.getOid() ) )
+            if ( !applicableAttributeOids.contains( attributeType.getOid() ) )
             {
                 applicableAttributes.add( attributeType );
                 applicableAttributeOids.add( attributeType.getOid() );
@@ -229,8 +231,8 @@
     {
         return objectType + " " + DescriptionUtils.getDescription( this );
     }
-    
-    
+
+
     /**
      * Copy an MatchingRuleUse
      */
@@ -240,23 +242,23 @@
 
         // Copy the SchemaObject common data
         copy.copy( this );
-        
+
         // Clone the APPLY AttributeTypes
         copy.applicableAttributeOids = new ArrayList<String>();
-        
+
         // Copy the APPLIES oid list
         for ( String oid : applicableAttributeOids )
         {
             copy.applicableAttributeOids.add( oid );
         }
-        
+
         // Copy the APPLIES list (will be empty)
         copy.applicableAttributes = new ArrayList<AttributeType>();
-        
+
         return copy;
     }
-    
-    
+
+
     /**
      * @see Object#equals(Object)
      */
@@ -271,14 +273,14 @@
         {
             return false;
         }
-        
-        MatchingRuleUse that = (MatchingRuleUse)o;
-        
+
+        MatchingRuleUse that = ( MatchingRuleUse ) o;
+
         // TODO : complete the checks
         return true;
     }
-    
-    
+
+
     /**
      * {@inheritDoc}
      */
@@ -286,7 +288,7 @@
     {
         // Clear the common elements
         super.clear();
-        
+
         // Clear the references
         applicableAttributes.clear();
         applicableAttributeOids.clear();



Mime
View raw message