directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r896090 - in /directory/apacheds/branches/apacheds-schema: core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
Date Tue, 05 Jan 2010 15:18:56 GMT
Author: elecharny
Date: Tue Jan  5 15:18:55 2010
New Revision: 896090

URL: http://svn.apache.org/viewvc?rev=896090&view=rev
Log:
Fixed the ModifyReplace errors.

Modified:
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
    directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java?rev=896090&r1=896089&r2=896090&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/ServerEntryUtils.java
Tue Jan  5 15:18:55 2010
@@ -40,6 +40,7 @@
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.entry.Value;
+import org.apache.directory.shared.ldap.exception.LdapInvalidAttributeIdentifierException;
 import org.apache.directory.shared.ldap.name.LdapDN;
 import org.apache.directory.shared.ldap.schema.AttributeType;
 import org.apache.directory.shared.ldap.schema.SchemaManager;
@@ -458,25 +459,21 @@
                 // DIRSERVER-646 Fix: Replacing an unknown attribute with no values 
                 // (deletion) causes an error
                 // -------------------------------------------------------------------
-                
-                // TODO - after removing JNDI we need to make the server handle 
-                // this in the codec
-                
                 if ( ! schemaManager.getAttributeTypeRegistry().contains( id ) 
                      && modification.getAttribute().size() == 0 
                      && modification.getOperation() == ModificationOperation.REPLACE_ATTRIBUTE
)
                 {
-                    continue;
+                    // The attributeType does not exist in the schema.
+                    // It's an error
+                    String message = "The AttributeType '" + id + "' does not exist in the
schema";
+                    throw new LdapInvalidAttributeIdentifierException( message );
+                }
+                else
+                {
+                    // TODO : handle options
+                    AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry(
id );
+                    modificationsList.add( toServerModification( modification, attributeType
) );
                 }
-
-                // -------------------------------------------------------------------
-                // END DIRSERVER-646 Fix
-                // -------------------------------------------------------------------
-                
-                
-                // TODO : handle options
-                AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry(
id );
-                modificationsList.add( toServerModification( modification, attributeType
) );
             }
         
             return modificationsList;

Modified: directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java?rev=896090&r1=896089&r2=896090&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
(original)
+++ directory/apacheds/branches/apacheds-schema/server-integ/src/test/java/org/apache/directory/server/operations/modify/ModifyReplaceIT.java
Tue Jan  5 15:18:55 2010
@@ -25,6 +25,7 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 
 import javax.naming.NamingEnumeration;
 import javax.naming.directory.Attribute;
@@ -32,6 +33,7 @@
 import javax.naming.directory.BasicAttribute;
 import javax.naming.directory.BasicAttributes;
 import javax.naming.directory.DirContext;
+import javax.naming.directory.InvalidAttributeIdentifierException;
 import javax.naming.directory.ModificationItem;
 import javax.naming.directory.SearchControls;
 import javax.naming.directory.SearchResult;
@@ -81,7 +83,6 @@
 public class ModifyReplaceIT extends AbstractLdapTestUnit 
 {
     private static final String BASE = "ou=system";
-
     
     /**
      * Create a person entry and try to remove a not present attribute
@@ -166,7 +167,15 @@
         Attribute attr = new BasicAttribute( "numberOfOctaves" );
         ModificationItem item = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr
);
 
-        sysRoot.modifyAttributes( rdn, new ModificationItem[] { item } );
+        try
+        {
+            sysRoot.modifyAttributes( rdn, new ModificationItem[] { item } );
+            fail();
+        }
+        catch ( InvalidAttributeIdentifierException iaie )
+        {
+            assertTrue( true );
+        }
 
         SearchControls sctls = new SearchControls();
         sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
@@ -200,7 +209,15 @@
         Attribute attr2 = new BasicAttribute( "description", "blah blah blah" );
         ModificationItem item2 = new ModificationItem( DirContext.ADD_ATTRIBUTE, attr2 );
 
-        sysRoot.modifyAttributes(rdn, new ModificationItem[] { item, item2 });
+        try
+        {
+            sysRoot.modifyAttributes(rdn, new ModificationItem[] { item, item2 });
+            fail();
+        }
+        catch ( InvalidAttributeIdentifierException iaie )
+        {
+            assertTrue( true );
+        }
 
         SearchControls sctls = new SearchControls();
         sctls.setSearchScope( SearchControls.SUBTREE_SCOPE );



Mime
View raw message