directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r493127 - in /directory/trunks/apacheds: core-unit/src/main/java/org/apache/directory/server/core/unit/ core-unit/src/test/java/org/apache/directory/server/core/schema/ core-unit/src/test/resources/org/apache/directory/server/core/schema/ c...
Date Fri, 05 Jan 2007 18:37:43 GMT
Author: akarasulu
Date: Fri Jan  5 10:37:42 2007
New Revision: 493127

URL: http://svn.apache.org/viewvc?view=rev&rev=493127
Log:
Added handler and test cases to make sure changes to syntaxCheckers under 
ou=schema are handled with the proper updates to registries.

 o added test case
 o modified syntaxChecker registry to now unregister
 o added handler for syntaxChecker events 
 o added test DummySyntaxChecker.bytecode not class so it does not get loaded 2 
   test dynamic code additions to the server via LDAP 


Added:
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerITest.java
    directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode
  (with props)
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
Modified:
    directory/trunks/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
    directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java

Modified: directory/trunks/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java?view=diff&rev=493127&r1=493126&r2=493127
==============================================================================
--- directory/trunks/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
(original)
+++ directory/trunks/apacheds/core-unit/src/main/java/org/apache/directory/server/core/unit/AbstractPerformanceTest.java
Fri Jan  5 10:37:42 2007
@@ -135,7 +135,7 @@
         if ( ! isExternal )
         {
             // Add indices for ou, uid, and objectClass
-            HashSet indexedAttributes = new HashSet();
+            HashSet<String> indexedAttributes = new HashSet<String>();
             indexedAttributes.add( "ou" );
             indexedAttributes.add( "uid" );
             indexedAttributes.add( "objectClass" );
@@ -158,7 +158,7 @@
             doDelete( configuration.getWorkingDirectory() );
             setContextRoots( username, password, configuration );
             
-            Hashtable env = new Hashtable( configuration.toJndiEnvironment() );
+            Hashtable<String, Object> env = new Hashtable<String, Object>( configuration.toJndiEnvironment()
);
             env.put( Context.SECURITY_PRINCIPAL, username );
             env.put( Context.SECURITY_CREDENTIALS, password );
             env.put( Context.SECURITY_AUTHENTICATION, "simple" );

Added: directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerITest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerITest.java?view=auto&rev=493127
==============================================================================
--- directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerITest.java
(added)
+++ directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandlerITest.java
Fri Jan  5 10:37:42 2007
@@ -0,0 +1,553 @@
+/*
+ *  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;
+
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.ModificationItem;
+
+import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.constants.SystemSchemaConstants;
+import org.apache.directory.server.core.unit.AbstractAdminTestCase;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
+import org.apache.directory.shared.ldap.message.LockableAttributesImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.Syntax;
+import org.apache.directory.shared.ldap.schema.syntax.AcceptAllSyntaxChecker;
+import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+
+
+/**
+ * A test case which tests the addition of various schema elements
+ * to the ldap server.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$
+ */
+public class MetaSyntaxCheckerHandlerITest extends AbstractAdminTestCase
+{
+    private static final String OID = "1.3.6.1.4.1.18060.0.4.0.0.100000";
+    private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.0.100001";
+
+    
+    /**
+     * Gets relative DN to ou=schema.
+     */
+    private final LdapDN getSyntaxCheckerContainer( String schemaName ) throws NamingException
+    {
+        return new LdapDN( "ou=syntaxCheckers,cn=" + schemaName );
+    }
+    
+    
+    // ----------------------------------------------------------------------
+    // Test all core methods with normal operational pathways
+    // ----------------------------------------------------------------------
+
+    
+    public void testAddSyntaxChecker() throws NamingException
+    {
+        Attributes attrs = new LockableAttributesImpl();
+        Attribute oc = new LockableAttributeImpl( SystemSchemaConstants.OBJECT_CLASS_AT,
"top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_FQCN_AT, AcceptAllSyntaxChecker.class.getName()
);
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test syntaxChecker" );
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        super.schemaRoot.createSubcontext( dn, attrs );
+        
+        assertTrue( registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        assertEquals( registries.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta"
);
+        Class clazz = registries.getSyntaxCheckerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+    }
+    
+    
+    public void testAddSyntaxCheckerWithByteCode() throws Exception
+    {
+        InputStream in = getClass().getResourceAsStream( "DummySyntaxChecker.bytecode" );
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+        while ( in.available() > 0 )
+        {
+            out.write( in.read() );
+        }
+        
+        Attributes attrs = new LockableAttributesImpl();
+        Attribute oc = new LockableAttributeImpl( SystemSchemaConstants.OBJECT_CLASS_AT,
"top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_FQCN_AT, "DummySyntaxChecker" );
+        attrs.put( MetaSchemaConstants.M_BYTECODE_AT, out.toByteArray() );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test syntaxChecker" );
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        super.schemaRoot.createSubcontext( dn, attrs );
+        
+        assertTrue( registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        assertEquals( registries.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta"
);
+        Class clazz = registries.getSyntaxCheckerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz.getName(), "DummySyntaxChecker" );
+    }
+    
+    
+    public void testDeleteSyntaxChecker() throws NamingException
+    {
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddSyntaxChecker();
+        
+        super.schemaRoot.destroySubcontext( dn );
+
+        assertFalse( "syntaxChecker should be removed from the registry after being deleted",

+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        
+        try
+        {
+            registries.getSyntaxCheckerRegistry().lookup( OID );
+            fail( "syntaxChecker lookup should fail after deleting the syntaxChecker" );
+        }
+        catch( NamingException e )
+        {
+        }
+    }
+
+
+    public void testRenameSyntaxChecker() throws NamingException
+    {
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddSyntaxChecker();
+        
+        LdapDN newdn = getSyntaxCheckerContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        super.schemaRoot.rename( dn, newdn );
+
+        assertFalse( "old syntaxChecker OID should be removed from the registry after being
renamed", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        
+        try
+        {
+            registries.getSyntaxCheckerRegistry().lookup( OID );
+            fail( "syntaxChecker lookup should fail after deleting the syntaxChecker" );
+        }
+        catch( NamingException e )
+        {
+        }
+
+        assertTrue( registries.getSyntaxCheckerRegistry().hasSyntaxChecker( NEW_OID ) );
+        Class clazz = registries.getSyntaxCheckerRegistry().lookup( NEW_OID ).getClass();
+        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+    }
+
+
+    public void testMoveSyntaxChecker() throws NamingException
+    {
+        testAddSyntaxChecker();
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getSyntaxCheckerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertTrue( "syntaxChecker OID should still be present", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        
+        assertEquals( "syntaxChecker schema should be set to apache not apachemeta", 
+            registries.getSyntaxCheckerRegistry().getSchemaName( OID ), "apache" );
+
+        Class clazz = registries.getSyntaxCheckerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+    }
+
+
+    public void testMoveSyntaxCheckerAndChangeRdn() throws NamingException
+    {
+        testAddSyntaxChecker();
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getSyntaxCheckerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertFalse( "old syntaxChecker OID should NOT be present", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        
+        assertTrue( "new syntaxChecker OID should be present", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( NEW_OID ) );
+        
+        assertEquals( "syntaxChecker with new oid should have schema set to apache NOT apachemeta",

+            registries.getSyntaxCheckerRegistry().getSchemaName( NEW_OID ), "apache" );
+
+        Class clazz = registries.getSyntaxCheckerRegistry().lookup( NEW_OID ).getClass();
+        assertEquals( clazz, AcceptAllSyntaxChecker.class );
+    }
+
+    
+    public void testModifySyntaxCheckerWithModificationItems() throws NamingException
+    {
+        testAddSyntaxChecker();
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        ModificationItem[] mods = new ModificationItem[1];
+        Attribute attr = new LockableAttributeImpl( MetaSchemaConstants.M_FQCN_AT, BogusSyntaxChecker.class.getName()
);
+        mods[0] = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr );
+        super.schemaRoot.modifyAttributes( dn, mods );
+
+        assertTrue( "syntaxChecker OID should still be present", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        
+        assertEquals( "syntaxChecker schema should be set to apachemeta", 
+            registries.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
+
+        Class clazz = registries.getSyntaxCheckerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, BogusSyntaxChecker.class );
+    }
+
+    
+    public void testModifySyntaxCheckerWithAttributes() throws NamingException
+    {
+        testAddSyntaxChecker();
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        Attributes mods = new LockableAttributesImpl();
+        mods.put( MetaSchemaConstants.M_FQCN_AT, BogusSyntaxChecker.class.getName() );
+        super.schemaRoot.modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+
+        assertTrue( "syntaxChecker OID should still be present", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        
+        assertEquals( "syntaxChecker schema should be set to apachemeta", 
+            registries.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
+
+        Class clazz = registries.getSyntaxCheckerRegistry().lookup( OID ).getClass();
+        assertEquals( clazz, BogusSyntaxChecker.class );
+    }
+    
+
+    // ----------------------------------------------------------------------
+    // Test move, rename, and delete when a MR exists and uses the Normalizer
+    // ----------------------------------------------------------------------
+
+    
+    public void testDeleteSyntaxCheckerWhenInUse() throws NamingException
+    {
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddSyntaxChecker();
+        registries.getSyntaxRegistry().register( "apachemeta", new DummySyntax() );
+        
+        try
+        {
+            super.schemaRoot.destroySubcontext( dn );
+            fail( "should not be able to delete a syntaxChecker in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "syntaxChecker should still be in the registry after delete failure",

+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+    
+    
+    public void testMoveSyntaxCheckerWhenInUse() throws NamingException
+    {
+        testAddSyntaxChecker();
+        registries.getSyntaxRegistry().register( "apachemeta", new DummySyntax() );
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getSyntaxCheckerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            super.schemaRoot.rename( dn, newdn );
+            fail( "should not be able to move a syntaxChecker in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "syntaxChecker should still be in the registry after move failure", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+
+
+    public void testMoveSyntaxCheckerAndChangeRdnWhenInUse() throws NamingException
+    {
+        testAddSyntaxChecker();
+        registries.getSyntaxRegistry().register( "apachemeta", new DummySyntax() );
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getSyntaxCheckerContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        try
+        {
+            super.schemaRoot.rename( dn, newdn );
+            fail( "should not be able to move a syntaxChecker in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "syntaxChecker should still be in the registry after move failure", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+
+    
+    public void testRenameSyntaxCheckerWhenInUse() throws NamingException
+    {
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddSyntaxChecker();
+        registries.getSyntaxRegistry().register( "apachemeta", new DummySyntax() );
+        
+        LdapDN newdn = getSyntaxCheckerContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        try
+        {
+            super.schemaRoot.rename( dn, newdn );
+            fail( "should not be able to rename a syntaxChecker in use" );
+        }
+        catch( LdapOperationNotSupportedException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        assertTrue( "syntaxChecker should still be in the registry after rename failure",

+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+
+
+    // ----------------------------------------------------------------------
+    // Let's try some freaky stuff
+    // ----------------------------------------------------------------------
+
+
+    public void testMoveSyntaxCheckerToTop() throws NamingException
+    {
+        testAddSyntaxChecker();
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN top = new LdapDN();
+        top.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            super.schemaRoot.rename( dn, top );
+            fail( "should not be able to move a syntaxChecker up to ou=schema" );
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "syntaxChecker should still be in the registry after move failure", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+
+
+    public void testMoveSyntaxCheckerToComparatorContainer() throws NamingException
+    {
+        testAddSyntaxChecker();
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = new LdapDN( "ou=comparators,cn=apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        try
+        {
+            super.schemaRoot.rename( dn, newdn );
+            fail( "should not be able to move a syntaxChecker into comparators container"
);
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "syntaxChecker should still be in the registry after move failure", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+    
+    
+    public void testAddSyntaxCheckerToDisabledSchema() throws NamingException
+    {
+        Attributes attrs = new LockableAttributesImpl();
+        Attribute oc = new LockableAttributeImpl( SystemSchemaConstants.OBJECT_CLASS_AT,
"top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_SYNTAX_CHECKER_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_FQCN_AT, AcceptAllSyntaxChecker.class.getName()
);
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, "A test syntaxChecker" );
+        
+        // nis is by default inactive
+        LdapDN dn = getSyntaxCheckerContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        super.schemaRoot.createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new syntaxChecker to disabled schema should not register it
into the registries", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+
+
+    public void testMoveSyntaxCheckerToDisabledSchema() throws NamingException
+    {
+        testAddSyntaxChecker();
+        
+        LdapDN dn = getSyntaxCheckerContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        // nis is inactive by default
+        LdapDN newdn = getSyntaxCheckerContainer( "nis" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertFalse( "syntaxChecker OID should no longer be present", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+    }
+
+
+    public void testMoveSyntaxCheckerToEnabledSchema() throws NamingException
+    {
+        testAddSyntaxCheckerToDisabledSchema();
+        
+        // nis is inactive by default
+        LdapDN dn = getSyntaxCheckerContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        assertFalse( "syntaxChecker OID should NOT be present when added to disabled nis
schema", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+
+        LdapDN newdn = getSyntaxCheckerContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertTrue( "syntaxChecker OID should be present when moved to enabled schema", 
+            registries.getSyntaxCheckerRegistry().hasSyntaxChecker( OID ) );
+        
+        assertEquals( "syntaxChecker should be in apachemeta schema after move", 
+            registries.getSyntaxCheckerRegistry().getSchemaName( OID ), "apachemeta" );
+    }
+
+    
+    public static class BogusSyntaxChecker implements SyntaxChecker
+    {
+        public BogusSyntaxChecker()
+        {
+        }
+        
+        public void assertSyntax( Object value ) throws NamingException
+        {
+        }
+
+        public String getSyntaxOid()
+        {
+            return OID;
+        }
+
+        public boolean isValidSyntax( Object value )
+        {
+            return false;
+        }
+    }
+
+    
+    class DummySyntax implements Syntax
+    {
+        private static final long serialVersionUID = 1L;
+
+
+        public String getDescription()
+        {
+            return null;
+        }
+
+        public String getName()
+        {
+            return "dummy";
+        }
+
+        public String[] getNames()
+        {
+            return new String[] { "dummy" };
+        }
+
+        public String getOid()
+        {
+            return OID;
+        }
+
+        public boolean isObsolete()
+        {
+            return false;
+        }
+
+        public SyntaxChecker getSyntaxChecker() throws NamingException
+        {
+            return null;
+        }
+
+        public boolean isHumanReadible()
+        {
+            return false;
+        }
+    }
+}

Added: directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode?view=auto&rev=493127
==============================================================================
Binary file - no diff available.

Propchange: directory/trunks/apacheds/core-unit/src/test/resources/org/apache/directory/server/core/schema/DummySyntaxChecker.bytecode
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java?view=auto&rev=493127
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
(added)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaSyntaxCheckerHandler.java
Fri Jan  5 10:37:42 2007
@@ -0,0 +1,269 @@
+/*
+ *   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;
+
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.ModificationItem;
+
+import org.apache.directory.server.constants.MetaSchemaConstants;
+import org.apache.directory.server.core.ServerUtils;
+import org.apache.directory.server.schema.bootstrap.Schema;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.server.schema.registries.SyntaxCheckerRegistry;
+import org.apache.directory.server.schema.registries.SyntaxRegistry;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.LockableAttributeImpl;
+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.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.util.NamespaceTools;
+
+
+/**
+ * A handler for operations peformed 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 MetaSyntaxCheckerHandler implements SchemaChangeHandler
+{
+    private static final String OU_OID = "2.5.4.11";
+
+    private final PartitionSchemaLoader loader;
+    private final SchemaEntityFactory factory;
+    private final Registries targetRegistries;
+    private final SyntaxCheckerRegistry syntaxCheckerRegistry;
+    private final SyntaxRegistry syntaxRegistry;
+    private final AttributeType m_oidAT;
+
+    
+
+    public MetaSyntaxCheckerHandler( Registries targetRegistries, PartitionSchemaLoader loader
) throws NamingException
+    {
+        this.targetRegistries = targetRegistries;
+        this.loader = loader;
+        this.syntaxCheckerRegistry = targetRegistries.getSyntaxCheckerRegistry();
+        this.syntaxRegistry = targetRegistries.getSyntaxRegistry();
+        this.factory = new SchemaEntityFactory( targetRegistries );
+        this.m_oidAT = targetRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT
);
+    }
+
+
+    private String getOid( Attributes entry ) throws NamingException
+    {
+        Attribute oid = ServerUtils.getAttribute( m_oidAT, entry );
+        if ( oid == null )
+        {
+            return null;
+        }
+        return ( String ) oid.get();
+    }
+    
+    
+    private Schema getSchema( LdapDN name ) throws NamingException
+    {
+        return loader.getSchema( MetaSchemaUtils.getSchemaName( name ) );
+    }
+    
+    
+    private void modify( LdapDN name, Attributes entry, Attributes targetEntry ) throws NamingException
+    {
+        String oldOid = getOid( entry );
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, targetRegistries
);
+        Schema schema = getSchema( name );
+        
+        if ( ! schema.isDisabled() )
+        {
+            syntaxCheckerRegistry.unregister( oldOid );
+            syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
+        }
+    }
+
+
+    public void modify( LdapDN name, int modOp, Attributes mods, Attributes entry, Attributes
targetEntry )
+        throws NamingException
+    {
+        modify( name, entry, targetEntry );
+    }
+
+
+    public void modify( LdapDN name, ModificationItem[] mods, Attributes entry, Attributes
targetEntry )
+        throws NamingException
+    {
+        modify( name, entry, targetEntry );
+    }
+
+
+    public void add( LdapDN name, Attributes entry ) throws NamingException
+    {
+        LdapDN parentDn = ( LdapDN ) name.clone();
+        parentDn.remove( parentDn.size() - 1 );
+        checkNewParent( parentDn );
+        
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, targetRegistries );
+        Schema schema = getSchema( name );
+        
+        if ( ! schema.isDisabled() )
+        {
+            syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
+        }
+    }
+
+
+    public void delete( LdapDN name, Attributes entry ) throws NamingException
+    {
+        String oid = getOid( entry );
+        if ( syntaxRegistry.hasSyntax( oid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The syntaxChecker with OID " +
oid 
+                + " cannot be deleted until all " 
+                + "syntaxes using this syntaxChecker have also been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        Schema schema = getSchema( name );
+        
+        if ( ! schema.isDisabled() )
+        {
+            syntaxCheckerRegistry.unregister( getOid( entry ) );
+        }
+    }
+
+
+    public void rename( LdapDN name, Attributes entry, String newRdn ) throws NamingException
+    {
+        String oldOid = getOid( entry );
+
+        if ( syntaxRegistry.hasSyntax( oldOid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The syntaxChecker with OID " +
oldOid 
+                + " cannot have it's OID changed until all " 
+                + "syntaxes using that syntaxChecker have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        Schema schema = getSchema( name );
+        Attributes targetEntry = ( Attributes ) entry.clone();
+        String newOid = NamespaceTools.getRdnValue( newRdn );
+        targetEntry.put( new LockableAttributeImpl( MetaSchemaConstants.M_OID_AT, newOid
) );
+        if ( ! schema.isDisabled() )
+        {
+            SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, targetRegistries
);
+            syntaxCheckerRegistry.unregister( oldOid );
+            syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
+        }
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, String newRn, boolean deleteOldRn,
Attributes entry ) 
+        throws NamingException
+    {
+        checkNewParent( newParentName );
+        String oldOid = getOid( entry );
+
+        if ( syntaxRegistry.hasSyntax( oldOid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The syntaxChecker with OID " +
oldOid 
+                + " cannot have it's OID changed until all " 
+                + "syntaxes using that syntaxChecker have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        Schema oldSchema = getSchema( oriChildName );
+        Schema newSchema = getSchema( newParentName );
+        Attributes targetEntry = ( Attributes ) entry.clone();
+        String newOid = NamespaceTools.getRdnValue( newRn );
+        targetEntry.put( new LockableAttributeImpl( MetaSchemaConstants.M_OID_AT, newOid
) );
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( targetEntry, targetRegistries
);
+
+        if ( ! oldSchema.isDisabled() )
+        {
+            syntaxCheckerRegistry.unregister( oldOid );
+        }
+
+        if ( ! newSchema.isDisabled() )
+        {
+            syntaxCheckerRegistry.register( newSchema.getSchemaName(), syntaxChecker );
+        }
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Attributes entry ) 
+        throws NamingException
+    {
+        checkNewParent( newParentName );
+        String oid = getOid( entry );
+
+        if ( syntaxRegistry.hasSyntax( oid ) )
+        {
+            throw new LdapOperationNotSupportedException( "The syntaxChecker with OID " +
oid 
+                + " cannot be moved to another schema until all " 
+                + "syntax using that syntaxChecker have been deleted.", 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        Schema oldSchema = getSchema( oriChildName );
+        Schema newSchema = getSchema( newParentName );
+        
+        SyntaxChecker syntaxChecker = factory.getSyntaxChecker( entry, targetRegistries );
+        
+        if ( ! oldSchema.isDisabled() )
+        {
+            syntaxCheckerRegistry.unregister( oid );
+        }
+        
+        if ( ! newSchema.isDisabled() )
+        {
+            syntaxCheckerRegistry.register( newSchema.getSchemaName(), syntaxChecker );
+        }
+    }
+    
+    
+    private void checkNewParent( LdapDN newParent ) throws NamingException
+    {
+        if ( newParent.size() != 3 )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent dn of a syntaxChecker should be at most 3 name components in
length.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        Rdn rdn = newParent.getRdn();
+        if ( ! targetRegistries.getOidRegistry().getOid( rdn.getType() ).equals( OU_OID )
)
+        {
+            throw new LdapInvalidNameException( "The parent entry of a syntaxChecker should
be an organizationalUnit.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( "syntaxCheckers" ) )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent entry of a normalizer should have a relative name of ou=syntaxCheckers.",

+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+    }
+}

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java?view=diff&rev=493127&r1=493126&r2=493127
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/PartitionSchemaLoader.java
Fri Jan  5 10:37:42 2007
@@ -330,7 +330,7 @@
             resultDN.normalize( attrRegistry.getNormalizerMapping() );
             Attributes attrs = partition.lookup( resultDN );
             SyntaxChecker sc = factory.getSyntaxChecker( attrs, targetRegistries );
-            targetRegistries.getSyntaxCheckerRegistry().register( schema.getSchemaName(),
sc.getSyntaxOid(), sc );
+            targetRegistries.getSyntaxCheckerRegistry().register( schema.getSchemaName(),
sc );
         }
     }
 

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java?view=diff&rev=493127&r1=493126&r2=493127
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaEntityFactory.java
Fri Jan  5 10:37:42 2007
@@ -161,6 +161,8 @@
         {
             try
             {
+                Attribute bytecode = AttributeUtils.getAttribute( entry, byteCodeAT );
+                classLoader.setAttribute( bytecode );
                 clazz = classLoader.loadClass( className );
             }
             catch ( ClassCastException e )

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java?view=diff&rev=493127&r1=493126&r2=493127
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
(original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
Fri Jan  5 10:37:42 2007
@@ -56,6 +56,7 @@
     private final AttributeType objectClassAT;
     private final MetaComparatorHandler metaComparatorHandler;
     private final MetaNormalizerHandler metaNormalizerHandler;
+    private final MetaSyntaxCheckerHandler metaSyntaxCheckerHandler;
     
 
     public SchemaManager( Registries globalRegistries, PartitionSchemaLoader loader ) throws
NamingException
@@ -67,6 +68,7 @@
         this.metaSchemaHandler = new MetaSchemaHandler( this.globalRegistries, this.loader
);
         this.metaComparatorHandler = new MetaComparatorHandler( globalRegistries, loader
);
         this.metaNormalizerHandler = new MetaNormalizerHandler( globalRegistries, loader
);
+        this.metaSyntaxCheckerHandler = new MetaSyntaxCheckerHandler( globalRegistries, loader
);
     }
     
     
@@ -104,6 +106,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_CHECKER_OC,
objectClassAT ) )
+        {
+            metaSyntaxCheckerHandler.add( name, entry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed
at this time" );
     }
     
@@ -130,6 +138,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_CHECKER_OC,
objectClassAT ) )
+        {
+            metaSyntaxCheckerHandler.delete( name, entry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed
at this time" );
     }
     
@@ -157,6 +171,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_CHECKER_OC,
objectClassAT ) )
+        {
+            metaSyntaxCheckerHandler.modify( name, modOp, mods, entry, targetEntry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed
at this time" );
     }
 
@@ -184,6 +204,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_CHECKER_OC,
objectClassAT ) )
+        {
+            metaSyntaxCheckerHandler.modify( name, mods, entry, targetEntry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed
at this time" );
     }
 
@@ -210,6 +236,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_CHECKER_OC,
objectClassAT ) )
+        {
+            metaSyntaxCheckerHandler.rename( name, entry, newRdn );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed
at this time" );
     }
 
@@ -236,6 +268,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_CHECKER_OC,
objectClassAT ) )
+        {
+            metaSyntaxCheckerHandler.move( oriChildName, newParentName, entry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed
at this time" );
     }
 
@@ -260,6 +298,12 @@
         if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_NORMALIZER_OC, objectClassAT
) )
         {
             metaNormalizerHandler.move( oriChildName, newParentName, newRn, deleteOldRn,
entry );
+            return;
+        }
+
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_CHECKER_OC,
objectClassAT ) )
+        {
+            metaSyntaxCheckerHandler.move( oriChildName, newParentName, newRn, deleteOldRn,
entry );
             return;
         }
 

Modified: directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java?view=diff&rev=493127&r1=493126&r2=493127
==============================================================================
--- directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
(original)
+++ directory/trunks/apacheds/schema-bootstrap/src/main/java/org/apache/directory/server/schema/bootstrap/BootstrapSchemaLoader.java
Fri Jan  5 10:37:42 2007
@@ -223,7 +223,7 @@
                 SyntaxChecker syntaxChecker = ( SyntaxChecker ) schemaObject;
                 SyntaxCheckerRegistry syntaxCheckerRegistry;
                 syntaxCheckerRegistry = registries.getSyntaxCheckerRegistry();
-                syntaxCheckerRegistry.register( schema.getSchemaName(), id, syntaxChecker
);
+                syntaxCheckerRegistry.register( schema.getSchemaName(), syntaxChecker );
                 break;
                 
             case SYNTAX_PRODUCER :

Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java?view=diff&rev=493127&r1=493126&r2=493127
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java
(original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultSyntaxCheckerRegistry.java
Fri Jan  5 10:37:42 2007
@@ -66,19 +66,20 @@
     // ------------------------------------------------------------------------
 
     
-    public void register( String schema, String oid, SyntaxChecker syntaxChecker ) throws
NamingException
+    public void register( String schema, SyntaxChecker syntaxChecker ) throws NamingException
     {
-        if ( byOid.containsKey( oid ) )
+        if ( byOid.containsKey( syntaxChecker.getSyntaxOid() ) )
         {
-            NamingException e = new NamingException( "SyntaxChecker with OID " + oid + "
already registered!" );
+            NamingException e = new NamingException( "SyntaxChecker with OID " + syntaxChecker.getSyntaxOid()

+                + " already registered!" );
             throw e;
         }
 
-        byOid.put( oid, syntaxChecker );
-        oidToSchema.put( oid, schema );
+        byOid.put( syntaxChecker.getSyntaxOid(), syntaxChecker );
+        oidToSchema.put( syntaxChecker.getSyntaxOid(), schema );
         if ( log.isDebugEnabled() )
         {
-            log.debug( "registered syntaxChecher for OID " + oid );
+            log.debug( "registered syntaxChecher for OID " + syntaxChecker.getSyntaxOid()
);
         }
     }
 
@@ -125,5 +126,17 @@
     public Iterator<SyntaxChecker> iterator()
     {
         return byOid.values().iterator();
+    }
+
+
+    public void unregister( String numericOid ) throws NamingException
+    {
+        if ( ! Character.isDigit( numericOid.charAt( 0 ) ) )
+        {
+            throw new NamingException( "Looks like the arg is not a numeric OID" );
+        }
+
+        byOid.remove( numericOid );
+        oidToSchema.remove( numericOid );
     }
 }

Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java?view=diff&rev=493127&r1=493126&r2=493127
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java
(original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/SyntaxCheckerRegistry.java
Fri Jan  5 10:37:42 2007
@@ -43,7 +43,7 @@
      * @throws NamingException if the SyntaxChecker is already registered or the
      *      registration operation is not supported
      */
-    void register( String schema, String oid, SyntaxChecker syntaxChecker ) throws NamingException;
+    void register( String schema, SyntaxChecker syntaxChecker ) throws NamingException;
 
 
     /**
@@ -77,10 +77,20 @@
      */
     boolean hasSyntaxChecker( String oid );
     
+
     /**
      * Get's an iterator over all the syntaxCheckers associated with this registry.
      * 
      * @return an Iterator over all the syntaxCheckers
      */
     Iterator<SyntaxChecker> iterator();
+
+
+    /**
+     * Unregisters a registered syntaxChecker from this registry.
+     * 
+     * @param numericOid the numeric oid of the syntax this checker is associated with
+     * @throws NamingException if the numericOid is not valid
+     */
+    void unregister( String numericOid ) throws NamingException;
 }



Mime
View raw message