directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r815560 - in /directory/apacheds/branches/apacheds-schema: core-entry/src/main/java/org/apache/directory/server/core/entry/ core-entry/src/test/java/org/apache/directory/server/core/entry/ core/src/main/java/org/apache/directory/server/core...
Date Tue, 15 Sep 2009 23:19:47 GMT
Author: elecharny
Date: Tue Sep 15 23:19:47 2009
New Revision: 815560

URL: http://svn.apache.org/viewvc?rev=815560&view=rev
Log:
DirectoryString are not supposed to be empty. Fixed some tests accordingly, and make the modify
operation control the attribute content only when a value is added (we don't care if the attribute
is empty if it's a replace or remove modification)

Modified:
    directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
    directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
    directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java?rev=815560&r1=815559&r2=815560&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/main/java/org/apache/directory/server/core/entry/DefaultServerAttribute.java
Tue Sep 15 23:19:47 2009
@@ -19,6 +19,7 @@
 package org.apache.directory.server.core.entry;
 
 
+import java.io.Externalizable;
 import java.io.IOException;
 import java.io.ObjectInput;
 import java.io.ObjectOutput;
@@ -739,6 +740,12 @@
             return false;
         }
 
+        // Check that we can have no value for this attributeType
+        if ( values.size() == 0 )
+        {
+            return attributeType.getSyntax().getSyntaxChecker().isValidSyntax( null );
+        }
+
         for ( Value<?> value : values )
         {
             if ( ! value.isValid() )
@@ -746,7 +753,7 @@
                 return false;
             }
         }
-
+        
         return true;
     }
 

Modified: directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java?rev=815560&r1=815559&r2=815560&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core-entry/src/test/java/org/apache/directory/server/core/entry/DefaultServerAttributeTest.java
Tue Sep 15 23:19:47 2009
@@ -571,7 +571,7 @@
         ServerAttribute attr = new DefaultServerAttribute( atCN );
         
         // No value, this should be valid
-        assertTrue( attr.isValid() );
+        assertFalse( attr.isValid() );
         
         attr.add( "test", "test2", "A123\\;" );
         assertTrue( attr.isValid() );
@@ -2094,7 +2094,7 @@
         assertEquals( "cn", dsaSer.getUpId() );
         assertEquals( 0, dsaSer.size() );
         assertTrue( dsaSer.isHR() );
-        assertTrue( dsaSer.isValid() );
+        assertFalse( dsaSer.isValid() );
     }
     
     

Modified: directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java?rev=815560&r1=815559&r2=815560&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
(original)
+++ directory/apacheds/branches/apacheds-schema/core/src/main/java/org/apache/directory/server/core/schema/SchemaInterceptor.java
Tue Sep 15 23:19:47 2009
@@ -1209,19 +1209,19 @@
                 throw new NoPermissionException( msg );
             }
             
-            // Check the syntax here
-            if ( !attribute.isValid() )
-            {
-                // The value syntax is incorrect : this is an error
-                String msg = "The new Attribute or one of its value is incorrect : " + attributeType;
-                LOG.error( msg );
-                throw new LdapInvalidAttributeValueException( msg, 
-                    ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
-            }
-
             switch ( mod.getOperation() )
             {
                 case ADD_ATTRIBUTE :
+                    // Check the syntax here
+                    if ( !attribute.isValid() )
+                    {
+                        // The value syntax is incorrect : this is an error
+                        String msg = "The new Attribute or one of its value is incorrect
: " + attributeType;
+                        LOG.error( msg );
+                        throw new LdapInvalidAttributeValueException( msg, 
+                            ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX );
+                    }
+
                     EntryAttribute currentAttribute = tempEntry.get( attributeType );
                     
                     // First check if the added Attribute is already present in the entry



Mime
View raw message