directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r495051 - in /directory/trunks/apacheds: constants/src/main/java/org/apache/directory/server/constants/ core-unit/src/test/java/org/apache/directory/server/core/schema/ core/src/main/java/org/apache/directory/server/core/schema/ schema-regi...
Date Thu, 11 Jan 2007 00:01:55 GMT
Author: akarasulu
Date: Wed Jan 10 16:01:54 2007
New Revision: 495051

URL: http://svn.apache.org/viewvc?view=rev&rev=495051
Log:
added code to handle updates to meta schema object under ou=schema: specifically for objectClasses

Added:
    directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerITest.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
Modified:
    directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/MetaSchemaConstants.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaManager.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
    directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AttributeTypeRegistry.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultAttributeTypeRegistry.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java
    directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ObjectClassRegistry.java

Modified: directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/MetaSchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/MetaSchemaConstants.java?view=diff&rev=495051&r1=495050&r2=495051
==============================================================================
--- directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/MetaSchemaConstants.java (original)
+++ directory/trunks/apacheds/constants/src/main/java/org/apache/directory/server/constants/MetaSchemaConstants.java Wed Jan 10 16:01:54 2007
@@ -37,6 +37,8 @@
     public static final String META_SYNTAX_OC = "metaSyntax";
     public static final String META_SYNTAX_CHECKER_OC = "metaSyntaxChecker";
     public static final String META_COMPARATOR_OC = "metaComparator";
+    public static final String META_NAME_FORM_OC = "metaNameForm";
+    public static final String META_DIT_CONTENT_RULE_OC = "metaDITContentRule";
 
     public static final String M_SUP_OBJECT_CLASS_AT = "m-supObjectClass";
     public static final String M_BYTECODE_AT = "m-bytecode";
@@ -48,6 +50,8 @@
     public static final String M_OBSOLETE_AT = "m-obsolete";
     public static final String M_NAME_AT = "m-name";
     public static final String M_OID_AT = "m-oid";
+    public static final String M_OC_AT = "m-oc";
+    public static final String M_AUX_AT = "m-aux";
     public static final String M_USAGE_AT = "m-usage";
     public static final String M_NO_USER_MODIFICATION_AT = "m-noUserModification";
     public static final String M_SINGLE_VALUE_AT = "m-singleValue";
@@ -60,5 +64,6 @@
     public static final String M_MUST_AT = "m-must";
     public static final String M_MAY_AT = "m-may";
     public static final String M_TYPE_OBJECT_CLASS_AT = "m-typeObjectClass";
+    
     public static final String X_HUMAN_READIBLE_AT = "x-humanReadible";
 }

Added: directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerITest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerITest.java?view=auto&rev=495051
==============================================================================
--- directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerITest.java (added)
+++ directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaObjectClassHandlerITest.java Wed Jan 10 16:01:54 2007
@@ -0,0 +1,476 @@
+/*
+ *  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.DirContext;
+
+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.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.AttributesImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+
+
+/**
+ * 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 MetaObjectClassHandlerITest extends AbstractAdminTestCase
+{
+    private static final String NAME = "testObjectClass";
+    private static final String NEW_NAME = "alternateName";
+
+    private static final String DESCRIPTION0 = "A test objectClass";
+    private static final String DESCRIPTION1 = "An alternate description";
+    
+    private static final String OID = "1.3.6.1.4.1.18060.0.4.0.3.100000";
+    private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.3.100001";
+
+    
+    /**
+     * Gets relative DN to ou=schema.
+     */
+    private final LdapDN getObjectClassContainer( String schemaName ) throws NamingException
+    {
+        return new LdapDN( "ou=objectClasses,cn=" + schemaName );
+    }
+    
+    
+    // ----------------------------------------------------------------------
+    // Test all core methods with normal operational pathways
+    // ----------------------------------------------------------------------
+
+    
+    public void testAddObjectClass() throws NamingException
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_NAME_AT, NAME);
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+        attrs.put( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT, "AUXILIARY" );
+        attrs.put( MetaSchemaConstants.M_MUST_AT, "cn" );
+        attrs.put( MetaSchemaConstants.M_MAY_AT, "ou" );
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        super.schemaRoot.createSubcontext( dn, attrs );
+        
+        assertTrue( registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        assertEquals( registries.getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+    }
+    
+    
+    public void testDeleteAttributeType() throws NamingException
+    {
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddObjectClass();
+        
+        super.schemaRoot.destroySubcontext( dn );
+
+        assertFalse( "objectClass should be removed from the registry after being deleted", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        try
+        {
+            registries.getObjectClassRegistry().lookup( OID );
+            fail( "objectClass lookup should fail after deleting it" );
+        }
+        catch( NamingException e )
+        {
+        }
+    }
+
+
+    public void testRenameAttributeType() throws NamingException
+    {
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        testAddObjectClass();
+        
+        LdapDN newdn = getObjectClassContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        super.schemaRoot.rename( dn, newdn );
+
+        assertFalse( "old objectClass OID should be removed from the registry after being renamed", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        try
+        {
+            registries.getObjectClassRegistry().lookup( OID );
+            fail( "objectClass lookup should fail after renaming the objectClass" );
+        }
+        catch( NamingException e )
+        {
+        }
+
+        assertTrue( registries.getObjectClassRegistry().hasObjectClass( NEW_OID ) );
+    }
+
+
+    public void testMoveAttributeType() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getObjectClassContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertTrue( "objectClass OID should still be present", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass schema should be set to apache not apachemeta", 
+            registries.getObjectClassRegistry().getSchemaName( OID ), "apache" );
+    }
+
+
+    public void testMoveObjectClassAndChangeRdn() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        LdapDN newdn = getObjectClassContainer( "apache" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertFalse( "old objectClass OID should NOT be present", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertTrue( "new objectClass OID should be present", 
+            registries.getObjectClassRegistry().hasObjectClass( NEW_OID ) );
+        
+        assertEquals( "objectClass with new oid should have schema set to apache NOT apachemeta", 
+            registries.getObjectClassRegistry().getSchemaName( NEW_OID ), "apache" );
+    }
+
+    
+    public void testModifyAttributeTypeWithModificationItems() throws NamingException
+    {
+        testAddObjectClass();
+        
+        ObjectClass oc = registries.getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION0 );
+        assertEquals( oc.getName(), NAME );
+
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        ModificationItemImpl[] mods = new ModificationItemImpl[2];
+        Attribute attr = new AttributeImpl( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
+        mods[0] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        attr = new AttributeImpl( MetaSchemaConstants.M_NAME_AT, NEW_NAME );
+        mods[1] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+        super.schemaRoot.modifyAttributes( dn, mods );
+
+        assertTrue( "objectClass OID should still be present", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass schema should be set to apachemeta", 
+            registries.getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+        
+        oc = registries.getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION1 );
+        assertEquals( oc.getName(), NEW_NAME );
+    }
+
+    
+    public void testModifyAttributeTypeWithAttributes() throws NamingException
+    {
+        testAddObjectClass();
+        
+        ObjectClass oc = registries.getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION0 );
+        assertEquals( oc.getName(), NAME );
+
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        Attributes mods = new AttributesImpl();
+        mods.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
+        mods.put( MetaSchemaConstants.M_NAME_AT, NEW_NAME );
+        super.schemaRoot.modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+
+        assertTrue( "objectClass OID should still be present", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass schema should be set to apachemeta", 
+            registries.getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+
+        oc = registries.getObjectClassRegistry().lookup( OID );
+        assertEquals( oc.getDescription(), DESCRIPTION1 );
+        assertEquals( oc.getName(), NEW_NAME );
+    }
+    
+
+    // ----------------------------------------------------------------------
+    // Test move, rename, and delete when a MR exists and uses the Normalizer
+    // ----------------------------------------------------------------------
+
+    
+//    public void testDeleteSyntaxWhenInUse() throws NamingException
+//    {
+//        LdapDN dn = getSyntaxContainer( "apachemeta" );
+//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//        testAddSyntax();
+//        addDependeeMatchingRule();
+//        
+//        try
+//        {
+//            super.schemaRoot.destroySubcontext( dn );
+//            fail( "should not be able to delete a syntax in use" );
+//        }
+//        catch( LdapOperationNotSupportedException e ) 
+//        {
+//            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+//        }
+//
+//        assertTrue( "syntax should still be in the registry after delete failure", 
+//            registries.getSyntaxRegistry().hasSyntax( OID ) );
+//    }
+//    
+//    
+//    public void testMoveSyntaxWhenInUse() throws NamingException
+//    {
+//        testAddSyntax();
+//        addDependeeMatchingRule();
+//        
+//        LdapDN dn = getSyntaxContainer( "apachemeta" );
+//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//
+//        LdapDN newdn = getSyntaxContainer( "apache" );
+//        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//        
+//        try
+//        {
+//            super.schemaRoot.rename( dn, newdn );
+//            fail( "should not be able to move a syntax in use" );
+//        }
+//        catch( LdapOperationNotSupportedException e ) 
+//        {
+//            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+//        }
+//
+//        assertTrue( "syntax should still be in the registry after move failure", 
+//            registries.getSyntaxRegistry().hasSyntax( OID ) );
+//    }
+//
+//
+//    public void testMoveSyntaxAndChangeRdnWhenInUse() throws NamingException
+//    {
+//        testAddSyntax();
+//        addDependeeMatchingRule()
+//        
+//        LdapDN dn = getSyntaxContainer( "apachemeta" );
+//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//
+//        LdapDN newdn = getSyntaxContainer( "apache" );
+//        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+//        
+//        try
+//        {
+//            super.schemaRoot.rename( dn, newdn );
+//            fail( "should not be able to move a syntax in use" );
+//        }
+//        catch( LdapOperationNotSupportedException e ) 
+//        {
+//            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+//        }
+//
+//        assertTrue( "syntax should still be in the registry after move failure", 
+//            registries.getSyntaxRegistry().hasSyntax( OID ) );
+//    }
+//
+//    
+
+    // Need to add body to this method which creates a new matchingRule after 
+    // the matchingRule addition code has been added.
+    
+//    private void addDependeeMatchingRule()
+//    {
+//        throw new NotImplementedException();
+//    }
+//    
+//    public void testRenameNormalizerWhenInUse() throws NamingException
+//    {
+//        LdapDN dn = getSyntaxContainer( "apachemeta" );
+//        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+//        testAddSyntax();
+//        addDependeeMatchingRule();
+//        
+//        LdapDN newdn = getSyntaxContainer( "apachemeta" );
+//        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+//        
+//        try
+//        {
+//            super.schemaRoot.rename( dn, newdn );
+//            fail( "should not be able to rename a syntax in use" );
+//        }
+//        catch( LdapOperationNotSupportedException e ) 
+//        {
+//            assertEquals( e.getResultCode(), ResultCodeEnum.UNWILLING_TO_PERFORM );
+//        }
+//
+//        assertTrue( "syntax should still be in the registry after rename failure", 
+//            registries.getSyntaxRegistry().hasSyntax( OID ) );
+//    }
+
+
+    // ----------------------------------------------------------------------
+    // Let's try some freaky stuff
+    // ----------------------------------------------------------------------
+
+
+    public void testMoveObjectClassToTop() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "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 objectClass up to ou=schema" );
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "objectClass should still be in the registry after move failure", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    public void testMoveObjectClassToComparatorContainer() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "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 objectClass into comparators container" );
+        }
+        catch( LdapInvalidNameException e ) 
+        {
+            assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+        }
+
+        assertTrue( "objectClass should still be in the registry after move failure", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+    
+    
+    public void testAddObjectClassToDisabledSchema() throws NamingException
+    {
+        Attributes attrs = new AttributesImpl();
+        Attribute oc = new AttributeImpl( SystemSchemaConstants.OBJECT_CLASS_AT, "top" );
+        oc.add( MetaSchemaConstants.META_TOP_OC );
+        oc.add( MetaSchemaConstants.META_OBJECT_CLASS_OC );
+        attrs.put( oc );
+        attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+        attrs.put( MetaSchemaConstants.M_NAME_AT, NAME);
+        attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+        attrs.put( MetaSchemaConstants.M_TYPE_OBJECT_CLASS_AT, "AUXILIARY" );
+        attrs.put( MetaSchemaConstants.M_MUST_AT, "cn" );
+        attrs.put( MetaSchemaConstants.M_MAY_AT, "ou" );
+        
+        LdapDN dn = getObjectClassContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        super.schemaRoot.createSubcontext( dn, attrs );
+        
+        assertFalse( "adding new objectClass to disabled schema should not register it into the registries", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    public void testMoveObjectClassToDisabledSchema() throws NamingException
+    {
+        testAddObjectClass();
+        
+        LdapDN dn = getObjectClassContainer( "apachemeta" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        // nis is inactive by default
+        LdapDN newdn = getObjectClassContainer( "nis" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertFalse( "objectClass OID should no longer be present", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+    }
+
+
+    public void testMoveObjectClassToEnabledSchema() throws NamingException
+    {
+        testAddObjectClassToDisabledSchema();
+        
+        // nis is inactive by default
+        LdapDN dn = getObjectClassContainer( "nis" );
+        dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+        assertFalse( "objectClass OID should NOT be present when added to disabled nis schema", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+
+        LdapDN newdn = getObjectClassContainer( "apachemeta" );
+        newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+        
+        super.schemaRoot.rename( dn, newdn );
+
+        assertTrue( "objectClass OID should be present when moved to enabled schema", 
+            registries.getObjectClassRegistry().hasObjectClass( OID ) );
+        
+        assertEquals( "objectClass should be in apachemeta schema after move", 
+            registries.getObjectClassRegistry().getSchemaName( OID ), "apachemeta" );
+    }
+}

Added: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java?view=auto&rev=495051
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java (added)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaObjectClassHandler.java Wed Jan 10 16:01:54 2007
@@ -0,0 +1,292 @@
+/*
+ *   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.util.HashSet;
+import java.util.Set;
+
+import javax.naming.NamingException;
+import javax.naming.directory.Attribute;
+import javax.naming.directory.Attributes;
+import javax.naming.directory.SearchResult;
+
+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.ObjectClassRegistry;
+import org.apache.directory.server.schema.registries.Registries;
+import org.apache.directory.shared.ldap.exception.LdapInvalidNameException;
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.AttributeImpl;
+import org.apache.directory.shared.ldap.message.ModificationItemImpl;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.name.LdapDN;
+import org.apache.directory.shared.ldap.name.Rdn;
+import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.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 MetaObjectClassHandler implements SchemaChangeHandler
+{
+    private static final String OU_OID = "2.5.4.11";
+
+    private final PartitionSchemaLoader loader;
+    private final SchemaPartitionDao dao;
+    private final SchemaEntityFactory factory;
+    private final Registries targetRegistries;
+    private final ObjectClassRegistry objectClassRegistry;
+    private final AttributeType m_oidAT;
+
+
+    public MetaObjectClassHandler( Registries targetRegistries, PartitionSchemaLoader loader, SchemaPartitionDao dao ) 
+        throws NamingException
+    {
+        this.targetRegistries = targetRegistries;
+        this.dao = dao;
+        this.loader = loader;
+        this.objectClassRegistry = targetRegistries.getObjectClassRegistry();
+        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 );
+        ObjectClass oc = factory.getObjectClass( targetEntry, targetRegistries );
+        Schema schema = getSchema( name );
+
+        if ( ! schema.isDisabled() )
+        {
+            objectClassRegistry.unregister( oldOid );
+            objectClassRegistry.register( schema.getSchemaName(), oc );
+        }
+    }
+
+
+    public void modify( LdapDN name, int modOp, Attributes mods, Attributes entry, Attributes targetEntry )
+        throws NamingException
+    {
+        modify( name, entry, targetEntry );
+    }
+
+
+    public void modify( LdapDN name, ModificationItemImpl[] 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 );
+        
+        ObjectClass oc = factory.getObjectClass( entry, targetRegistries );
+        Schema schema = getSchema( name );
+        
+        if ( ! schema.isDisabled() )
+        {
+            objectClassRegistry.register( schema.getSchemaName(), oc );
+        }
+    }
+
+
+    private Set<String> getOids( Set<SearchResult> results ) throws NamingException
+    {
+        Set<String> oids = new HashSet<String>( results.size() );
+        
+        for ( SearchResult result : results )
+        {
+            LdapDN dn = new LdapDN( result.getName() );
+            dn.normalize( this.targetRegistries.getAttributeTypeRegistry().getNormalizerMapping() );
+            oids.add( ( String ) dn.getRdn().getValue() );
+        }
+        
+        return oids;
+    }
+    
+    
+    public void delete( LdapDN name, Attributes entry ) throws NamingException
+    {
+        ObjectClass oc = factory.getObjectClass( entry, targetRegistries );
+        Set<SearchResult> dependees = dao.listObjectClassDependees( oc );
+        if ( dependees != null && dependees.size() > 0 )
+        {
+            throw new LdapOperationNotSupportedException( "The objectClass with OID " + oc.getOid() 
+                + " cannot be deleted until all entities" 
+                + " using this objectClass have also been deleted.  The following dependees exist: " 
+                + getOids( dependees ), 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+        
+        Schema schema = getSchema( name );
+        
+        if ( ! schema.isDisabled() )
+        {
+            objectClassRegistry.unregister( oc.getOid() );
+        }
+    }
+
+
+    public void rename( LdapDN name, Attributes entry, String newRdn ) throws NamingException
+    {
+        ObjectClass oldOc = factory.getObjectClass( entry, targetRegistries );
+        Set<SearchResult> dependees = dao.listObjectClassDependees( oldOc );
+        if ( dependees != null && dependees.size() > 0 )
+        {
+            throw new LdapOperationNotSupportedException( "The objectClass with OID " + oldOc.getOid()
+                + " cannot be deleted until all entities" 
+                + " using this objectClass have also been deleted.  The following dependees exist: " 
+                + getOids( dependees ), 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        Schema schema = getSchema( name );
+        Attributes targetEntry = ( Attributes ) entry.clone();
+        String newOid = NamespaceTools.getRdnValue( newRdn );
+        targetEntry.put( new AttributeImpl( MetaSchemaConstants.M_OID_AT, newOid ) );
+        if ( ! schema.isDisabled() )
+        {
+            ObjectClass oc = factory.getObjectClass( targetEntry, targetRegistries );
+            objectClassRegistry.unregister( oldOc.getOid() );
+            objectClassRegistry.register( schema.getSchemaName(), oc );
+        }
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, String newRn, boolean deleteOldRn, Attributes entry ) 
+        throws NamingException
+    {
+        checkNewParent( newParentName );
+        ObjectClass oldOc = factory.getObjectClass( entry, targetRegistries );
+        Set<SearchResult> dependees = dao.listObjectClassDependees( oldOc );
+        if ( dependees != null && dependees.size() > 0 )
+        {
+            throw new LdapOperationNotSupportedException( "The objectClass with OID " + oldOc.getOid()
+                + " cannot be deleted until all entities" 
+                + " using this objectClass have also been deleted.  The following dependees exist: " 
+                + getOids( dependees ), 
+                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 AttributeImpl( MetaSchemaConstants.M_OID_AT, newOid ) );
+        ObjectClass at = factory.getObjectClass( targetEntry, targetRegistries );
+
+        if ( ! oldSchema.isDisabled() )
+        {
+            objectClassRegistry.unregister( oldOc.getOid() );
+        }
+
+        if ( ! newSchema.isDisabled() )
+        {
+            objectClassRegistry.register( newSchema.getSchemaName(), at );
+        }
+    }
+
+
+    public void move( LdapDN oriChildName, LdapDN newParentName, Attributes entry ) 
+        throws NamingException
+    {
+        checkNewParent( newParentName );
+        ObjectClass oldAt = factory.getObjectClass( entry, targetRegistries );
+        Set<SearchResult> dependees = dao.listObjectClassDependees( oldAt );
+        if ( dependees != null && dependees.size() > 0 )
+        {
+            throw new LdapOperationNotSupportedException( "The objectClass with OID " + oldAt.getOid() 
+                + " cannot be deleted until all entities" 
+                + " using this objectClass have also been deleted.  The following dependees exist: " 
+                + getOids( dependees ), 
+                ResultCodeEnum.UNWILLING_TO_PERFORM );
+        }
+
+        Schema oldSchema = getSchema( oriChildName );
+        Schema newSchema = getSchema( newParentName );
+        
+        ObjectClass oc = factory.getObjectClass( entry, targetRegistries );
+        
+        if ( ! oldSchema.isDisabled() )
+        {
+            objectClassRegistry.unregister( oldAt.getOid() );
+        }
+        
+        if ( ! newSchema.isDisabled() )
+        {
+            objectClassRegistry.register( newSchema.getSchemaName(), oc );
+        }
+    }
+    
+    
+    private void checkNewParent( LdapDN newParent ) throws NamingException
+    {
+        if ( newParent.size() != 3 )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent dn of a objectClass 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 objectClass should be an organizationalUnit.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+        
+        if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( "objectClasses" ) )
+        {
+            throw new LdapInvalidNameException( 
+                "The parent entry of a attributeType should have a relative name of ou=objectClasses.", 
+                ResultCodeEnum.NAMING_VIOLATION );
+        }
+    }
+}

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=495051&r1=495050&r2=495051
==============================================================================
--- 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 Wed Jan 10 16:01:54 2007
@@ -60,7 +60,8 @@
     private final MetaSyntaxHandler metaSyntaxHandler;
     private final MetaMatchingRuleHandler metaMatchingRuleHandler;
     private final MetaAttributeTypeHandler metaAttributeTypeHandler;
-    
+    private final MetaObjectClassHandler metaObjectClassHandler;
+
 
     public SchemaManager( Registries globalRegistries, PartitionSchemaLoader loader, SchemaPartitionDao dao ) 
         throws NamingException
@@ -76,6 +77,7 @@
         this.metaSyntaxHandler = new MetaSyntaxHandler( globalRegistries, loader, dao );
         this.metaMatchingRuleHandler = new MetaMatchingRuleHandler( globalRegistries, loader, dao );
         this.metaAttributeTypeHandler = new MetaAttributeTypeHandler( globalRegistries, loader, dao );
+        this.metaObjectClassHandler = new MetaObjectClassHandler( globalRegistries, loader, dao );
     }
     
     
@@ -130,13 +132,19 @@
             metaMatchingRuleHandler.add( name, entry );
             return;
         }
-
+        
         if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC, objectClassAT ) )
         {
             metaAttributeTypeHandler.add( name, entry );
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_OBJECT_CLASS_OC, objectClassAT ) )
+        {
+            metaObjectClassHandler.add( name, entry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
     }
     
@@ -187,6 +195,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_OBJECT_CLASS_OC, objectClassAT ) )
+        {
+            metaObjectClassHandler.delete( name, entry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
     }
     
@@ -238,6 +252,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_OBJECT_CLASS_OC, objectClassAT ) )
+        {
+            metaObjectClassHandler.modify( name, modOp, mods, entry, targetEntry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
     }
 
@@ -289,6 +309,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_OBJECT_CLASS_OC, objectClassAT ) )
+        {
+            metaObjectClassHandler.modify( name, mods, entry, targetEntry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
     }
 
@@ -339,6 +365,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_OBJECT_CLASS_OC, objectClassAT ) )
+        {
+            metaObjectClassHandler.rename( name, entry, newRdn );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
     }
 
@@ -389,6 +421,12 @@
             return;
         }
 
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_OBJECT_CLASS_OC, objectClassAT ) )
+        {
+            metaObjectClassHandler.move( oriChildName, newParentName, entry );
+            return;
+        }
+
         throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
     }
 
@@ -437,6 +475,12 @@
         if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC, objectClassAT ) )
         {
             metaAttributeTypeHandler.move( oriChildName, newParentName, newRn, deleteOldRn, entry );
+            return;
+        }
+
+        if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_OBJECT_CLASS_OC, objectClassAT ) )
+        {
+            metaObjectClassHandler.move( oriChildName, newParentName, newRn, deleteOldRn, entry );
             return;
         }
 

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?view=diff&rev=495051&r1=495050&r2=495051
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java Wed Jan 10 16:01:54 2007
@@ -53,6 +53,7 @@
 import org.apache.directory.shared.ldap.name.Rdn;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
 import org.apache.directory.shared.ldap.schema.syntax.NumericOidSyntaxChecker;
 
 import org.slf4j.Logger;
@@ -90,6 +91,9 @@
     private final String M_SUP_ATTRIBUTE_TYPE_OID;
     private final String M_MUST_OID;
     private final String M_MAY_OID;
+    private final String M_AUX_OID;
+    private final String M_OC_OID;
+    private final String M_SUP_OBJECT_CLASS_OID;
     
     private final AttributeType disabledAttributeType;
     
@@ -120,6 +124,9 @@
         this.M_SUP_ATTRIBUTE_TYPE_OID = oidRegistry.getOid( MetaSchemaConstants.M_SUP_ATTRIBUTE_TYPE_AT );
         this.M_MUST_OID = oidRegistry.getOid( MetaSchemaConstants.M_MUST_AT );
         this.M_MAY_OID = oidRegistry.getOid( MetaSchemaConstants.M_MAY_AT );
+        this.M_AUX_OID = oidRegistry.getOid( MetaSchemaConstants.M_AUX_AT );
+        this.M_OC_OID = oidRegistry.getOid( MetaSchemaConstants.M_OC_AT );
+        this.M_SUP_OBJECT_CLASS_OID = oidRegistry.getOid( MetaSchemaConstants.M_SUP_OBJECT_CLASS_AT );
     }
 
 
@@ -452,6 +459,24 @@
 
     public Set<SearchResult> listAttributeTypeDependees( AttributeType at ) throws NamingException
     {
+        /*
+         * Right now the following inefficient filter is being used:
+         * 
+         * ( & 
+         *      ( | ( objectClass = metaAttributeType ) ( objectClass = metaObjectClass ) )
+         *      ( | ( m-oid = $oid ) ( m-must = $oid ) ( m-supAttributeType = $oid ) )
+         * )
+         * 
+         * the reason why this is inefficient is because the or terms have large scan counts
+         * and several loops are going to be required.  The following search is better because
+         * it constrains the results better:
+         * 
+         * ( |
+         *      ( & ( objectClass = metaAttributeType ) ( m-supAttributeType = $oid ) )
+         *      ( & ( objectClass = metaObjectClass ) ( | ( m-may = $oid ) ( m-must = $oid ) ) )
+         * )
+         */
+        
         Set<SearchResult> set = new HashSet<SearchResult>( );
         BranchNode filter = new BranchNode( AssertionEnum.AND );
         
@@ -468,6 +493,75 @@
         or.addNode( new SimpleNode( M_MAY_OID, at.getOid(), AssertionEnum.EQUALITY ) );
         or.addNode( new SimpleNode( M_MUST_OID, at.getOid(), AssertionEnum.EQUALITY ) );
         or.addNode( new SimpleNode( M_SUP_ATTRIBUTE_TYPE_OID, at.getOid(), AssertionEnum.EQUALITY ) );
+        filter.addNode( or );
+
+        SearchControls searchControls = new SearchControls();
+        searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+        NamingEnumeration<SearchResult> ne = null;
+        
+        try
+        {
+            ne = partition.search( partition.getSuffix(), new HashMap(), filter, searchControls );
+            while( ne.hasMore() )
+            {
+                set.add( ne.next() );
+            }
+        }
+        finally
+        {
+            if ( ne != null )
+            {
+                ne.close();
+            }
+        }
+        
+        return set;
+    }
+
+
+    public Set<SearchResult> listObjectClassDependees( ObjectClass oc ) throws NamingException
+    {
+        /*
+         * Right now the following inefficient filter is being used:
+         * 
+         * ( & 
+         *      ( | ( objectClass = metaObjectClass ) ( objectClass = metaDITContentRule ) 
+         *          ( objectClass = metaNameForm ) )
+         *      ( | ( m-oc = $oid ) ( m-aux = $oid ) ( m-supObjectClass = $oid ) )
+         * )
+         * 
+         * The reason why this is inefficient is because the or terms have large scan counts
+         * and several loops are going to be required.  For example all the objectClasses and 
+         * all the metaDITContentRules and all the metaNameForm candidates will be a massive 
+         * number.  This is probably going to be bigger than the 2nd term where a candidate 
+         * satisfies one of the terms.
+         * 
+         * The following search is better because it constrains the results better:
+         * 
+         * ( |
+         *      ( & ( objectClass = metaNameForm ) ( m-oc = $oid ) )
+         *      ( & ( objectClass = metaObjectClass ) ( m-supObjectClass = $oid ) )
+         *      ( & ( objectClass = metaDITContentRule ) ( m-aux = $oid ) )
+         * )
+         */
+        
+        Set<SearchResult> set = new HashSet<SearchResult>( );
+        BranchNode filter = new BranchNode( AssertionEnum.AND );
+        
+        BranchNode or = new BranchNode( AssertionEnum.OR );
+        or.addNode( new SimpleNode( OBJECTCLASS_OID, 
+            MetaSchemaConstants.META_NAME_FORM_OC.toLowerCase(), AssertionEnum.EQUALITY ) );
+        or.addNode( new SimpleNode( OBJECTCLASS_OID, 
+            MetaSchemaConstants.META_OBJECT_CLASS_OC.toLowerCase(), AssertionEnum.EQUALITY ) );
+        or.addNode( new SimpleNode( OBJECTCLASS_OID, 
+            MetaSchemaConstants.META_DIT_CONTENT_RULE_OC.toLowerCase(), AssertionEnum.EQUALITY ) );
+        filter.addNode( or );
+
+        
+        or = new BranchNode( AssertionEnum.OR );
+        or.addNode( new SimpleNode( M_AUX_OID, oc.getOid(), AssertionEnum.EQUALITY ) );
+        or.addNode( new SimpleNode( M_OC_OID, oc.getOid(), AssertionEnum.EQUALITY ) );
+        or.addNode( new SimpleNode( M_SUP_OBJECT_CLASS_OID, oc.getOid(), AssertionEnum.EQUALITY ) );
         filter.addNode( or );
 
         SearchControls searchControls = new SearchControls();

Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?view=diff&rev=495051&r1=495050&r2=495051
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java Wed Jan 10 16:01:54 2007
@@ -94,6 +94,7 @@
 {
     private static final String[] EMPTY_STRING_ARRAY = new String[0];
     private static final String BINARY_KEY = "java.naming.ldap.attributes.binary";
+    private static final AttributeType[] EMPTY_ATTRIBUTE_TYPE_ARRAY = new AttributeType[0];
 
     /** The LoggerFactory used by this Interceptor */
     private static Logger log = LoggerFactory.getLogger( SchemaService.class );
@@ -1294,8 +1295,6 @@
     }
 
 
-    private static final AttributeType[] EMPTY_ATTRIBUTE_TYPE_ARRAY = new AttributeType[0];
-    
     /**
      * Uses the objectClass registry to ascend super classes and collect 
      * all attributeTypes within must lists until top is reached on each

Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AttributeTypeRegistry.java?view=diff&rev=495051&r1=495050&r2=495051
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AttributeTypeRegistry.java (original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/AttributeTypeRegistry.java Wed Jan 10 16:01:54 2007
@@ -26,6 +26,7 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.AttributeType;
+import org.apache.directory.shared.ldap.schema.OidNormalizer;
 
 
 /**
@@ -90,7 +91,7 @@
      * Gets an oid/name to normalizer mapping used to normalize distinguished 
      * names.
      */
-    Map getNormalizerMapping() throws NamingException; 
+    Map<String, OidNormalizer> getNormalizerMapping() throws NamingException; 
     
     /**
      * Quick lookup to see if an attribute has descendants.

Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultAttributeTypeRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultAttributeTypeRegistry.java?view=diff&rev=495051&r1=495050&r2=495051
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultAttributeTypeRegistry.java (original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultAttributeTypeRegistry.java Wed Jan 10 16:01:54 2007
@@ -200,7 +200,7 @@
     }
     
     
-    public Map getNormalizerMapping() throws NamingException
+    public Map<String,OidNormalizer> getNormalizerMapping() throws NamingException
     {
         if ( mapping == null )
         {

Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java?view=diff&rev=495051&r1=495050&r2=495051
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java (original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java Wed Jan 10 16:01:54 2007
@@ -141,4 +141,16 @@
     {
         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/ObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ObjectClassRegistry.java?view=diff&rev=495051&r1=495050&r2=495051
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ObjectClassRegistry.java (original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/ObjectClassRegistry.java Wed Jan 10 16:01:54 2007
@@ -82,4 +82,13 @@
      * @return an iterator over all ObjectClasses in registry
      */
     Iterator<ObjectClass> iterator();
+
+
+    /**
+     * Removes the ObjectClass corresponding to the numeric identifier form this registry.
+     * 
+     * @param numericOid the numeric identifier for the ObjectClass to remove
+     * @throws NamingException if the numeric identifier is not valid
+     */
+    void unregister( String numericOid ) throws NamingException;
 }



Mime
View raw message