You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ak...@apache.org on 2007/01/09 07:14:30 UTC
svn commit: r494326 - in /directory/trunks/apacheds:
core-unit/src/test/java/org/apache/directory/server/core/schema/
core/src/main/java/org/apache/directory/server/core/schema/
schema-registries/src/main/java/org/apache/directory/server/schema/registr...
Author: akarasulu
Date: Mon Jan 8 22:14:29 2007
New Revision: 494326
URL: http://svn.apache.org/viewvc?view=rev&rev=494326
Log:
Added matchingRule entity adds, deletes, modifys, modifyRn and moves under
ou=schema. In the process we have added some additional PartitionSchemaDao
methods and changed the MR registry to unregister MRs.
Added:
directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerITest.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
Modified:
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/SchemaManager.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultMatchingRuleRegistry.java
directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/MatchingRuleRegistry.java
Added: directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerITest.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerITest.java?view=auto&rev=494326
==============================================================================
--- directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerITest.java (added)
+++ directory/trunks/apacheds/core-unit/src/test/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandlerITest.java Mon Jan 8 22:14:29 2007
@@ -0,0 +1,470 @@
+/*
+ * 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.MatchingRule;
+
+
+/**
+ * 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 MetaMatchingRuleHandlerITest extends AbstractAdminTestCase
+{
+ private static final String DESCRIPTION0 = "A test matchingRule";
+ private static final String DESCRIPTION1 = "An alternate description";
+
+ private static final String INTEGER_SYNTAX_OID = "1.3.6.1.4.1.1466.115.121.1.27";
+ private static final String DIRSTR_SYNTAX_OID = "1.3.6.1.4.1.1466.115.121.1.15";
+
+ private static final String OID = "1.3.6.1.4.1.18060.0.4.0.1.100000";
+ private static final String NEW_OID = "1.3.6.1.4.1.18060.0.4.0.1.100001";
+
+
+ /**
+ * Gets relative DN to ou=schema.
+ */
+ private final LdapDN getMatchingRuleContainer( String schemaName ) throws NamingException
+ {
+ return new LdapDN( "ou=matchingRules,cn=" + schemaName );
+ }
+
+
+ // ----------------------------------------------------------------------
+ // Test all core methods with normal operational pathways
+ // ----------------------------------------------------------------------
+
+
+ public void testAddMatchingRule() 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_MATCHING_RULE_OC );
+ attrs.put( oc );
+ attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+ attrs.put( MetaSchemaConstants.M_SYNTAX_AT, INTEGER_SYNTAX_OID );
+ attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+
+ LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+ super.schemaRoot.createSubcontext( dn, attrs );
+
+ assertTrue( registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+ assertEquals( registries.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
+ }
+
+
+ public void testDeleteMatchingRule() throws NamingException
+ {
+ LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+ testAddMatchingRule();
+
+ super.schemaRoot.destroySubcontext( dn );
+
+ assertFalse( "matchingRule should be removed from the registry after being deleted",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ try
+ {
+ registries.getMatchingRuleRegistry().lookup( OID );
+ fail( "matchingRule lookup should fail after deleting it" );
+ }
+ catch( NamingException e )
+ {
+ }
+ }
+
+
+ public void testRenameMatchingRule() throws NamingException
+ {
+ LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+ testAddMatchingRule();
+
+ LdapDN newdn = getMatchingRuleContainer( "apachemeta" );
+ newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+ super.schemaRoot.rename( dn, newdn );
+
+ assertFalse( "old matchingRule OID should be removed from the registry after being renamed",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ try
+ {
+ registries.getMatchingRuleRegistry().lookup( OID );
+ fail( "matchingRule lookup should fail after renaming the matchingRule" );
+ }
+ catch( NamingException e )
+ {
+ }
+
+ assertTrue( registries.getMatchingRuleRegistry().hasMatchingRule( NEW_OID ) );
+ }
+
+
+ public void testMoveMatchingRule() throws NamingException
+ {
+ testAddMatchingRule();
+
+ LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ LdapDN newdn = getMatchingRuleContainer( "apache" );
+ newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ super.schemaRoot.rename( dn, newdn );
+
+ assertTrue( "matchingRule OID should still be present",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ assertEquals( "matchingRule schema should be set to apache not apachemeta",
+ registries.getMatchingRuleRegistry().getSchemaName( OID ), "apache" );
+ }
+
+
+ public void testMoveMatchingRuleAndChangeRdn() throws NamingException
+ {
+ testAddMatchingRule();
+
+ LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ LdapDN newdn = getMatchingRuleContainer( "apache" );
+ newdn.add( MetaSchemaConstants.M_OID_AT + "=" + NEW_OID );
+
+ super.schemaRoot.rename( dn, newdn );
+
+ assertFalse( "old matchingRule OID should NOT be present",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ assertTrue( "new matchingRule OID should be present",
+ registries.getMatchingRuleRegistry().hasMatchingRule( NEW_OID ) );
+
+ assertEquals( "matchingRule with new oid should have schema set to apache NOT apachemeta",
+ registries.getMatchingRuleRegistry().getSchemaName( NEW_OID ), "apache" );
+ }
+
+
+ public void testModifyMatchingRuleWithModificationItems() throws NamingException
+ {
+ testAddMatchingRule();
+
+ MatchingRule mr = registries.getMatchingRuleRegistry().lookup( OID );
+ assertEquals( mr.getDescription(), DESCRIPTION0 );
+ assertEquals( mr.getSyntax().getOid(), INTEGER_SYNTAX_OID );
+
+ LdapDN dn = getMatchingRuleContainer( "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_SYNTAX_AT, DIRSTR_SYNTAX_OID );
+ mods[1] = new ModificationItemImpl( DirContext.REPLACE_ATTRIBUTE, attr );
+ super.schemaRoot.modifyAttributes( dn, mods );
+
+ assertTrue( "matchingRule OID should still be present",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ assertEquals( "matchingRule schema should be set to apachemeta",
+ registries.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
+
+ mr = registries.getMatchingRuleRegistry().lookup( OID );
+ assertEquals( mr.getDescription(), DESCRIPTION1 );
+ assertEquals( mr.getSyntax().getOid(), DIRSTR_SYNTAX_OID );
+ }
+
+
+ public void testModifyMatchingRuleWithAttributes() throws NamingException
+ {
+ testAddMatchingRule();
+
+ MatchingRule mr = registries.getMatchingRuleRegistry().lookup( OID );
+ assertEquals( mr.getDescription(), DESCRIPTION0 );
+ assertEquals( mr.getSyntax().getOid(), INTEGER_SYNTAX_OID );
+
+ LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ Attributes mods = new AttributesImpl();
+ mods.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION1 );
+ mods.put( MetaSchemaConstants.M_SYNTAX_AT, DIRSTR_SYNTAX_OID );
+ super.schemaRoot.modifyAttributes( dn, DirContext.REPLACE_ATTRIBUTE, mods );
+
+ assertTrue( "matchingRule OID should still be present",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ assertEquals( "matchingRule schema should be set to apachemeta",
+ registries.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
+
+ mr = registries.getMatchingRuleRegistry().lookup( OID );
+ assertEquals( mr.getDescription(), DESCRIPTION1 );
+ assertEquals( mr.getSyntax().getOid(), DIRSTR_SYNTAX_OID );
+ }
+
+
+ // ----------------------------------------------------------------------
+ // 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 testMoveMatchingRuleToTop() throws NamingException
+ {
+ testAddMatchingRule();
+
+ LdapDN dn = getMatchingRuleContainer( "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 matchingRule up to ou=schema" );
+ }
+ catch( LdapInvalidNameException e )
+ {
+ assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+ }
+
+ assertTrue( "matchingRule should still be in the registry after move failure",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+ }
+
+
+ public void testMoveMatchingRuleToComparatorContainer() throws NamingException
+ {
+ testAddMatchingRule();
+
+ LdapDN dn = getMatchingRuleContainer( "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 matchingRule into comparators container" );
+ }
+ catch( LdapInvalidNameException e )
+ {
+ assertEquals( e.getResultCode(), ResultCodeEnum.NAMING_VIOLATION );
+ }
+
+ assertTrue( "matchingRule should still be in the registry after move failure",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+ }
+
+
+ public void testAddMatchingRuleToDisabledSchema() 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_MATCHING_RULE_OC );
+ attrs.put( oc );
+ attrs.put( MetaSchemaConstants.M_OID_AT, OID );
+ attrs.put( MetaSchemaConstants.M_SYNTAX_AT, INTEGER_SYNTAX_OID );
+ attrs.put( MetaSchemaConstants.M_DESCRIPTION_AT, DESCRIPTION0 );
+
+ LdapDN dn = getMatchingRuleContainer( "nis" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+ super.schemaRoot.createSubcontext( dn, attrs );
+
+ assertFalse( "adding new matchingRule to disabled schema should not register it into the registries",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+ }
+
+
+ public void testMoveMatchingRuleToDisabledSchema() throws NamingException
+ {
+ testAddMatchingRule();
+
+ LdapDN dn = getMatchingRuleContainer( "apachemeta" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ // nis is inactive by default
+ LdapDN newdn = getMatchingRuleContainer( "nis" );
+ newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ super.schemaRoot.rename( dn, newdn );
+
+ assertFalse( "matchingRule OID should no longer be present",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+ }
+
+
+ public void testMoveMatchingRuleToEnabledSchema() throws NamingException
+ {
+ testAddMatchingRuleToDisabledSchema();
+
+ // nis is inactive by default
+ LdapDN dn = getMatchingRuleContainer( "nis" );
+ dn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ assertFalse( "matchingRule OID should NOT be present when added to disabled nis schema",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ LdapDN newdn = getMatchingRuleContainer( "apachemeta" );
+ newdn.add( MetaSchemaConstants.M_OID_AT + "=" + OID );
+
+ super.schemaRoot.rename( dn, newdn );
+
+ assertTrue( "matchingRule OID should be present when moved to enabled schema",
+ registries.getMatchingRuleRegistry().hasMatchingRule( OID ) );
+
+ assertEquals( "matchingRule should be in apachemeta schema after move",
+ registries.getMatchingRuleRegistry().getSchemaName( OID ), "apachemeta" );
+ }
+}
Added: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java?view=auto&rev=494326
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java (added)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/schema/MetaMatchingRuleHandler.java Mon Jan 8 22:14:29 2007
@@ -0,0 +1,293 @@
+/*
+ * 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.MatchingRuleRegistry;
+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.MatchingRule;
+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 MetaMatchingRuleHandler 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 MatchingRuleRegistry matchingRuleRegistry;
+ private final AttributeType m_oidAT;
+
+
+
+ public MetaMatchingRuleHandler( Registries targetRegistries, PartitionSchemaLoader loader, SchemaPartitionDao dao )
+ throws NamingException
+ {
+ this.targetRegistries = targetRegistries;
+ this.dao = dao;
+ this.loader = loader;
+ this.matchingRuleRegistry = targetRegistries.getMatchingRuleRegistry();
+ 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 );
+ MatchingRule mr = factory.getMatchingRule( targetEntry, targetRegistries );
+ Schema schema = getSchema( name );
+
+ if ( ! schema.isDisabled() )
+ {
+ matchingRuleRegistry.unregister( oldOid );
+ matchingRuleRegistry.register( schema.getSchemaName(), mr );
+ }
+ }
+
+
+ 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 );
+
+ MatchingRule mr = factory.getMatchingRule( entry, targetRegistries );
+ Schema schema = getSchema( name );
+
+ if ( ! schema.isDisabled() )
+ {
+ matchingRuleRegistry.register( schema.getSchemaName(), mr );
+ }
+ }
+
+
+ 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
+ {
+ MatchingRule mr = factory.getMatchingRule( entry, targetRegistries );
+ Set<SearchResult> dependees = dao.listMatchingRuleDependees( mr );
+ if ( dependees != null && dependees.size() > 0 )
+ {
+ throw new LdapOperationNotSupportedException( "The matchingRule with OID " + mr.getOid()
+ + " cannot be deleted until all entities"
+ + " using this matchingRule have also been deleted. The following dependees exist: "
+ + getOids( dependees ),
+ ResultCodeEnum.UNWILLING_TO_PERFORM );
+ }
+
+ Schema schema = getSchema( name );
+
+ if ( ! schema.isDisabled() )
+ {
+ matchingRuleRegistry.unregister( mr.getOid() );
+ }
+ }
+
+
+ public void rename( LdapDN name, Attributes entry, String newRdn ) throws NamingException
+ {
+ MatchingRule oldMr = factory.getMatchingRule( entry, targetRegistries );
+ Set<SearchResult> dependees = dao.listMatchingRuleDependees( oldMr );
+ if ( dependees != null && dependees.size() > 0 )
+ {
+ throw new LdapOperationNotSupportedException( "The matchingRule with OID " + oldMr.getOid()
+ + " cannot be deleted until all entities"
+ + " using this matchingRule 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() )
+ {
+ MatchingRule mr = factory.getMatchingRule( targetEntry, targetRegistries );
+ matchingRuleRegistry.unregister( oldMr.getOid() );
+ matchingRuleRegistry.register( schema.getSchemaName(), mr );
+ }
+ }
+
+
+ public void move( LdapDN oriChildName, LdapDN newParentName, String newRn, boolean deleteOldRn, Attributes entry )
+ throws NamingException
+ {
+ checkNewParent( newParentName );
+ MatchingRule oldMr = factory.getMatchingRule( entry, targetRegistries );
+ Set<SearchResult> dependees = dao.listMatchingRuleDependees( oldMr );
+ if ( dependees != null && dependees.size() > 0 )
+ {
+ throw new LdapOperationNotSupportedException( "The matchingRule with OID " + oldMr.getOid()
+ + " cannot be deleted until all entities"
+ + " using this matchingRule 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 ) );
+ MatchingRule mr = factory.getMatchingRule( targetEntry, targetRegistries );
+
+ if ( ! oldSchema.isDisabled() )
+ {
+ matchingRuleRegistry.unregister( oldMr.getOid() );
+ }
+
+ if ( ! newSchema.isDisabled() )
+ {
+ matchingRuleRegistry.register( newSchema.getSchemaName(), mr );
+ }
+ }
+
+
+ public void move( LdapDN oriChildName, LdapDN newParentName, Attributes entry )
+ throws NamingException
+ {
+ checkNewParent( newParentName );
+ MatchingRule oldMr = factory.getMatchingRule( entry, targetRegistries );
+ Set<SearchResult> dependees = dao.listMatchingRuleDependees( oldMr );
+ if ( dependees != null && dependees.size() > 0 )
+ {
+ throw new LdapOperationNotSupportedException( "The matchingRule with OID " + oldMr.getOid()
+ + " cannot be deleted until all entities"
+ + " using this matchingRule have also been deleted. The following dependees exist: "
+ + getOids( dependees ),
+ ResultCodeEnum.UNWILLING_TO_PERFORM );
+ }
+
+ Schema oldSchema = getSchema( oriChildName );
+ Schema newSchema = getSchema( newParentName );
+
+ MatchingRule mr = factory.getMatchingRule( entry, targetRegistries );
+
+ if ( ! oldSchema.isDisabled() )
+ {
+ matchingRuleRegistry.unregister( oldMr.getOid() );
+ }
+
+ if ( ! newSchema.isDisabled() )
+ {
+ matchingRuleRegistry.register( newSchema.getSchemaName(), mr );
+ }
+ }
+
+
+ private void checkNewParent( LdapDN newParent ) throws NamingException
+ {
+ if ( newParent.size() != 3 )
+ {
+ throw new LdapInvalidNameException(
+ "The parent dn of a matchingRule should be at most 3 name components in length.",
+ ResultCodeEnum.NAMING_VIOLATION );
+ }
+
+ Rdn rdn = newParent.getRdn();
+ if ( ! targetRegistries.getOidRegistry().getOid( rdn.getType() ).equals( OU_OID ) )
+ {
+ throw new LdapInvalidNameException( "The parent entry of a matchingRule should be an organizationalUnit.",
+ ResultCodeEnum.NAMING_VIOLATION );
+ }
+
+ if ( ! ( ( String ) rdn.getValue() ).equalsIgnoreCase( "matchingRules" ) )
+ {
+ throw new LdapInvalidNameException(
+ "The parent entry of a syntax should have a relative name of ou=matchingRules.",
+ 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=494326&r1=494325&r2=494326
==============================================================================
--- 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 Mon Jan 8 22:14:29 2007
@@ -33,9 +33,11 @@
import javax.naming.NamingEnumeration;
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.partition.Partition;
import org.apache.directory.server.schema.bootstrap.Schema;
import org.apache.directory.server.schema.registries.AbstractSchemaLoader;
@@ -48,6 +50,7 @@
import org.apache.directory.shared.ldap.schema.Syntax;
import org.apache.directory.shared.ldap.schema.MatchingRule;
import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
+import org.apache.directory.shared.ldap.util.AttributeUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,6 +71,8 @@
private SchemaEntityFactory factory;
private Partition partition;
private AttributeTypeRegistry attrRegistry;
+ private final AttributeType mOidAT;
+ private final AttributeType mNameAT;
public PartitionSchemaLoader( Partition partition, Registries bootstrapRegistries ) throws NamingException
@@ -77,6 +82,8 @@
this.attrRegistry = bootstrapRegistries.getAttributeTypeRegistry();
dao = new SchemaPartitionDao( this.partition, bootstrapRegistries );
+ mOidAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_OID_AT );
+ mNameAT = bootstrapRegistries.getAttributeTypeRegistry().lookup( MetaSchemaConstants.M_NAME_AT );
}
@@ -88,6 +95,41 @@
*/
public void loadEnabled( Registries targetRegistries ) throws NamingException
{
+ /*
+ * We need to load all names and oids into the oid registry regardless of
+ * the entity being in an enabled schema. This is necessary because we
+ * search for values in the schema partition that represent matchingRules
+ * and other entities that are not loaded. While searching these values
+ * in disabled schemas normalizers will attempt to equate names with oids
+ * and if there is an unrecognized value by a normalizer then the search
+ * will fail.
+ *
+ * For example there is a NameOrNumericOidNormalizer that will reduce a
+ * numeric OID or a non-numeric OID to it's numeric form using the OID
+ * registry. While searching the schema partition for attributeTypes we
+ * might find values of matchingRules in the m-ordering, m-equality, and
+ * m-substr attributes of metaAttributeType definitions. Now if an entry
+ * references a matchingRule that has not been loaded then the
+ * NameOrNumericOidNormalizer will bomb out when it tries to resolve
+ * names of matchingRules in unloaded schemas to OID values using the
+ * OID registry. To prevent this we need to load all the OID's in advance
+ * regardless of whether they are used or not.
+ */
+ NamingEnumeration ne = dao.listAllNames();
+ while ( ne.hasMore() )
+ {
+ Attributes attrs = ( ( SearchResult ) ne.next() ).getAttributes();
+ String oid = ( String ) AttributeUtils.getAttribute( attrs, mOidAT ).get();
+ Attribute names = AttributeUtils.getAttribute( attrs, mNameAT );
+ targetRegistries.getOidRegistry().register( oid, oid );
+ for ( int ii = 0; ii < names.size(); ii++ )
+ {
+ targetRegistries.getOidRegistry().register( ( String ) names.get( ii ), oid );
+ }
+ }
+ ne.close();
+
+
Map<String, Schema> allSchemaMap = getSchemas();
Set<Schema> enabledSchemaSet = new HashSet<Schema>();
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=494326&r1=494325&r2=494326
==============================================================================
--- 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 Mon Jan 8 22:14:29 2007
@@ -58,6 +58,7 @@
private final MetaNormalizerHandler metaNormalizerHandler;
private final MetaSyntaxCheckerHandler metaSyntaxCheckerHandler;
private final MetaSyntaxHandler metaSyntaxHandler;
+ private final MetaMatchingRuleHandler metaMatchingRuleHandler;
public SchemaManager( Registries globalRegistries, PartitionSchemaLoader loader, SchemaPartitionDao dao )
@@ -72,6 +73,7 @@
this.metaNormalizerHandler = new MetaNormalizerHandler( globalRegistries, loader );
this.metaSyntaxCheckerHandler = new MetaSyntaxCheckerHandler( globalRegistries, loader );
this.metaSyntaxHandler = new MetaSyntaxHandler( globalRegistries, loader, dao );
+ this.metaMatchingRuleHandler = new MetaMatchingRuleHandler( globalRegistries, loader, dao );
}
@@ -121,6 +123,12 @@
return;
}
+ if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_MATCHING_RULE_OC, objectClassAT ) )
+ {
+ metaMatchingRuleHandler.add( name, entry );
+ return;
+ }
+
throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
}
@@ -159,6 +167,12 @@
return;
}
+ if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_MATCHING_RULE_OC, objectClassAT ) )
+ {
+ metaMatchingRuleHandler.delete( name, entry );
+ return;
+ }
+
throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
}
@@ -198,6 +212,12 @@
return;
}
+ if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_MATCHING_RULE_OC, objectClassAT ) )
+ {
+ metaMatchingRuleHandler.modify( name, modOp, mods, entry, targetEntry );
+ return;
+ }
+
throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
}
@@ -237,6 +257,12 @@
return;
}
+ if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_MATCHING_RULE_OC, objectClassAT ) )
+ {
+ metaMatchingRuleHandler.modify( name, mods, entry, targetEntry );
+ return;
+ }
+
throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
}
@@ -275,6 +301,12 @@
return;
}
+ if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_MATCHING_RULE_OC, objectClassAT ) )
+ {
+ metaMatchingRuleHandler.rename( name, entry, newRdn );
+ return;
+ }
+
throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
}
@@ -313,6 +345,12 @@
return;
}
+ if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_MATCHING_RULE_OC, objectClassAT ) )
+ {
+ metaMatchingRuleHandler.move( oriChildName, newParentName, entry );
+ return;
+ }
+
throw new NotImplementedException( "only changes to metaSchema objects are managed at this time" );
}
@@ -349,6 +387,12 @@
if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_SYNTAX_OC, objectClassAT ) )
{
metaSyntaxHandler.move( oriChildName, newParentName, newRn, deleteOldRn, entry );
+ return;
+ }
+
+ if ( AttributeUtils.containsValue( oc, MetaSchemaConstants.META_MATCHING_RULE_OC, objectClassAT ) )
+ {
+ metaMatchingRuleHandler.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=494326&r1=494325&r2=494326
==============================================================================
--- 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 Mon Jan 8 22:14:29 2007
@@ -44,6 +44,7 @@
import org.apache.directory.server.schema.registries.Registries;
import org.apache.directory.shared.ldap.filter.BranchNode;
import org.apache.directory.shared.ldap.filter.ExprNode;
+import org.apache.directory.shared.ldap.filter.PresenceNode;
import org.apache.directory.shared.ldap.filter.SimpleNode;
import org.apache.directory.shared.ldap.filter.AssertionEnum;
import org.apache.directory.shared.ldap.message.AttributeImpl;
@@ -51,6 +52,7 @@
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.MatchingRule;
import org.apache.directory.shared.ldap.schema.syntax.NumericOidSyntaxChecker;
import org.slf4j.Logger;
@@ -81,8 +83,11 @@
private final String CN_OID;
private final String M_OID_OID;
private final String OBJECTCLASS_OID;
- private final String META_SYNTAX_OID;
-
+ private final String M_SYNTAX_OID;
+ private final String M_ORDERING_OID;
+ private final String M_SUBSTRING_OID;
+ private final String M_EQUALITY_OID;
+
private final AttributeType disabledAttributeType;
@@ -105,10 +110,13 @@
this.disabledAttributeType = attrRegistry.lookup( MetaSchemaConstants.M_DISABLED_AT );
this.M_OID_OID = oidRegistry.getOid( MetaSchemaConstants.M_OID_AT );
this.OBJECTCLASS_OID = oidRegistry.getOid( SystemSchemaConstants.OBJECT_CLASS_AT );
- this.META_SYNTAX_OID = oidRegistry.getOid( MetaSchemaConstants.M_SYNTAX_AT );
+ this.M_SYNTAX_OID = oidRegistry.getOid( MetaSchemaConstants.M_SYNTAX_AT );
+ this.M_ORDERING_OID = oidRegistry.getOid( MetaSchemaConstants.M_ORDERING_AT );
+ this.M_EQUALITY_OID = oidRegistry.getOid( MetaSchemaConstants.M_EQUALITY_AT );
+ this.M_SUBSTRING_OID = oidRegistry.getOid( MetaSchemaConstants.M_SUBSTR_AT );
}
-
-
+
+
public Map<String,Schema> getSchemas() throws NamingException
{
Map<String,Schema> schemas = new HashMap<String,Schema>();
@@ -347,7 +355,7 @@
MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC.toLowerCase(), AssertionEnum.EQUALITY ) );
filter.addNode( or );
- filter.addNode( new SimpleNode( META_SYNTAX_OID,
+ filter.addNode( new SimpleNode( M_SYNTAX_OID,
numericOid.toLowerCase(), AssertionEnum.EQUALITY ) );
SearchControls searchControls = new SearchControls();
@@ -371,5 +379,67 @@
}
return set;
+ }
+
+
+ public Set<SearchResult> listMatchingRuleDependees( MatchingRule mr ) throws NamingException
+ {
+ Set<SearchResult> set = new HashSet<SearchResult>( );
+ BranchNode filter = new BranchNode( AssertionEnum.AND );
+
+ // ( objectClass = metaAttributeType )
+ filter.addNode( new SimpleNode( OBJECTCLASS_OID,
+ MetaSchemaConstants.META_ATTRIBUTE_TYPE_OC.toLowerCase(), AssertionEnum.EQUALITY ) );
+
+ BranchNode or = new BranchNode( AssertionEnum.OR );
+ or.addNode( new SimpleNode( M_ORDERING_OID, mr.getOid(), AssertionEnum.EQUALITY ) );
+ or.addNode( new SimpleNode( M_SUBSTRING_OID, mr.getOid(), AssertionEnum.EQUALITY ) );
+ or.addNode( new SimpleNode( M_EQUALITY_OID, mr.getOid(), AssertionEnum.EQUALITY ) );
+ filter.addNode( or );
+
+ if ( mr.getNames() != null || mr.getNames().length > 0 )
+ {
+ for ( String name : mr.getNames() )
+ {
+ or.addNode( new SimpleNode( M_ORDERING_OID, name.toLowerCase(), AssertionEnum.EQUALITY ) );
+ or.addNode( new SimpleNode( M_SUBSTRING_OID, name.toLowerCase(), AssertionEnum.EQUALITY ) );
+ or.addNode( new SimpleNode( M_EQUALITY_OID, name.toLowerCase(), AssertionEnum.EQUALITY ) );
+ }
+ }
+
+ 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 NamingEnumeration listAllNames() throws NamingException
+ {
+ SearchControls searchControls = new SearchControls();
+ searchControls.setSearchScope( SearchControls.SUBTREE_SCOPE );
+ BranchNode filter = new BranchNode( AssertionEnum.AND );
+
+ // (& (m-oid=*) (m-name=*) )
+ filter.addNode( new PresenceNode( M_OID_OID ) );
+ filter.addNode( new PresenceNode( M_NAME_OID ) );
+ return partition.search( partition.getSuffix(), new HashMap(), filter, searchControls );
}
}
Modified: directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultMatchingRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultMatchingRuleRegistry.java?view=diff&rev=494326&r1=494325&r2=494326
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultMatchingRuleRegistry.java (original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultMatchingRuleRegistry.java Mon Jan 8 22:14:29 2007
@@ -113,6 +113,7 @@
{
oidRegistry.register( names[ii], matchingRule.getOid() );
}
+ oidRegistry.register( matchingRule.getOid(), matchingRule.getOid() );
byOid.put( matchingRule.getOid(), matchingRule );
if ( log.isDebugEnabled() )
@@ -158,5 +159,17 @@
public Iterator<MatchingRule> 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/MatchingRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/MatchingRuleRegistry.java?view=diff&rev=494326&r1=494325&r2=494326
==============================================================================
--- directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/MatchingRuleRegistry.java (original)
+++ directory/trunks/apacheds/schema-registries/src/main/java/org/apache/directory/server/schema/registries/MatchingRuleRegistry.java Mon Jan 8 22:14:29 2007
@@ -84,4 +84,13 @@
* @return an iterator over all MatchingRules in registry
*/
Iterator<MatchingRule> iterator();
+
+
+ /**
+ * Removes a registered matchingRule from this registry.
+ *
+ * @param numericOid the numeric object identifier for the matchingRule to remove
+ * @throws NamingException if the numericOid is invalid
+ */
+ void unregister( String numericOid ) throws NamingException;
}