directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r498885 - /directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Date Tue, 23 Jan 2007 01:27:25 GMT
Author: akarasulu
Date: Mon Jan 22 17:27:24 2007
New Revision: 498885

URL: http://svn.apache.org/viewvc?view=rev&rev=498885
Log:
better error reporting for certain kinds of schema errors

Modified:
    directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java

Modified: directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java?view=diff&rev=498885&r1=498884&r2=498885
==============================================================================
--- directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
(original)
+++ directory/apacheds/branches/1.0/core/src/main/java/org/apache/directory/server/core/schema/SchemaService.java
Mon Jan 22 17:27:24 2007
@@ -1314,7 +1314,7 @@
             }
         }
 
-        check( tmpEntry );
+        check( name, tmpEntry );
         
         // let's figure out if we need to add or take away from mods to maintain 
         // the objectClass attribute with it's hierarchy of ancestors 
@@ -1488,7 +1488,7 @@
         }
     }
 
-    private void check( Attributes entry ) throws NamingException
+    private void check( LdapDN dn, Attributes entry ) throws NamingException
     {
         NamingEnumeration attrEnum = entry.getIDs();
         
@@ -1522,12 +1522,12 @@
 
         boolean hasExtensibleObject = getObjectClasses( objectClassAttr, ocs );
         
-        assertRequiredAttributesPresent( entry, must );
+        assertRequiredAttributesPresent( dn, entry, must );
         assertNumberOfAttributeValuesValid( entry );
 
         if ( !hasExtensibleObject )
         {
-            assertAllAttributesAllowed( entry, allowed );
+            assertAllAttributesAllowed( dn, entry, allowed );
         }
     }
     
@@ -1536,7 +1536,7 @@
      */
     public void add( NextInterceptor next, LdapDN normName, Attributes attrs ) throws NamingException
     {
-        check( attrs );
+        check( normName, attrs );
         next.add(normName, attrs );
     }
     
@@ -1572,28 +1572,27 @@
     /**
      * Checks to see the presence of all required attributes within an entry.
      */
-    private void assertRequiredAttributesPresent( Attributes entry, Set must ) 
+    private void assertRequiredAttributesPresent( LdapDN dn, Attributes entry, Set must )

         throws NamingException
     {
         NamingEnumeration attributes = entry.getAll();
         
         while ( attributes.hasMoreElements() && ( must.size() > 0 ) )
         {
-            Attribute attribute = (Attribute)attributes.nextElement();
-            
+            Attribute attribute = ( Attribute ) attributes.nextElement();
             String oid = globalRegistries.getOidRegistry().getOid( attribute.getID() );
-            
             must.remove( oid );
         }
         
         if ( must.size() != 0 )
         {
             throw new LdapSchemaViolationException( "Required attributes " + 
-                must.toArray() + " not found within entry.", 
+                must + " not found within entry " + dn.getUpName(), 
                 ResultCodeEnum.OBJECTCLASSVIOLATION );
         }
     }
     
+    
     /**
      * Checks to see if an attribute is required by as determined from an entry's
      * set of objectClass attribute values.
@@ -1603,7 +1602,7 @@
      * @return true if the objectClass values require the attribute, false otherwise
      * @throws NamingException if the attribute is not recognized
      */
-    private void assertAllAttributesAllowed( Attributes attributes, Set allowed ) throws
NamingException
+    private void assertAllAttributesAllowed( LdapDN dn, Attributes attributes, Set allowed
) throws NamingException
     {
         // Never check the attributes if the extensibleObject objectClass is
         // declared for this entry
@@ -1629,7 +1628,7 @@
                 if ( !allowed.contains( attrOid ) )
                 {
                     throw new LdapSchemaViolationException( "Attribute " + 
-                        attribute.getID() + " not declared in entry's objectClasses.", 
+                        attribute.getID() + " not declared in objectClasses of entry " +
dn.getUpName(), 
                         ResultCodeEnum.OBJECTCLASSVIOLATION );
                 }
             }



Mime
View raw message