directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1085789 [2/4] - in /directory/shared/trunk: dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/ dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ dsml/parser/src/test/java/org/apache/directory/shared/d...
Date Sat, 26 Mar 2011 19:17:42 GMT
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java Sat Mar 26 19:17:40 2011
@@ -80,23 +80,12 @@ public class DefaultEntryAttribute imple
         
         if ( attributeType != null )
         {
-            stringValue = new StringValue( attributeType, value );
-            
             try
             {
-                stringValue.normalize();
+                stringValue = new StringValue( attributeType, value );
             }
-            catch( LdapException ne )
-            {
-                // The value can't be normalized : we don't add it.
-                LOG.error( I18n.err( I18n.ERR_04449, value ) );
-                return null;
-            }
-    
-            if ( !stringValue.isValid() )
+            catch ( LdapInvalidAttributeValueException iae )
             {
-                // The value is not valid : we don't add it.
-                LOG.error( I18n.err( I18n.ERR_04450, value ) );
                 return null;
             }
         }
@@ -109,31 +98,13 @@ public class DefaultEntryAttribute imple
     }
 
 
-    private Value<byte[]> createBinaryValue( AttributeType attributeType, byte[] value )
+    private Value<byte[]> createBinaryValue( AttributeType attributeType, byte[] value ) throws LdapInvalidAttributeValueException
     {
         Value<byte[]> binaryValue = null;
         
         if ( attributeType != null )
         {
             binaryValue = new BinaryValue( attributeType, value );
-            
-            try
-            {
-                binaryValue.normalize();
-            }
-            catch( LdapException ne )
-            {
-                // The value can't be normalized : we don't add it.
-                LOG.error( I18n.err( I18n.ERR_04449, value ) );
-                return null;
-            }
-            
-            if ( !binaryValue.isValid() )
-            {
-                // The value is not valid : we don't add it.
-                LOG.error( I18n.err( I18n.ERR_04450, value ) );
-                return null;
-            }
         }
         else
         {
@@ -188,7 +159,14 @@ public class DefaultEntryAttribute imple
     {
         if ( attributeType != null )
         {
-            setAttributeType( attributeType );
+            try
+            {
+                setAttributeType( attributeType );
+            }
+            catch ( LdapInvalidAttributeValueException liave )
+            {
+                // Do nothing, it can't happen, there is no value
+            }
         }
     }
 
@@ -217,7 +195,15 @@ public class DefaultEntryAttribute imple
             throw new IllegalArgumentException( message );
         }
 
-        setAttributeType( attributeType );
+        try
+        { 
+            setAttributeType( attributeType );
+        }
+        catch ( LdapInvalidAttributeValueException liave )
+        {
+            // Do nothing, it can't happen, there is no value
+        }
+            
         setUpId( upId, attributeType );
     }
 
@@ -243,7 +229,7 @@ public class DefaultEntryAttribute imple
         {
             for ( Value<?> val:vals )
             {
-                if ( ( val instanceof StringValue) || ( val.isBinary() ) )
+                if ( ( val instanceof StringValue) || ( !val.isHR() ) )
                 {
                     add( val );
                 }
@@ -266,7 +252,7 @@ public class DefaultEntryAttribute imple
      * @param attributeType The attributeType added on creation
      * @param vals The added value for this attribute
      */
-    public DefaultEntryAttribute( AttributeType attributeType, String... vals )
+    public DefaultEntryAttribute( AttributeType attributeType, String... vals ) throws LdapInvalidAttributeValueException
     {
         this( null, attributeType, vals );
     }
@@ -279,7 +265,7 @@ public class DefaultEntryAttribute imple
      * @param attributeType The attributeType added on creation
      * @param vals the added values for this attribute
      */
-    public DefaultEntryAttribute( String upId, AttributeType attributeType, String... vals )
+    public DefaultEntryAttribute( String upId, AttributeType attributeType, String... vals ) throws LdapInvalidAttributeValueException
     {
         if ( attributeType == null )
         {
@@ -307,7 +293,7 @@ public class DefaultEntryAttribute imple
      * @param attributeType the attribute type according to the schema
      * @param vals an initial set of values for this attribute
      */
-    public DefaultEntryAttribute( String upId, AttributeType attributeType, Value<?>... vals )
+    public DefaultEntryAttribute( String upId, AttributeType attributeType, Value<?>... vals ) throws LdapInvalidAttributeValueException
     {
         if ( attributeType == null )
         {
@@ -332,7 +318,7 @@ public class DefaultEntryAttribute imple
      * @param attributeType the attribute type according to the schema
      * @param vals an initial set of values for this attribute
      */
-    public DefaultEntryAttribute( AttributeType attributeType, Value<?>... vals )
+    public DefaultEntryAttribute( AttributeType attributeType, Value<?>... vals ) throws LdapInvalidAttributeValueException
     {
         this( null, attributeType, vals );
     }
@@ -343,7 +329,15 @@ public class DefaultEntryAttribute imple
      */
     public DefaultEntryAttribute( String upId, String... vals )
     {
-        add( vals );
+        try
+        {
+            add( vals );
+        }
+        catch ( LdapInvalidAttributeValueException liave )
+        {
+            // Do nothing, it can't happen
+        }
+        
         setUpId( upId );
     }
 
@@ -353,7 +347,15 @@ public class DefaultEntryAttribute imple
      */
     public DefaultEntryAttribute( String upId, byte[]... vals )
     {
-        add( vals );
+        try
+        { 
+            add( vals );
+        }
+        catch ( LdapInvalidAttributeValueException liave )
+        {
+            // Do nothing, this can't happen
+        }
+        
         setUpId( upId );
     }
 
@@ -364,7 +366,7 @@ public class DefaultEntryAttribute imple
      * @param attributeType The attributeType added on creation
      * @param vals The value for the added attribute
      */
-    public DefaultEntryAttribute( AttributeType attributeType, byte[]... vals )
+    public DefaultEntryAttribute( AttributeType attributeType, byte[]... vals ) throws LdapInvalidAttributeValueException
     {
         this( null, attributeType, vals );
     }
@@ -377,7 +379,7 @@ public class DefaultEntryAttribute imple
      * @param attributeType the AttributeType to be added
      * @param vals the values for the added attribute
      */
-    public DefaultEntryAttribute( String upId, AttributeType attributeType, byte[]... vals )
+    public DefaultEntryAttribute( String upId, AttributeType attributeType, byte[]... vals ) throws LdapInvalidAttributeValueException
     {
         if ( attributeType == null )
         {
@@ -399,7 +401,7 @@ public class DefaultEntryAttribute imple
      * @param attributeType The attribute's type 
      * @param attribute The attribute to be copied
      */
-    public DefaultEntryAttribute( AttributeType attributeType, EntryAttribute attribute )
+    public DefaultEntryAttribute( AttributeType attributeType, EntryAttribute attribute ) throws LdapException
     {
         // Copy the common values. isHR is only available on a ServerAttribute 
         this.attributeType = attributeType;
@@ -476,16 +478,14 @@ public class DefaultEntryAttribute imple
     {
         Value<?> value = get();
         
-        if ( value.isBinary() )
-        {
-            return value.getBytes();
-        }
-        else
+        if ( value.isHR() )
         {
             String message = I18n.err( I18n.ERR_04130 );
             LOG.error( message );
             throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
         }
+
+        return value.getBytes();
     }
 
 
@@ -753,14 +753,6 @@ public class DefaultEntryAttribute imple
             }
         }
 
-        for ( Value<?> value:values )
-        {
-            if ( !value.isValid() )
-            {
-                return false;
-            }
-        }
-
         return true;
     }
 
@@ -840,25 +832,39 @@ public class DefaultEntryAttribute imple
                 {
                     if ( ( val == null ) || val.isNull() )
                     {
-                        Value<String> nullSV = new StringValue( attributeType, (String)null );
-                        
-                        if ( values.add( nullSV ) )
+                        try
+                        {        
+                            Value<String> nullSV = new StringValue( attributeType, (String)null );
+                            
+                            if ( values.add( nullSV ) )
+                            {
+                                nbAdded++;
+                            }
+                        }
+                        catch ( LdapInvalidAttributeValueException iae )
                         {
-                            nbAdded++;
+                            continue;
                         }
                     }
                     else if ( val instanceof StringValue)
                     {
                         StringValue stringValue = (StringValue)val;
                         
-                        if ( stringValue.getAttributeType() == null )
-                        {
-                            stringValue.apply( attributeType );
+                        try
+                        { 
+                            if ( stringValue.getAttributeType() == null )
+                            {
+                                stringValue.apply( attributeType );
+                            }
+                            
+                            if ( values.add( val ) )
+                            {
+                                nbAdded++;
+                            }
                         }
-                        
-                        if ( values.add( val ) )
+                        catch ( LdapInvalidAttributeValueException iae )
                         {
-                            nbAdded++;
+                            continue;
                         }
                     }
                     else
@@ -873,11 +879,18 @@ public class DefaultEntryAttribute imple
                     {
                         if ( attributeType.getSyntax().getSyntaxChecker().isValidSyntax( val ) )
                         {
-                            Value<byte[]> nullSV = new BinaryValue( attributeType, (byte[])null );
-                            
-                            if ( values.add( nullSV ) )
+                            try
                             {
-                                nbAdded++;
+                                Value<byte[]> nullSV = new BinaryValue( attributeType, (byte[])null );
+                                
+                                if ( values.add( nullSV ) )
+                                {
+                                    nbAdded++;
+                                }
+                            }
+                            catch ( LdapInvalidAttributeValueException iae )
+                            {
+                                continue;
                             }
                         }
                         else
@@ -892,14 +905,21 @@ public class DefaultEntryAttribute imple
                         {
                             BinaryValue binaryValue = (BinaryValue)val;
                             
-                            if ( binaryValue.getAttributeType() == null )
+                            try
                             {
-                                binaryValue = new BinaryValue( attributeType, val.getBytes() ); 
+                                if ( binaryValue.getAttributeType() == null )
+                                {
+                                    binaryValue = new BinaryValue( attributeType, val.getBytes() ); 
+                                }
+            
+                                if ( values.add( binaryValue ) )
+                                {
+                                    nbAdded++;
+                                }
                             }
-        
-                            if ( values.add( binaryValue ) )
+                            catch ( LdapInvalidAttributeValueException iae )
                             {
-                                nbAdded++;
+                                continue;
                             }
                         }
                         else
@@ -1054,7 +1074,7 @@ public class DefaultEntryAttribute imple
     /**
      * @see EntryAttribute#add(String...)
      */
-    public int add( String... vals )
+    public int add( String... vals ) throws LdapInvalidAttributeValueException
     {
         int nbAdded = 0;
         
@@ -1209,7 +1229,7 @@ public class DefaultEntryAttribute imple
      * @param vals some new values to be added which may be null
      * @return the number of added values, or 0 if none has been added
      */
-    public int add( byte[]... vals )
+    public int add( byte[]... vals ) throws LdapInvalidAttributeValueException
     {
         int nbAdded = 0;
         
@@ -1232,18 +1252,7 @@ public class DefaultEntryAttribute imple
                 }
                 else
                 {
-                    value = new BinaryValue( attributeType, val );
-                    
-                    try
-                    {
-                        value.normalize();
-                    }
-                    catch( LdapException ne )
-                    {
-                        // The value can't be normalized : we don't add it.
-                        LOG.error( I18n.err( I18n.ERR_04449, Strings.dumpBytes(val) ) );
-                        return 0;
-                    }
+                    value = createBinaryValue( attributeType, val );
                 }
                 
                 if ( add( value ) != 0 )
@@ -1331,19 +1340,19 @@ public class DefaultEntryAttribute imple
                 // contained in the object
                 for ( Value<?> val:vals )
                 {
-                    if ( val.isBinary() )
+                    if ( val.isHR() )
                     {
-                        if ( !values.contains( val ) )
+                        String stringVal = val.getString();
+                        
+                        // We have to convert the binary value to a String
+                        if ( ! values.contains( new BinaryValue( Strings.getBytesUtf8(stringVal) ) ) )
                         {
                             return false;
                         }
                     }
                     else
                     {
-                        String stringVal = val.getString();
-                        
-                        // We have to convert the binary value to a String
-                        if ( ! values.contains( new BinaryValue( Strings.getBytesUtf8(stringVal) ) ) )
+                        if ( !values.contains( val ) )
                         {
                             return false;
                         }
@@ -1364,9 +1373,16 @@ public class DefaultEntryAttribute imple
                     {
                         StringValue stringValue = (StringValue)val;
                         
-                        if ( stringValue.getAttributeType() == null )
+                        try
                         {
-                            stringValue.apply( attributeType );
+                            if ( stringValue.getAttributeType() == null )
+                            {
+                                stringValue.apply( attributeType );
+                            }
+                        }
+                        catch ( LdapInvalidAttributeValueException liave )
+                        {
+                            return false;
                         }
                         
                         if ( !values.contains( val ) )
@@ -1430,8 +1446,14 @@ public class DefaultEntryAttribute imple
             {
                 for ( String val:vals )
                 {
-                    
-                    if ( !contains( new StringValue( val ) ) )
+                    try
+                    {
+                        if ( !contains( new StringValue( val ) ) )
+                        {
+                            return false;
+                        }
+                    }
+                    catch ( IllegalArgumentException iae )
                     {
                         return false;
                     }
@@ -1462,9 +1484,16 @@ public class DefaultEntryAttribute imple
                 // don't find one in the values
                 for ( String val:vals )
                 {
-                    StringValue value = new StringValue( attributeType, val );
-                    
-                    if ( !values.contains( value ) )
+                    try
+                    {
+                        StringValue value = new StringValue( attributeType, val );
+                        
+                        if ( !values.contains( value ) )
+                        {
+                            return false;
+                        }
+                    }
+                    catch ( LdapInvalidAttributeValueException liave )
                     {
                         return false;
                     }
@@ -1540,18 +1569,16 @@ public class DefaultEntryAttribute imple
                 // don't find one in the values
                 for ( byte[] val:vals )
                 {
-                    BinaryValue value = new BinaryValue( attributeType, val );
-                    
                     try
-                    {
-                        value.normalize();
-                    }
-                    catch ( LdapException ne )
-                    {
-                        return false;
-                    }
+                    {   
+                        BinaryValue value = new BinaryValue( attributeType, val );
                     
-                    if ( !values.contains( value ) )
+                        if ( !values.contains( value ) )
+                        {
+                            return false;
+                        }
+                    }
+                    catch ( LdapInvalidAttributeValueException liave )
                     {
                         return false;
                     }
@@ -1787,12 +1814,19 @@ public class DefaultEntryAttribute imple
                     {
                         StringValue stringValue = (StringValue)val;
                         
-                        if ( stringValue.getAttributeType() == null )
+                        try
                         {
-                            stringValue.apply( attributeType );
-                        }
+                            if ( stringValue.getAttributeType() == null )
+                            {
+                                stringValue.apply( attributeType );
+                            }
                         
-                        removed &= values.remove( stringValue );
+                            removed &= values.remove( stringValue );
+                        }
+                        catch ( LdapInvalidAttributeValueException liave )
+                        {
+                            removed = false;
+                        }
                     }
                     else
                     {
@@ -1806,14 +1840,21 @@ public class DefaultEntryAttribute imple
                 {
                     if ( val instanceof BinaryValue )
                     {
-                        BinaryValue binaryValue = (BinaryValue)val;
-                        
-                        if ( binaryValue.getAttributeType() == null )
+                        try
+                        {
+                            BinaryValue binaryValue = (BinaryValue)val;
+                            
+                            if ( binaryValue.getAttributeType() == null )
+                            {
+                                binaryValue.apply( attributeType );
+                            }
+                            
+                            removed &= values.remove( binaryValue );
+                        }
+                        catch ( LdapInvalidAttributeValueException liave )
                         {
-                            binaryValue.apply( attributeType );
+                            removed = false;
                         }
-                        
-                        removed &= values.remove( binaryValue );
                     }
                     else
                     {
@@ -1878,10 +1919,17 @@ public class DefaultEntryAttribute imple
         {
             if ( !isHR ) 
             {
-                for ( byte[] val:vals )
+                try
                 {
-                    BinaryValue value = new BinaryValue( attributeType, val );
-                    removed &= values.remove( value );
+                    for ( byte[] val:vals )
+                    {
+                        BinaryValue value = new BinaryValue( attributeType, val );
+                        removed &= values.remove( value );
+                    }
+                }
+                catch ( LdapInvalidAttributeValueException liave )
+                {
+                    removed = false;
                 }
             }
             else
@@ -1945,8 +1993,15 @@ public class DefaultEntryAttribute imple
             {
                 for ( String val:vals )
                 {
-                    StringValue value = new StringValue( attributeType, val );
-                    removed &= values.remove( value );
+                    try
+                    {
+                        StringValue value = new StringValue( attributeType, val );
+                        removed &= values.remove( value );
+                    }
+                    catch ( LdapInvalidAttributeValueException liave )
+                    {
+                        removed = false;
+                    }
                 }
             }
             else
@@ -1993,7 +2048,7 @@ public class DefaultEntryAttribute imple
      *
      * @param attributeType the attributeType associated with this entry attribute
      */
-    public void setAttributeType( AttributeType attributeType )
+    public void setAttributeType( AttributeType attributeType ) throws LdapInvalidAttributeValueException
     {
         if ( attributeType == null )
         {
@@ -2332,7 +2387,7 @@ public class DefaultEntryAttribute imple
     /**
      * {@inheritDoc}
      */
-    public void applySchemaManager( SchemaManager schemaManager )
+    public void applySchemaManager( SchemaManager schemaManager ) throws LdapInvalidAttributeValueException
     {
         AttributeType attributeType = null;
         

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java Sat Mar 26 19:17:40 2011
@@ -25,6 +25,7 @@ import java.io.ObjectOutput;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.slf4j.Logger;
@@ -177,7 +178,7 @@ public class DefaultModification impleme
     /**
      * {@inheritDoc}
      */
-    public void applyAttributeType( AttributeType attributeType )
+    public void applyAttributeType( AttributeType attributeType ) throws LdapInvalidAttributeValueException
     {
         this.attributeType = attributeType;
         

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java Sat Mar 26 19:17:40 2011
@@ -71,7 +71,7 @@ public interface EntryAttribute extends 
      * @param vals some new values to be added which may be null
      * @return the number of added values, or 0 if none has been added
      */
-    int add( String... vals );
+    int add( String... vals ) throws LdapInvalidAttributeValueException;
 
 
     /**
@@ -102,7 +102,7 @@ public interface EntryAttribute extends 
      * @param vals some new values to be added which may be null
      * @return the number of added values, or 0 if none has been added
      */
-    int add( byte[]... vals );
+    int add( byte[]... vals ) throws LdapInvalidAttributeValueException;
 
 
     /**
@@ -143,7 +143,7 @@ public interface EntryAttribute extends 
      * @param val some new values to be added which may be null
      * @return the number of added values, or 0 if none has been added
      */
-    int add( Value<?>... val );
+    int add( Value<?>... val ) throws LdapInvalidAttributeValueException;
     
     
     /**
@@ -221,7 +221,7 @@ public interface EntryAttribute extends 
      *
      * @param attributeType the attributeType associated with this entry attribute
      */
-    void setAttributeType( AttributeType attributeType );
+    void setAttributeType( AttributeType attributeType ) throws LdapInvalidAttributeValueException;
 
     
     /**
@@ -492,5 +492,5 @@ public interface EntryAttribute extends 
     /**
      * Apply the give SchemaManager to make this EntryAttribute Schema aware
      */
-    void applySchemaManager( SchemaManager schemaManager );
+    void applySchemaManager( SchemaManager schemaManager ) throws LdapInvalidAttributeValueException;
 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java Sat Mar 26 19:17:40 2011
@@ -98,6 +98,11 @@ public class EntryUtils
         {
             public boolean isValidSyntax( Object value )
             {
+                if ( value == null )
+                {
+                    return true;
+                }
+                
                 if ( !( value instanceof String ) )
                 {
                     return false;
@@ -134,7 +139,7 @@ public class EntryUtils
         {
             public Value<?> normalize( Value<?> value ) throws LdapException
             {
-                if ( !value.isBinary() )
+                if ( value.isHR() )
                 {
                     return new StringValue( value.getString().toLowerCase() );
                 }
@@ -145,7 +150,7 @@ public class EntryUtils
             
             public String normalize( String value ) throws LdapException
             {
-                return value.toLowerCase();
+                return Strings.toLowerCase( value );
             }
         };
         
@@ -217,7 +222,7 @@ public class EntryUtils
         {
             public Value<?> normalize( Value<?> value ) throws LdapException
             {
-                if ( value.isBinary() )
+                if ( !value.isHR() )
                 {
                     byte[] val = value.getBytes();
                     

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Modification.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Modification.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Modification.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Modification.java Sat Mar 26 19:17:40 2011
@@ -21,6 +21,7 @@ package org.apache.directory.shared.ldap
 
 import java.io.Externalizable;
 
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 
 /**
@@ -80,5 +81,5 @@ public interface Modification extends Cl
      * 
      * @param AttributeType the injected AttributeType
      */
-    void applyAttributeType( AttributeType attributeType );
+    void applyAttributeType( AttributeType attributeType ) throws LdapInvalidAttributeValueException;
 }
\ No newline at end of file

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java Sat Mar 26 19:17:40 2011
@@ -25,6 +25,7 @@ import java.io.ObjectOutput;
 
 import org.apache.directory.shared.i18n.I18n;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.ldap.model.schema.LdapComparator;
 import org.apache.directory.shared.ldap.model.schema.Normalizer;
@@ -53,7 +54,6 @@ public class StringValue extends Abstrac
      */
     public StringValue()
     {
-        normalized = false;
         valid = null;
     }
 
@@ -91,7 +91,7 @@ public class StringValue extends Abstrac
     public StringValue( String value )
     {
         this.wrappedValue = value;
-        normalized = false;
+        this.normalizedValue = value;
         valid = null;
     }
 
@@ -101,11 +101,13 @@ public class StringValue extends Abstrac
      *
      * @param attributeType the schema type associated with this StringValue
      * @param value the value to wrap which can be null
+     * @throws LdapInvalidAttributeValueException If the added value is invalid accordingly 
+     * to the schema
      */
-    public StringValue( AttributeType attributeType, String value )
+    public StringValue( AttributeType attributeType, String value ) throws LdapInvalidAttributeValueException
     {
-        this( attributeType );
-        this.wrappedValue = value;
+        this( value );
+        apply( attributeType );
     }
 
 
@@ -135,88 +137,17 @@ public class StringValue extends Abstrac
      *
      * @return gets the normalized value
      */
-    public String getNormalizedValue()
+    public String getNormValue()
     {
         if ( isNull() )
         {
-            normalized = true;
             return null;
         }
 
-        if ( !normalized )
-        {
-            try
-            {
-                normalize();
-            }
-            catch ( LdapException ne )
-            {
-                String message = "Cannot normalize the value :" + ne.getLocalizedMessage();
-                LOG.info( message );
-                normalized = false;
-            }
-        }
-        
-        if ( normalizedValue == null )
-        {
-            return wrappedValue;
-        }
-
         return normalizedValue;
     }
     
     
-    /**
-     * Compute the normalized (canonical) representation for the wrapped string.
-     * If the wrapped String is null, the normalized form will be null too.  
-     *
-     * @throws LdapException if the value cannot be properly normalized
-     */
-    public void normalize() throws LdapException
-    {
-        // If the value is already normalized, get out.
-        if ( normalized )
-        {
-            return;
-        }
-        
-        if ( attributeType != null )
-        {
-            Normalizer normalizer = getNormalizer();
-    
-            if ( normalizer == null )
-            {
-                normalizedValue = wrappedValue;
-            }
-            else
-            {
-                normalizedValue = ( String ) normalizer.normalize( wrappedValue );
-            }
-    
-            normalized = true;
-        }
-    }
-
-    
-    /**
-     * Normalize the value. For a client String value, applies the given normalizer.
-     * 
-     * It supposes that the client has access to the schema in order to select the
-     * appropriate normalizer.
-     * 
-     * @param normalizer The normalizer to apply to the value
-     * @exception LdapException If the value cannot be normalized
-     */
-    public final void normalize( Normalizer normalizer ) throws LdapException
-    {
-        if ( normalizer != null )
-        {
-            normalizedValue = (String)normalizer.normalize( wrappedValue );
-            normalized = true;
-        }
-    }
-
-    
     // -----------------------------------------------------------------------
     // Comparable<String> Methods
     // -----------------------------------------------------------------------
@@ -256,7 +187,7 @@ public class StringValue extends Abstrac
         {
             if ( stringValue.getAttributeType() == null )
             {
-                return getNormalizedValue().compareTo( stringValue.getNormalizedValue() );
+                return getNormValue().compareTo( stringValue.getNormValue() );
             }
             else
             {
@@ -270,12 +201,12 @@ public class StringValue extends Abstrac
         }
         else 
         {
-            return getNormalizedValue().compareTo( stringValue.getNormalizedValue() );
+            return getNormValue().compareTo( stringValue.getNormValue() );
         }
             
         try
         {
-            return getLdapComparator().compare( getNormalizedValue(), stringValue.getNormalizedValue() );
+            return getLdapComparator().compare( getNormValue(), stringValue.getNormValue() );
         }
         catch ( LdapException e )
         {
@@ -322,7 +253,7 @@ public class StringValue extends Abstrac
             // which cannot be null at this point.
             // If the normalized value is null, will default to wrapped
             // which cannot be null at this point.
-            String normalized = getNormalizedValue();
+            String normalized = getNormValue();
             
             if ( normalized != null )
             {
@@ -388,12 +319,12 @@ public class StringValue extends Abstrac
             }
             else
             {
-                return this.getNormalizedValue().equals( other.getNormalizedValue() );
+                return this.getNormValue().equals( other.getNormValue() );
             }
         }
         else if ( other.attributeType != null )
         {
-            return this.getNormalizedValue().equals( other.getNormalizedValue() );
+            return this.getNormValue().equals( other.getNormValue() );
         }
 
         // Shortcut : compare the values without normalization
@@ -414,13 +345,13 @@ public class StringValue extends Abstrac
                 // Compare normalized values
                 if ( comparator == null )
                 {
-                    return getNormalizedValue().equals( other.getNormalizedValue() );
+                    return getNormValue().equals( other.getNormValue() );
                 }
                 else
                 {
-                    if ( isNormalized() )
+                    if ( isSchemaAware() )
                     {
-                        return comparator.compare( getNormalizedValue(), other.getNormalizedValue() ) == 0;
+                        return comparator.compare( getNormValue(), other.getNormValue() ) == 0;
                     }
                     else
                     {
@@ -436,19 +367,17 @@ public class StringValue extends Abstrac
         }
         else
         {
-            return this.getNormalizedValue().equals( other.getNormalizedValue() );
+            return this.getNormValue().equals( other.getNormValue() );
         }
     }
     
     
     /**
-     * Tells if the current value is Binary or String
-     * 
-     * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
+     * {@inheritDoc}
      */
-    public boolean isBinary()
+    public boolean isHR()
     {
-        return false;
+        return true;
     }
 
     
@@ -502,7 +431,7 @@ public class StringValue extends Abstrac
         }
         
         // Read the isNormalized flag
-        normalized = in.readBoolean();
+        boolean normalized = in.readBoolean();
         
         if ( normalized ) 
         {
@@ -542,7 +471,7 @@ public class StringValue extends Abstrac
         }
         
         // Write the isNormalized flag
-        if ( normalized )
+        if ( attributeType != null )
         {
             // This flag is present to tell that we have a normalized value different 
             // from the upValue

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Value.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Value.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Value.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Value.java Sat Mar 26 19:17:40 2011
@@ -23,8 +23,8 @@ package org.apache.directory.shared.ldap
 import java.io.Externalizable;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
-import org.apache.directory.shared.ldap.model.schema.Normalizer;
 import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
 
 
@@ -36,7 +36,7 @@ import org.apache.directory.shared.ldap.
  */
 public interface Value<T> extends Cloneable, Externalizable, Comparable<Value<T>>
 {
-    /** Two flags used to tll if the value is HR or not in serialization */
+    /** Two flags used to tell if the value is HR or not in serialization */
     public static final boolean STRING = true;
     public static final boolean BINARY = false;
 
@@ -44,11 +44,15 @@ public interface Value<T> extends Clonea
      * Apply an AttributeType to the current Value, normalizing it.
      *
      * @param attributeType The AttributeType to apply
+     * @throws LdapInvalidAttributeValueException If the value is not valid accordingly
+     * to the schema
      */
-    void apply( AttributeType attributeType );
+    void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException;
     
 
     /**
+     * Clone a Value
+     * 
      * @return A cloned value
      */
     Value<T> clone();
@@ -112,11 +116,11 @@ public interface Value<T> extends Clonea
     
     
     /**
-     * Gets a reference to the wrapped binary value.
+     * Gets a reference to the wrapped value.
      * 
      * Warning ! The value is not copied !!!
      *
-     * @return a direct handle on the binary value that is wrapped
+     * @return a direct handle on the value that is wrapped
      */
     T getReference();
     
@@ -126,21 +130,9 @@ public interface Value<T> extends Clonea
      *
      * @return <code>true</code> if the value has already been normalized.
      */
-    boolean isNormalized();
+    boolean isSchemaAware();
     
     
-    /** 
-     * Uses the syntaxChecker associated with the attributeType to check if the
-     * value is valid.  Repeated calls to this method do not attempt to re-check
-     * the syntax of the wrapped value every time if the wrapped value does not
-     * change. Syntax checks only result on the first check, and when the wrapped
-     * value changes.
-     *
-     * @return <code>true</code> if the value is valid
-     */
-    boolean isValid();
-
-    
     /**
      * Uses the syntaxChecker associated with the attributeType to check if the
      * value is valid.  Repeated calls to this method do not attempt to re-check
@@ -159,7 +151,7 @@ public interface Value<T> extends Clonea
      * Set the normalized flag.
      * 
      * @param normalized the value : true or false
-     */
+     *
     void setNormalized( boolean normalized );
 
     
@@ -173,7 +165,7 @@ public interface Value<T> extends Clonea
      *
      * @return gets the normalized value
      */
-    T getNormalizedValue();
+    T getNormValue();
     
     
     /**
@@ -182,7 +174,7 @@ public interface Value<T> extends Clonea
      *
      * @return gets a reference to the normalized value
      */
-    T getNormalizedValueReference();
+    T getNormReference();
 
     
     /**
@@ -190,7 +182,7 @@ public interface Value<T> extends Clonea
      * must be schema aware.
      * 
      * @exception LdapException if the value cannot be normalized
-     */
+     *
     void normalize() throws LdapException;
 
     
@@ -202,16 +194,16 @@ public interface Value<T> extends Clonea
      * 
      * @param normalizer the normalizer to apply to the value
      * @exception LdapException if the value cannot be normalized
-     */
+     *
     void normalize( Normalizer normalizer ) throws LdapException;
     
     
     /**
-     * Tells if the current value is Binary or String
+     * Tells if the current value is Human Readable
      * 
      * @return <code>true</code> if the value is Binary, <code>false</code> otherwise
      */
-    boolean isBinary();
+    boolean isHR();
     
     
     /**

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/AbstractExprNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/AbstractExprNode.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/AbstractExprNode.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/AbstractExprNode.java Sat Mar 26 19:17:40 2011
@@ -153,7 +153,7 @@ public abstract class AbstractExprNode i
         StringBuilder sb = null;
         String val;
 
-        if ( value.isBinary() )
+        if ( !value.isHR() )
         {
             sb = new StringBuilder( ((BinaryValue)value).getReference().length * 3 );
             

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ExtensibleNode.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ExtensibleNode.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ExtensibleNode.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ExtensibleNode.java Sat Mar 26 19:17:40 2011
@@ -183,7 +183,7 @@ public class ExtensibleNode extends Leaf
      */
     public Value<?> getEscapedValue()
     {
-        if ( !value.isBinary() )
+        if ( value.isHR() )
         {
             return escapeFilterValue( value );
         }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReader.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReader.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReader.java Sat Mar 26 19:17:40 2011
@@ -34,6 +34,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.Entry;
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.ldap.model.schema.SchemaManager;
 import org.apache.directory.shared.util.Strings;
@@ -284,13 +285,20 @@ public class LdifAttributesReader extend
         }
         else
         {
-            if ( attributeValue instanceof String )
+            try
             {
-                attribute.add( ( String ) attributeValue );
+                if ( attributeValue instanceof String )
+                {
+                    attribute.add( ( String ) attributeValue );
+                }
+                else
+                {
+                    attribute.add( ( byte[] ) attributeValue );
+                }
             }
-            else
+            catch ( LdapInvalidAttributeValueException liave )
             {
-                attribute.add( ( byte[] ) attributeValue );
+                throw new LdapLdifException( liave.getMessage() );
             }
         }
     }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java Sat Mar 26 19:17:40 2011
@@ -47,6 +47,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.message.Control;
 import org.apache.directory.shared.ldap.model.name.Dn;
@@ -1105,13 +1106,20 @@ public class LdifReader implements Itera
 
                 Object attributeValue = parseValue( line, colonIndex );
 
-                if ( attributeValue instanceof String )
-                {
-                    attribute.add( ( String ) attributeValue );
+                try
+                {  
+                    if ( attributeValue instanceof String )
+                    {
+                        attribute.add( ( String ) attributeValue );
+                    }
+                    else
+                    {
+                        attribute.add( ( byte[] ) attributeValue );
+                    }
                 }
-                else
+                catch ( LdapInvalidAttributeValueException liave )
                 {
-                    attribute.add( ( byte[] ) attributeValue );
+                    throw new LdapLdifException( liave.getMessage() );
                 }
 
                 isEmptyValue = false;

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifUtils.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifUtils.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifUtils.java Sat Mar 26 19:17:40 2011
@@ -559,14 +559,7 @@ public final class LdifUtils
             {
                 lineBuffer.append( ':' );
             }
-            else if ( value.isBinary() )
-            {
-                // It is binary, so we have to encode it using Base64 before adding it
-                char[] encoded = Base64.encode( value.getBytes() );
-
-                lineBuffer.append( ":: " + new String( encoded ) );
-            }
-            else if ( !value.isBinary() )
+            else if ( value.isHR() )
             {
                 // It's a String but, we have to check if encoding isn't required
                 String str = value.getString();
@@ -585,6 +578,13 @@ public final class LdifUtils
                     }
                 }
             }
+            else
+            {
+                // It is binary, so we have to encode it using Base64 before adding it
+                char[] encoded = Base64.encode( value.getBytes() );
+
+                lineBuffer.append( ":: " + new String( encoded ) );
+            }
 
             lineBuffer.append( "\n" );
             sb.append( stripLineToNChars( lineBuffer.toString(), length ) );

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java Sat Mar 26 19:17:40 2011
@@ -108,7 +108,7 @@ public class AddRequestImpl extends Abst
      * 
      * @param value The value to add
      */
-    public void addAttributeValue( String value )
+    public void addAttributeValue( String value ) throws LdapException
     {
         currentAttribute.add( value );
     }
@@ -119,7 +119,7 @@ public class AddRequestImpl extends Abst
      * 
      * @param value The value to add
      */
-    public void addAttributeValue( Value<?> value )
+    public void addAttributeValue( Value<?> value ) throws LdapException
     {
         currentAttribute.add( value );
     }
@@ -130,7 +130,7 @@ public class AddRequestImpl extends Abst
      * 
      * @param value The value to add
      */
-    public void addAttributeValue( byte[] value )
+    public void addAttributeValue( byte[] value ) throws LdapException
     {
         currentAttribute.add( value );
     }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/CompareRequestImpl.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/CompareRequestImpl.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/CompareRequestImpl.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/CompareRequestImpl.java Sat Mar 26 19:17:40 2011
@@ -314,7 +314,7 @@ public class CompareRequestImpl extends 
         sb.append( "        Attribute description : '" ).append( attrId ).append( "'\n" );
         sb.append( "        Attribute value : '" );
 
-        if ( !attrVal.isBinary() )
+        if ( attrVal.isHR() )
         {
             sb.append( attrVal.get() );
         }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java Sat Mar 26 19:17:40 2011
@@ -30,6 +30,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.model.entry.StringValue;
 import org.apache.directory.shared.ldap.model.entry.Value;
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.exception.LdapInvalidDnException;
 import org.apache.directory.shared.ldap.model.message.ResultCodeEnum;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
@@ -162,7 +163,16 @@ public class Ava implements Externalizab
                 throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
             }
             
-            createAva( schemaManager, upType, new BinaryValue( attributeType, upValue ) );
+            try
+            { 
+                createAva( schemaManager, upType, new BinaryValue( attributeType, upValue ) );
+            }
+            catch ( LdapInvalidAttributeValueException liave )
+            {
+                String message =  I18n.err( I18n.ERR_04188 );
+                LOG.error( message );
+                throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+            }
         }
         else
         {
@@ -215,7 +225,16 @@ public class Ava implements Externalizab
                 throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
             }
             
-            createAva( schemaManager, upType, new StringValue( attributeType, upValue ) );
+            try
+            { 
+                createAva( schemaManager, upType, new StringValue( attributeType, upValue ) );
+            }
+            catch ( LdapInvalidAttributeValueException liave )
+            {
+                String message =  I18n.err( I18n.ERR_04188 );
+                LOG.error( message );
+                throw new LdapInvalidDnException( ResultCodeEnum.INVALID_DN_SYNTAX, message );
+            }
         }
         else
         {
@@ -664,7 +683,7 @@ public class Ava implements Externalizab
      */
     public String normalize()
     {
-        if ( !normValue.isBinary() )
+        if ( normValue.isHR() )
         {
             // The result will be gathered in a stringBuilder
             StringBuilder sb = new StringBuilder();
@@ -888,7 +907,7 @@ public class Ava implements Externalizab
             out.writeBoolean( false);
         }
         
-        boolean isHR = !normValue.isBinary();
+        boolean isHR = normValue.isHR();
         
         out.writeBoolean( isHR );
         

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java Sat Mar 26 19:17:40 2011
@@ -391,7 +391,7 @@ public class Rdn implements Cloneable, E
             case 1:
                 // We have a single Ava
                 // We will trim and lowercase type and value.
-                if ( !ava.getNormValue().isBinary() )
+                if ( ava.getNormValue().isHR() )
                 {
                     normName = ava.getNormName();
                 }

Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/normalizers/RegexNormalizer.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/normalizers/RegexNormalizer.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/normalizers/RegexNormalizer.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/normalizers/RegexNormalizer.java Sat Mar 26 19:17:40 2011
@@ -82,7 +82,7 @@ public class RegexNormalizer extends Nor
             return null;
         }
 
-        if ( !value.isBinary() )
+        if ( value.isHR() )
         {
             String str = value.getString();
 

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java?rev=1085789&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java (added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java Sat Mar 26 19:17:40 2011
@@ -0,0 +1,91 @@
+/*
+ *  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.shared.ldap.model.schema.syntaxCheckers;
+
+
+import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a valid DerefAlias. We
+ * have four possible values :
+ * <ul>
+ * <li>NEVER</li>
+ * <li>SEARCHING</li>
+ * <li>FINDING</li>
+ * <li>ALWAYS</li>
+ * </ul>
+ * The value is case insensitive
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@SuppressWarnings("serial")
+public class DerefAliasSyntaxChecker extends SyntaxChecker
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( DerefAliasSyntaxChecker.class );
+
+    /**
+     * Creates a new instance of DerefAliasSyntaxChecker.
+     */
+    public DerefAliasSyntaxChecker()
+    {
+        super( SchemaConstants.DEREF_ALIAS_SYNTAX );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue = null;
+
+        if ( value == null )
+        {
+            LOG.debug( "Syntax invalid for 'null'" );
+            return false;
+        }
+        
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = Strings.utf8ToString((byte[]) value);
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        strValue = Strings.trim( Strings.toLowerCase( strValue ) );
+        
+        return ( "never".equals( strValue ) || 
+                 "finding".equals(  strValue ) || 
+                 "searching".equals( strValue ) ||
+                 "always".equals( strValue ));
+    }
+}

Added: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java?rev=1085789&view=auto
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java (added)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java Sat Mar 26 19:17:40 2011
@@ -0,0 +1,87 @@
+/*
+ *  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.shared.ldap.model.schema.syntaxCheckers;
+
+
+import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
+import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
+import org.apache.directory.shared.util.Strings;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A SyntaxChecker which verifies that a value is a valid Search Scope. We
+ * have three possible values :
+ * <ul>
+ * <li>OBJECT</li>
+ * <li>ONE</li>
+ * <li>SUBTREE</li>
+ * </ul>
+ * The value is case insensitive
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+@SuppressWarnings("serial")
+public class SearchScopeSyntaxChecker extends SyntaxChecker
+{
+    /** A logger for this class */
+    private static final Logger LOG = LoggerFactory.getLogger( SearchScopeSyntaxChecker.class );
+
+    /**
+     * Creates a new instance of SearchScopeSyntaxChecker.
+     */
+    public SearchScopeSyntaxChecker()
+    {
+        super( SchemaConstants.SEARCH_SCOPE_SYNTAX );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isValidSyntax( Object value )
+    {
+        String strValue = null;
+
+        if ( value == null )
+        {
+            LOG.debug( "Syntax invalid for 'null'" );
+            return false;
+        }
+        
+        if ( value instanceof String )
+        {
+            strValue = ( String ) value;
+        }
+        else if ( value instanceof byte[] )
+        {
+            strValue = Strings.utf8ToString((byte[]) value);
+        }
+        else
+        {
+            strValue = value.toString();
+        }
+
+        strValue = Strings.trim( Strings.toLowerCase( strValue ) );
+        
+        return ( "object".equals( strValue ) || "one".equals(  strValue ) || "subtree".equals( strValue ) );
+    }
+}

Modified: directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueAttributeTypeTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueAttributeTypeTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueAttributeTypeTest.java (original)
+++ directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueAttributeTypeTest.java Sat Mar 26 19:17:40 2011
@@ -35,6 +35,7 @@ import java.io.ObjectOutputStream;
 import java.util.Arrays;
 
 import org.apache.directory.shared.ldap.model.exception.LdapException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
 import org.apache.directory.shared.ldap.model.schema.AttributeType;
 import org.apache.directory.shared.ldap.model.schema.LdapSyntax;
 import org.apache.directory.shared.ldap.model.schema.MatchingRule;
@@ -90,7 +91,7 @@ public class BinaryValueAttributeTypeTes
         {
             public Value<?> normalize( Value<?> value ) throws LdapException
             {
-                if ( value.isBinary() )
+                if ( !value.isHR() )
                 {
                     byte[] val = value.getBytes();
                     // each byte will be changed to be > 0, and spaces will be trimmed
@@ -221,7 +222,7 @@ public class BinaryValueAttributeTypeTes
     /**
      * Test the constructor with a null value
      */
-    @Test public void testServerBinaryValueNullValue()
+    @Test public void testServerBinaryValueNullValue() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         
@@ -235,13 +236,13 @@ public class BinaryValueAttributeTypeTes
     /**
      * Test the constructor with an empty value
      */
-    @Test public void testServerBinaryValueEmptyValue()
+    @Test public void testServerBinaryValueEmptyValue() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         
         BinaryValue value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
         
-        assertEquals( StringConstants.EMPTY_BYTES, value.getReference() );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, value.getReference() ) );
         assertFalse( value.isNull() );
     }
     
@@ -265,7 +266,7 @@ public class BinaryValueAttributeTypeTes
     /**
      * Test the constructor with a value
      */
-    @Test public void testServerBinaryValue()
+    @Test public void testServerBinaryValue() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         byte[] val = new byte[]{0x01};
@@ -299,7 +300,7 @@ public class BinaryValueAttributeTypeTes
         
         assertEquals( bv, bv1 );
         
-        bv.normalize();
+        bv.apply( at );
         
         // Even if we didn't normalized sbv2, it should be equal to sbv,
         // as if they have the same AT, and the same value, they are equal.
@@ -310,7 +311,7 @@ public class BinaryValueAttributeTypeTes
     /**
      * Test the equals method
      */
-    @Test public void testEquals()
+    @Test public void testEquals() throws LdapInvalidAttributeValueException
     {
         AttributeType at1 = EntryUtils.getBytesAttributeType();
         
@@ -337,56 +338,56 @@ public class BinaryValueAttributeTypeTes
 
     
     /**
-     * Test the getNormalizedValue method
+     * Test the getNormValue method
      */
-    @Test public void testGetNormalizedValue()
+    @Test public void testGetNormalizedValue() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         
         BinaryValue value = new BinaryValue( attribute, null );
-        assertNull( value.getNormalizedValue() );
+        assertNull( value.getNormValue() );
 
         value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
-        assertTrue( Arrays.equals(  StringConstants.EMPTY_BYTES, value.getNormalizedValue() ) );
+        assertTrue( Arrays.equals(  StringConstants.EMPTY_BYTES, value.getNormValue() ) );
 
         value = new BinaryValue( attribute, BYTES2 );
-        assertTrue( Arrays.equals( BYTES1, value.getNormalizedValue() ) );
+        assertTrue( Arrays.equals( BYTES1, value.getNormValue() ) );
     }
     
     
     /**
-     * Test the getNormalizedValue method
+     * Test the getNormValue method
      */
-    @Test public void testGetNormalizedValueCopy()
+    @Test public void testGetNormalizedValueCopy() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         
         BinaryValue value = new BinaryValue( attribute, null );
-        assertNull( value.getNormalizedValue() );
+        assertNull( value.getNormValue() );
 
         value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
-        assertTrue( Arrays.equals(  StringConstants.EMPTY_BYTES, value.getNormalizedValue() ) );
+        assertTrue( Arrays.equals(  StringConstants.EMPTY_BYTES, value.getNormValue() ) );
 
         value = new BinaryValue( attribute, BYTES2 );
-        assertTrue( Arrays.equals( BYTES1, value.getNormalizedValue() ) );
+        assertTrue( Arrays.equals( BYTES1, value.getNormValue() ) );
     }
     
     
     /**
-     * Test the getNormalizedValue method
+     * Test the getNormValue method
      */
-    @Test public void testGetNormalizedValueReference()
+    @Test public void testGetNormalizedValueReference() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         
         BinaryValue value = new BinaryValue( attribute, null );
-        assertNull( value.getNormalizedValueReference() );
+        assertNull( value.getNormReference() );
 
         value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
-        assertTrue( Arrays.equals(  StringConstants.EMPTY_BYTES, value.getNormalizedValueReference() ) );
+        assertTrue( Arrays.equals(  StringConstants.EMPTY_BYTES, value.getNormReference() ) );
 
         value = new BinaryValue( attribute, BYTES2 );
-        assertTrue( Arrays.equals( BYTES1, value.getNormalizedValueReference() ) );
+        assertTrue( Arrays.equals( BYTES1, value.getNormReference() ) );
     }
     
     
@@ -408,25 +409,20 @@ public class BinaryValueAttributeTypeTes
      * 
      * The SyntaxChecker does not accept values longer than 5 chars.
      */
-    @Test public void testIsValid()
+    @Test public void testIsValid() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         
-        BinaryValue value = new BinaryValue( attribute, null );
-        assertTrue( value.isValid() );
-        
-        value = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
-        assertTrue( value.isValid() );
-
-        value = new BinaryValue( attribute, new byte[]{0x01, 0x02} );
-        assertTrue( value.isValid() );
+        new BinaryValue( attribute, null );
+        new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
+        new BinaryValue( attribute, new byte[]{0x01, 0x02} );
 
         try
         {
-            value = new BinaryValue( attribute, new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06} );
+            new BinaryValue( attribute, new byte[]{0x01, 0x02, 0x03, 0x04, 0x05, 0x06} );
             fail();
         }
-        catch ( IllegalArgumentException iae )
+        catch ( LdapInvalidAttributeValueException liave )
         {
             assertTrue( true );
         }
@@ -437,7 +433,7 @@ public class BinaryValueAttributeTypeTes
      * Tests to make sure the hashCode method is working properly.
      * @throws Exception on errors
      */
-    @Test public void testHashCode()
+    @Test public void testHashCode() throws LdapInvalidAttributeValueException
     {
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         BinaryValue v0 = new BinaryValue( attribute, new byte[]{0x01, 0x02} );
@@ -449,45 +445,15 @@ public class BinaryValueAttributeTypeTes
         assertEquals( v0, v1 );
         assertEquals( v0, v2 );
         assertEquals( v1, v2 );
-        assertTrue( v0.isValid() );
-        assertTrue( v1.isValid() );
-        assertTrue( v2.isValid() );
 
         BinaryValue v3 = new BinaryValue( attribute, new byte[]{0x01, 0x03} );
         assertFalse( v3.equals( v0 ) );
         assertFalse( v3.equals( v1 ) );
         assertFalse( v3.equals( v2 ) );
-        assertTrue( v3.isValid() );
     }
 
 
     /**
-     * Test the same method
-     */
-    @Test
-    public void testSame() throws LdapException
-    {
-        AttributeType attribute = EntryUtils.getBytesAttributeType();
-        BinaryValue bv = new BinaryValue( attribute );
-
-        bv.normalize();
-        assertTrue( bv.isSame() );
-        
-        bv = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
-        bv.normalize();
-        assertTrue( bv.isSame() );
-
-        bv = new BinaryValue( attribute, BYTES1 );
-        bv.normalize();
-        assertTrue( bv.isSame() );
-
-        bv = new BinaryValue( attribute, BYTES2 );
-        bv.normalize();
-        assertFalse( bv.isSame() );
-    }
-    
-    
-    /**
      * Test the instanceOf method
      */
     @Test
@@ -513,16 +479,16 @@ public class BinaryValueAttributeTypeTes
         AttributeType attribute = EntryUtils.getBytesAttributeType();
         BinaryValue bv = new BinaryValue( attribute );
 
-        bv.normalize();
-        assertEquals( null, bv.getNormalizedValue() );
+        bv.apply( at );
+        assertEquals( null, bv.getNormValue() );
         
         bv = new BinaryValue( attribute, StringConstants.EMPTY_BYTES );
-        bv.normalize();
-        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormalizedValue() ) );
+        bv.apply( at );
+        assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, bv.getNormValue() ) );
 
         bv = new BinaryValue( attribute, BYTES2 );
-        bv.normalize();
-        assertTrue( Arrays.equals( BYTES1, bv.getNormalizedValue() ) );
+        bv.apply( at );
+        assertTrue( Arrays.equals( BYTES1, bv.getNormValue() ) );
     }
     
 
@@ -530,7 +496,7 @@ public class BinaryValueAttributeTypeTes
      * Test the compareTo method
      */
     @Test
-    public void testCompareTo()
+    public void testCompareTo() throws LdapInvalidAttributeValueException
     {
         AttributeType at1 = EntryUtils.getBytesAttributeType();
         BinaryValue v0 = new BinaryValue( at1, BYTES1 );
@@ -557,8 +523,8 @@ public class BinaryValueAttributeTypeTes
         // First check with a value which will be normalized
         BinaryValue sbv = new BinaryValue( at, v1 );
         
-        sbv.normalize();
-        byte[] normalized = sbv.getNormalizedValueReference();
+        sbv.apply( at );
+        byte[] normalized = sbv.getNormReference();
         
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sbv.getReference() ) );
@@ -597,8 +563,8 @@ public class BinaryValueAttributeTypeTes
         // First check with a value which will be normalized
         BinaryValue sbv = new BinaryValue( at, v1 );
         
-        sbv.normalize();
-        byte[] normalized = sbv.getNormalizedValueReference();
+        sbv.apply( at );
+        byte[] normalized = sbv.getNormReference();
         
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sbv.getBytes() ) );
@@ -617,8 +583,8 @@ public class BinaryValueAttributeTypeTes
         // First check with a value which will be normalized
         BinaryValue sbv = new BinaryValue( at );
         
-        sbv.normalize();
-        byte[] normalized = sbv.getNormalizedValueReference();
+        sbv.apply( at );
+        byte[] normalized = sbv.getNormReference();
         
         assertEquals( null, normalized );
         assertEquals( null, sbv.get() );
@@ -637,8 +603,8 @@ public class BinaryValueAttributeTypeTes
         // First check with a value which will be normalized
         BinaryValue sbv = new BinaryValue( at, StringConstants.EMPTY_BYTES );
         
-        sbv.normalize();
-        byte[] normalized = sbv.getNormalizedValueReference();
+        sbv.apply( at );
+        byte[] normalized = sbv.getNormReference();
         
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, normalized ) );
         assertTrue( Arrays.equals( StringConstants.EMPTY_BYTES, sbv.getBytes() ) );
@@ -660,8 +626,8 @@ public class BinaryValueAttributeTypeTes
         // First check with a value which will be normalized
         BinaryValue sbv = new BinaryValue( at, v1 );
         
-        sbv.normalize();
-        byte[] normalized = sbv.getNormalizedValueReference();
+        sbv.apply( at );
+        byte[] normalized = sbv.getNormReference();
         
         assertTrue( Arrays.equals( v1Norm, normalized ) );
         assertTrue( Arrays.equals( v1, sbv.getBytes() ) );



Mime
View raw message