directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r506370 - in /directory/apacheds/trunk: ./ 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/regis...
Date Mon, 12 Feb 2007 08:26:41 GMT
Author: akarasulu
Date: Mon Feb 12 00:26:40 2007
New Revision: 506370

URL: http://svn.apache.org/viewvc?view=rev&rev=506370
Log:
changes ...

 o adding objectClass presence check method to SchemaPartitionDao
 o added some checks to DescriptionParser for poorly structured objectClasses
 o added objectClass add/remove tests in SubschemaSubentryITest
 o fixed a bug in DefaultObjectClassRegistry for OCs without names


Modified:
    directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
    directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
    directory/apacheds/trunk/pom.xml
    directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java

Modified: directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java?view=diff&rev=506370&r1=506369&r2=506370
==============================================================================
--- directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
(original)
+++ directory/apacheds/trunk/core-unit/src/test/java/org/apache/directory/server/core/schema/SubschemaSubentryITest.java
Mon Feb 12 00:26:40 2007
@@ -52,6 +52,7 @@
 import org.apache.directory.shared.ldap.schema.syntax.LdapSyntaxDescription;
 import org.apache.directory.shared.ldap.schema.syntax.MatchingRuleDescription;
 import org.apache.directory.shared.ldap.schema.syntax.NormalizerDescription;
+import org.apache.directory.shared.ldap.schema.syntax.ObjectClassDescription;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxChecker;
 import org.apache.directory.shared.ldap.schema.syntax.SyntaxCheckerDescription;
 import org.apache.directory.shared.ldap.schema.syntax.parser.AttributeTypeDescriptionSchemaParser;
@@ -59,6 +60,7 @@
 import org.apache.directory.shared.ldap.schema.syntax.parser.LdapSyntaxDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.schema.syntax.parser.MatchingRuleDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.schema.syntax.parser.NormalizerDescriptionSchemaParser;
+import org.apache.directory.shared.ldap.schema.syntax.parser.ObjectClassDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.schema.syntax.parser.SyntaxCheckerDescriptionSchemaParser;
 import org.apache.directory.shared.ldap.util.Base64;
 
@@ -87,6 +89,8 @@
         new LdapSyntaxDescriptionSchemaParser();
     private MatchingRuleDescriptionSchemaParser matchingRuleDescriptionSchemaParser =
         new MatchingRuleDescriptionSchemaParser();
+    private ObjectClassDescriptionSchemaParser objectClassDescriptionSchemaParser =
+        new ObjectClassDescriptionSchemaParser();
 
     
     /**
@@ -1391,6 +1395,335 @@
     }
 
 
+    // -----------------------------------------------------------------------
+    // ObjectClass Tests
+    // -----------------------------------------------------------------------
+    
+    
+    private void checkObjectClassPresent( String oid, String schemaName, boolean isPresent
) throws Exception
+    {
+        // -------------------------------------------------------------------
+        // check first to see if it is present in the subschemaSubentry
+        // -------------------------------------------------------------------
+        
+        Attributes attrs = getSubschemaSubentryAttributes();
+        Attribute attrTypes = attrs.get( "objectClasses" );
+        ObjectClassDescription objectClassDescription = null; 
+        for ( int ii = 0; ii < attrTypes.size(); ii++ )
+        {
+            String desc = ( String ) attrTypes.get( ii );
+            if ( desc.indexOf( oid ) != -1 )
+            {
+                objectClassDescription = objectClassDescriptionSchemaParser.parseObjectClassDescription(
desc );
+                break;
+            }
+        }
+     
+        if ( isPresent )
+        {
+            assertNotNull( objectClassDescription );
+            assertEquals( oid, objectClassDescription.getNumericOid() );
+        }
+        else
+        {
+            assertNull( objectClassDescription );
+        }
+
+        // -------------------------------------------------------------------
+        // check next to see if it is present in the schema partition
+        // -------------------------------------------------------------------
+        
+        attrs = null;
+        
+        if ( isPresent )
+        {
+            attrs = schemaRoot.getAttributes( "m-oid=" + oid + ",ou=objectClasses,cn=" +
schemaName );
+            assertNotNull( attrs );
+        }
+        else
+        {
+            try
+            {
+                attrs = schemaRoot.getAttributes( "m-oid=" + oid + ",ou=objectClasses,cn="
+ schemaName );
+                fail( "should never get here" );
+            }
+            catch( NamingException e )
+            {
+            }
+            assertNull( attrs );
+        }
+        
+        // -------------------------------------------------------------------
+        // check to see if it is present in the matchingRuleRegistry
+        // -------------------------------------------------------------------
+        
+        if ( isPresent ) 
+        { 
+            assertTrue( registries.getObjectClassRegistry().hasObjectClass( oid ) );
+        }
+        else
+        {
+            assertFalse( registries.getObjectClassRegistry().hasObjectClass( oid ) );
+        }
+    }
+    
+    
+    /**
+     * Tests a number of modify add, remove and replace operation combinations for
+     * objectClasses on the schema subentry.
+     */
+    public void testAddRemoveReplaceObjectClasses() throws Exception
+    {
+        enableSchema( "nis" );
+        List<String> descriptions = new ArrayList<String>();
+
+        // -------------------------------------------------------------------
+        // test rejection with non-existant superclass
+        // -------------------------------------------------------------------
+        
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 SUP 1.2.3 X-SCHEMA 'nis' )"
);
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 SUP ( 1.2.3 $ 4.5.6 ) X-SCHEMA
'nis' )" );
+
+        try
+        {
+            modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+            fail( "Cannot add objectClass with bogus non-existant super" );
+        }
+        catch( LdapOperationNotSupportedException e )
+        {
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+        }
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+
+        // -------------------------------------------------------------------
+        // test add with existant superiors but no name and no desc
+        // -------------------------------------------------------------------
+
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "SUP 2.5.6.0 X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "SUP 2.5.6.0 X-SCHEMA 'nis' )" );
+        
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", true );
+
+        // -------------------------------------------------------------------
+        // test add with existant superiors with names and no desc
+        // -------------------------------------------------------------------
+
+        modify( DirContext.REMOVE_ATTRIBUTE, descriptions, "objectClasses" );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+        
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) SUP 2.5.6.0 X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) SUP 2.5.6.0 X-SCHEMA 'nis' )" );
+        
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", true );
+
+        // -------------------------------------------------------------------
+        // test add with existant superiors with names and desc
+        // -------------------------------------------------------------------
+
+        modify( DirContext.REMOVE_ATTRIBUTE, descriptions, "objectClasses" );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+        
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) DESC 'bogus' SUP 2.5.6.0 X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) DESC 'bogus' SUP 2.5.6.0 X-SCHEMA 'nis' )" );
+        
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", true );
+
+        // -------------------------------------------------------------------
+        // test add with many existant superiors with names and desc
+        // -------------------------------------------------------------------
+
+        modify( DirContext.REMOVE_ATTRIBUTE, descriptions, "objectClasses" );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+        
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) DESC 'bogus' SUP ( 2.5.6.0 $ dynamicObject )
X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) DESC 'bogus' SUP ( 2.5.6.0 $ domain ) X-SCHEMA
'nis' )" );
+        
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", true );
+
+        // -------------------------------------------------------------------
+        // test reject with non-existant attributeType in may list
+        // -------------------------------------------------------------------
+
+        modify( DirContext.REMOVE_ATTRIBUTE, descriptions, "objectClasses" );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+        
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) DESC 'bogus' SUP ( 2.5.6.0 $ dynamicObject )
" +
+                "MAY ( blah0 $ cn ) X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) DESC 'bogus' SUP ( 2.5.6.0 $ domain ) " +
+                "MAY ( sn $ blah1 ) X-SCHEMA 'nis' )" );
+        
+        try
+        {
+            modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+            fail( "Cannot add objectClass with bogus non-existant attributeTypes" );
+        }
+        catch( LdapOperationNotSupportedException e )
+        {
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+        }
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+
+        // -------------------------------------------------------------------
+        // test reject with non-existant attributeType in must list
+        // -------------------------------------------------------------------
+
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) DESC 'bogus' SUP ( 2.5.6.0 $ dynamicObject )
" +
+                "MUST ( blah0 $ cn ) X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) DESC 'bogus' SUP ( 2.5.6.0 $ domain ) " +
+                "MUST ( sn $ blah1 ) X-SCHEMA 'nis' )" );
+        
+        try
+        {
+            modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+            fail( "Cannot add objectClass with bogus non-existant attributeTypes" );
+        }
+        catch( LdapOperationNotSupportedException e )
+        {
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+        }
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+
+        // -------------------------------------------------------------------
+        // test add with valid attributeTypes in may list
+        // -------------------------------------------------------------------
+
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) DESC 'bogus' SUP ( 2.5.6.0 $ dynamicObject )
" +
+                "MAY ( sn $ cn ) X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) DESC 'bogus' SUP ( 2.5.6.0 $ domain ) " +
+                "MAY ( sn $ ou ) X-SCHEMA 'nis' )" );
+        
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", true );
+
+        // -------------------------------------------------------------------
+        // test add with valid attributeTypes in must list
+        // -------------------------------------------------------------------
+
+        modify( DirContext.REMOVE_ATTRIBUTE, descriptions, "objectClasses" );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+        
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) DESC 'bogus' SUP ( 2.5.6.0 $ dynamicObject )
" +
+                "MUST ( sn $ cn ) X-SCHEMA 'nis' )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) DESC 'bogus' SUP ( 2.5.6.0 $ domain ) " +
+                "MUST ( sn $ ou ) X-SCHEMA 'nis' )" );
+        
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", true );
+
+        // -------------------------------------------------------------------
+        // test add success full (with obsolete)
+        // -------------------------------------------------------------------
+        
+        modify( DirContext.REMOVE_ATTRIBUTE, descriptions, "objectClasses" );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+        
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+                "NAME ( 'blah0' 'altname0' ) DESC 'bogus' OBSOLETE SUP ( 2.5.6.0 $ dynamicObject
) STRUCTURAL " +
+                "MUST ( sn $ cn ) " +
+                "MAY ( sn $ ou ) " +
+                "X-SCHEMA 'nis' ) " );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+                "NAME ( 'blah1' 'altname1' ) DESC 'bogus' OBSOLETE SUP ( 2.5.6.0 $ domain
) STRUCTURAL " +
+                "MUST ( sn $ ou ) " +
+                "MAY ( sn $ ou ) " +
+                "X-SCHEMA 'nis' )" );
+        
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", true );
+
+        // -------------------------------------------------------------------
+        // test failure to replace
+        // -------------------------------------------------------------------
+        
+        modify( DirContext.REMOVE_ATTRIBUTE, descriptions, "objectClasses" );
+        checkMatchingRulePresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "nis", false );
+        checkMatchingRulePresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "nis", false );
+        
+        try
+        {
+            modify( DirContext.REPLACE_ATTRIBUTE, descriptions, "objectClasses" );
+            fail( "modify REPLACE operations should not be allowed" );
+        }
+        catch ( LdapOperationNotSupportedException e )
+        {
+            assertEquals( ResultCodeEnum.UNWILLING_TO_PERFORM, e.getResultCode() );
+        }
+
+        // -------------------------------------------------------------------
+        // check add no schema info
+        // -------------------------------------------------------------------
+        
+        descriptions.clear();
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10000 " +
+            "NAME ( 'blah0' 'altname0' ) DESC 'bogus' OBSOLETE SUP ( 2.5.6.0 $ dynamicObject
) STRUCTURAL " +
+            "MUST ( sn $ cn ) " +
+            "MAY ( sn $ ou ) )" );
+        descriptions.add( "( 1.3.6.1.4.1.18060.0.4.1.3.10001 " +
+            "NAME ( 'blah1' 'altname1' ) DESC 'bogus' OBSOLETE SUP ( 2.5.6.0 $ domain ) STRUCTURAL
" +
+            "MUST ( sn $ ou ) " +
+            "MAY ( sn $ ou ) )" );
+
+        modify( DirContext.ADD_ATTRIBUTE, descriptions, "objectClasses" );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10000", "other", true );
+        checkObjectClassPresent( "1.3.6.1.4.1.18060.0.4.1.3.10001", "other", true );
+    }
+
+    
     // -----------------------------------------------------------------------
     // Private Utility Methods 
     // -----------------------------------------------------------------------

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java?view=diff&rev=506370&r1=506369&r2=506370
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/DescriptionParsers.java
Mon Feb 12 00:26:40 2007
@@ -385,7 +385,57 @@
                 iave.setRootCause( e );
                 throw iave;
             }
-         
+            
+            // if the super objectClasses are provided make sure it exists in some schema
+            if ( desc.getSuperiorObjectClasses() != null && desc.getSuperiorObjectClasses().size()
> 0 )
+            {
+                for ( String superior : desc.getSuperiorObjectClasses() )
+                {
+                    if ( superior.equals( "2.5.6.0" ) || superior.equalsIgnoreCase( "top"
) )
+                    {
+                        continue;
+                    }
+                    
+                    if ( ! dao.hasObjectClass( superior ) )
+                    {
+                        throw new LdapOperationNotSupportedException(
+                            "Cannot permit the addition of an objectClass with an invalid
superior objectClass: " 
+                                + superior, 
+                            ResultCodeEnum.UNWILLING_TO_PERFORM );
+                    }
+                }
+            }
+            
+            // if the may list is provided make sure attributes exists in some schema
+            if ( desc.getMayAttributeTypes() != null && desc.getMayAttributeTypes().size()
> 0 )
+            {
+                for ( String mayAttr : desc.getMayAttributeTypes() )
+                {
+                    if ( ! dao.hasAttributeType( mayAttr ) )
+                    {
+                        throw new LdapOperationNotSupportedException(
+                            "Cannot permit the addition of an objectClass with an invalid
" +
+                            "attributeType in the mayList: " + mayAttr, 
+                            ResultCodeEnum.UNWILLING_TO_PERFORM );
+                    }
+                }
+            }
+            
+            // if the must list is provided make sure attributes exists in some schema
+            if ( desc.getMustAttributeTypes() != null && desc.getMustAttributeTypes().size()
> 0 )
+            {
+                for ( String mustAttr : desc.getMustAttributeTypes() )
+                {
+                    if ( ! dao.hasAttributeType( mustAttr ) )
+                    {
+                        throw new LdapOperationNotSupportedException(
+                            "Cannot permit the addition of an objectClass with an invalid
" +
+                            "attributeType in the mustList: " + mustAttr, 
+                            ResultCodeEnum.UNWILLING_TO_PERFORM );
+                    }
+                }
+            }
+            
             ObjectClassImpl oc = new ObjectClassImpl( desc.getNumericOid(), globalRegistries
);
             oc.setMayListOids( desc.getMayAttributeTypes().toArray( EMPTY) );
             oc.setMustListOids( desc.getMustAttributeTypes().toArray( EMPTY ) );

Modified: directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java?view=diff&rev=506370&r1=506369&r2=506370
==============================================================================
--- directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
(original)
+++ directory/apacheds/trunk/core/src/main/java/org/apache/directory/server/core/schema/SchemaPartitionDao.java
Mon Feb 12 00:26:40 2007
@@ -288,6 +288,49 @@
     }
     
     
+    public boolean hasObjectClass( String oid ) throws NamingException
+    {
+        BranchNode filter = new BranchNode( AssertionEnum.AND );
+        filter.addNode( new SimpleNode( OBJECTCLASS_OID, 
+            MetaSchemaConstants.META_OBJECT_CLASS_OC, AssertionEnum.EQUALITY ) );
+
+        if ( NUMERIC_OID_CHECKER.isValidSyntax( oid ) )
+        {
+            filter.addNode( new SimpleNode( M_OID_OID, oid, AssertionEnum.EQUALITY ) );
+        }
+        else
+        {
+            filter.addNode( new SimpleNode( M_NAME_OID, oid.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
);
+            
+            if ( ! ne.hasMore() )
+            {
+                return false;
+            }
+            
+            ne.next();
+            if ( ne.hasMore() )
+            {
+                throw new NamingException( "Got more than one attributeType for oid of "
+ oid );
+            }
+
+            return true;
+        }
+        finally
+        {
+            ne.close();
+        }
+    }
+    
+    
     public boolean hasSyntax( String oid ) throws NamingException
     {
         BranchNode filter = new BranchNode( AssertionEnum.AND );

Modified: directory/apacheds/trunk/pom.xml
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/pom.xml?view=diff&rev=506370&r1=506369&r2=506370
==============================================================================
--- directory/apacheds/trunk/pom.xml (original)
+++ directory/apacheds/trunk/pom.xml Mon Feb 12 00:26:40 2007
@@ -350,7 +350,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.1.3</version>
+        <version>2.3-SNAPSHOT</version>
         <configuration>
           <argLine>-Xmx1024m</argLine>
         </configuration>

Modified: directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java?view=diff&rev=506370&r1=506369&r2=506370
==============================================================================
--- directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java
(original)
+++ directory/apacheds/trunk/schema-registries/src/main/java/org/apache/directory/server/schema/registries/DefaultObjectClassRegistry.java
Mon Feb 12 00:26:40 2007
@@ -75,7 +75,15 @@
             throw e;
         }
 
-        oidRegistry.register( objectClass.getName(), objectClass.getOid() );
+        if ( objectClass.getNames() != null && objectClass.getNames().length >
0 )
+        {
+            oidRegistry.register( objectClass.getName(), objectClass.getOid() );
+        }
+        else
+        {
+            oidRegistry.register( objectClass.getOid(), objectClass.getOid() );
+        }
+        
         byOid.put( objectClass.getOid(), objectClass );
         if ( log.isDebugEnabled() )
         {



Mime
View raw message