You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2011/03/26 20:17:42 UTC
svn commit: r1085789 [1/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...
Author: elecharny
Date: Sat Mar 26 19:17:40 2011
New Revision: 1085789
URL: http://svn.apache.org/viewvc?rev=1085789&view=rev
Log:
o Cleaned up the Value classes
o Lots of test fixed, and reflected the changes in the Value classes in all the code
Added:
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/DerefAliasSyntaxChecker.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/syntaxCheckers/SearchScopeSyntaxChecker.java
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=syntaxcheckers/
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=syntaxcheckers/m-oid=1.3.6.1.4.1.18060.0.4.1.0.10.ldif
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=syntaxcheckers/m-oid=1.3.6.1.4.1.18060.0.4.1.0.11.ldif
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=syntaxes/
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=syntaxes/m-oid=1.3.6.1.4.1.18060.0.4.1.0.10.ldif
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=syntaxes/m-oid=1.3.6.1.4.1.18060.0.4.1.0.11.ldif
Removed:
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/protocol/
Modified:
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ModifyRequestDsml.java
directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java
directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryAttributeSerializationTest.java
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareModificationSerializationTest.java
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareValueSerializationTest.java
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java
directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/addRequest/AddAttributeValue.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreSearchResultAttributeValue.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java
directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/SchemaConstants.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AbstractValue.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AttributeUtils.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/BinaryValue.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttribute.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultModification.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryAttribute.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/EntryUtils.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Modification.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/StringValue.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/Value.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/AbstractExprNode.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/filter/ExtensibleNode.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifAttributesReader.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifReader.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/ldif/LdifUtils.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/AddRequestImpl.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/message/CompareRequestImpl.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Ava.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/name/Rdn.java
directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/schema/normalizers/RegexNormalizer.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueAttributeTypeTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/BinaryValueTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/DefaultEntryAttributeTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ModificationTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueAttributeTypeTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/StringValueTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/entry/ValueSerializationTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/AddRequestImplTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/ModifyRequestImplTest.java
directory/shared/trunk/ldap/model/src/test/java/org/apache/directory/shared/ldap/model/message/SearchResultEntryImplTest.java
directory/shared/trunk/ldap/schema/data/src/main/java/org/apache/directory/shared/ldap/schemaloader/AttributeClassLoader.java
directory/shared/trunk/ldap/schema/data/src/main/resources/schema-all.ldif
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.819.ldif
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.821.ldif
directory/shared/trunk/ldap/schema/data/src/main/resources/schema/ou=schema/cn=adsconfig/ou=attributetypes/m-oid=1.3.6.1.4.1.18060.0.4.1.2.828.ldif
directory/shared/trunk/ldap/schema/data/src/test/java/org/apache/directory/shared/ldap/schemaloader/SchemaManagerEnableDisableLoadTest.java
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/Dsmlv2ResponseGrammar.java Sat Mar 26 19:17:40 2011
@@ -1757,13 +1757,20 @@ public final class Dsmlv2ResponseGrammar
// Getting the value
String nextText = xpp.nextText();
- if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+ try
{
- searchResultEntry.addAttributeValue( Base64.decode( nextText.toCharArray() ) );
+ if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+ {
+ searchResultEntry.addAttributeValue( Base64.decode( nextText.toCharArray() ) );
+ }
+ else
+ {
+ searchResultEntry.addAttributeValue( nextText );
+ }
}
- else
+ catch ( LdapException le )
{
- searchResultEntry.addAttributeValue( nextText );
+ throw new XmlPullParserException( le.getMessage() );
}
}
catch ( IOException e )
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/reponse/SearchResultEntryDsml.java Sat Mar 26 19:17:40 2011
@@ -20,7 +20,7 @@
package org.apache.directory.shared.dsmlv2.reponse;
-import org.apache.directory.shared.dsmlv2.ParserUtils;
+import org.apache.directory.shared.dsmlv2.ParserUtils;
import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
import org.apache.directory.shared.ldap.model.entry.Entry;
@@ -97,7 +97,7 @@ public class SearchResultEntryDsml
*
* @param value The added value
*/
- public void addAttributeValue( Object value )
+ public void addAttributeValue( Object value ) throws LdapException
{
if ( value instanceof String )
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/AddRequestDsml.java Sat Mar 26 19:17:40 2011
@@ -108,7 +108,7 @@ public class AddRequestDsml
*
* @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 AddRequestDsml
*
* @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 AddRequestDsml
*
* @param value The value to add
*/
- public void addAttributeValue( byte[] value )
+ public void addAttributeValue( byte[] value ) throws LdapException
{
currentAttribute.add( value );
}
@@ -218,7 +218,7 @@ public class AddRequestDsml
*
* @param value The value to be added
*/
- public void addAttributeValue( Object value )
+ public void addAttributeValue( Object value ) throws LdapException
{
if ( value instanceof Value<?> )
{
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/Dsmlv2Grammar.java Sat Mar 26 19:17:40 2011
@@ -1286,13 +1286,20 @@ public final class Dsmlv2Grammar extends
String nextText = xpp.nextText();
if ( !nextText.equals( "" ) )
{
- if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+ try
{
- addRequest.addAttributeValue( Base64.decode( nextText.trim().toCharArray() ) );
+ if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+ {
+ addRequest.addAttributeValue( Base64.decode( nextText.trim().toCharArray() ) );
+ }
+ else
+ {
+ addRequest.addAttributeValue( nextText.trim() );
+ }
}
- else
+ catch ( LdapException le )
{
- addRequest.addAttributeValue( nextText.trim() );
+ throw new XmlPullParserException( le.getMessage() );
}
}
}
@@ -1868,13 +1875,20 @@ public final class Dsmlv2Grammar extends
String nextText = xpp.nextText();
// We are testing if nextText equals "" since a modification can be "".
- if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+ try
{
- modifyRequest.addAttributeValue( Base64.decode(nextText.trim().toCharArray()) );
+ if ( ParserUtils.isBase64BinaryValue( xpp, typeValue ) )
+ {
+ modifyRequest.addAttributeValue( Base64.decode(nextText.trim().toCharArray()) );
+ }
+ else
+ {
+ modifyRequest.addAttributeValue( nextText.trim() );
+ }
}
- else
+ catch ( LdapException le )
{
- modifyRequest.addAttributeValue( nextText.trim() );
+ throw new XmlPullParserException( le.getMessage() );
}
}
catch ( IOException e )
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ModifyRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ModifyRequestDsml.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ModifyRequestDsml.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/ModifyRequestDsml.java Sat Mar 26 19:17:40 2011
@@ -31,6 +31,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.entry.Modification;
import org.apache.directory.shared.ldap.model.entry.ModificationOperation;
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.message.MessageTypeEnum;
import org.apache.directory.shared.ldap.model.message.ModifyRequest;
import org.apache.directory.shared.ldap.model.message.ModifyRequestImpl;
@@ -118,7 +119,7 @@ public class ModifyRequestDsml
*
* @param value The value to add
*/
- public void addAttributeValue( byte[] value )
+ public void addAttributeValue( byte[] value ) throws LdapException
{
currentAttribute.add( value );
}
@@ -129,7 +130,7 @@ public class ModifyRequestDsml
*
* @param value The value to add
*/
- public void addAttributeValue( String value )
+ public void addAttributeValue( String value ) throws LdapException
{
currentAttribute.add( value );
}
Modified: directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java (original)
+++ directory/shared/trunk/dsml/parser/src/test/java/org/apache/directory/shared/dsmlv2/addRequest/AddRequestTest.java Sat Mar 26 19:17:40 2011
@@ -450,7 +450,7 @@ public class AddRequestTest extends Abst
Iterator<Value<?>> valueIterator = attribute.iterator();
assertTrue( valueIterator.hasNext() );
Value<?> value = valueIterator.next();
- assertTrue( value.isBinary() );
+ assertFalse( value.isHR() );
assertEquals( "DSMLv2.0 rocks!!", value.getString() );
}
Modified: directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java (original)
+++ directory/shared/trunk/i18n/src/main/java/org/apache/directory/shared/i18n/I18n.java Sat Mar 26 19:17:40 2011
@@ -581,7 +581,7 @@ public enum I18n
ERR_04444( "ERR_04444" ),
ERR_04445( "ERR_04445" ),
ERR_04446( "ERR_04446" ),
- ERR_04447( "ERR_04447" ),
+ ERR_04447_CANNOT_NORMALIZE_VALUE( "ERR_04447_CANNOT_NORMALIZE_VALUE" ),
ERR_04448( "ERR_04448" ),
ERR_04449( "ERR_04449" ),
ERR_04450( "ERR_04450" ),
@@ -607,7 +607,7 @@ public enum I18n
ERR_04470( "ERR_04470" ),
ERR_04471( "ERR_04471" ),
ERR_04472( "ERR_04472" ),
- ERR_04473( "ERR_04473" ),
+ ERR_04473_NOT_VALID_VALUE( "ERR_04473_NOT_VALID_VALUE" ),
ERR_04474( "ERR_04474" ),
ERR_04475( "ERR_04475" ),
ERR_04476( "ERR_04476" ),
Modified: directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties
URL: http://svn.apache.org/viewvc/directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties (original)
+++ directory/shared/trunk/i18n/src/main/resources/org/apache/directory/shared/i18n/errors.properties Sat Mar 26 19:17:40 2011
@@ -569,7 +569,7 @@ ERR_04443=Failed to compare normalized v
ERR_04444=I don't really know how to compare anything other than ServerBinaryValues at this point in time.
ERR_04445=There is no Syntax associated with this attributeType
ERR_04446=Cannot use standard serialization for a ServerStringValue
-ERR_04447=Cannot normalize the wrapped value {0}
+ERR_04447_CANNOT_NORMALIZE_VALUE=Cannot normalize the wrapped value {0}
ERR_04448=I don't know what to do if value is not a ServerStringValue
ERR_04449=The value ''{0}'' can't be normalized, it hasn't been added
ERR_04450=The value ''{0}'' is incorrect, it hasn't been added
@@ -595,7 +595,7 @@ ERR_04469=Cannot use standard serializat
ERR_04470=Cannot read the attribute as it's OID (''{0}'') does not exist
ERR_04471=Cannot serialize a Modification with no attribute
ERR_04472=The attribute ''{0}'' is incorrect
-ERR_04473=Not a valid value
+ERR_04473_NOT_VALID_VALUE=Not a valid value
ERR_04474=Expected string to normalize
ERR_04475=Expected byte[] to normalize
ERR_04476=Cannot set an AttributeType {0} when another one ({1}) is already present
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryAttributeSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryAttributeSerializationTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryAttributeSerializationTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareEntryAttributeSerializationTest.java Sat Mar 26 19:17:40 2011
@@ -29,6 +29,7 @@ import java.io.ObjectOutputStream;
import org.apache.directory.shared.ldap.model.entry.DefaultEntryAttribute;
import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
+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.ldap.schemamanager.impl.DefaultSchemaManager;
@@ -70,7 +71,7 @@ public class SchemaAwareEntryAttributeSe
@Test
- public void testEntryAttributeNoStringValueSerialization() throws IOException, ClassNotFoundException
+ public void testEntryAttributeNoStringValueSerialization() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
{
EntryAttribute attribute1 = new DefaultEntryAttribute( cn );
@@ -93,7 +94,7 @@ public class SchemaAwareEntryAttributeSe
@Test
- public void testEntryAttributeOneStringValueSerialization() throws IOException, ClassNotFoundException
+ public void testEntryAttributeOneStringValueSerialization() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
{
EntryAttribute attribute1 = new DefaultEntryAttribute( "CommonName", cn, "test" );
@@ -117,7 +118,7 @@ public class SchemaAwareEntryAttributeSe
@Test
- public void testEntryAttributeManyStringValuesSerialization() throws IOException, ClassNotFoundException
+ public void testEntryAttributeManyStringValuesSerialization() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
{
EntryAttribute attribute1 = new DefaultEntryAttribute( "CN", cn, "test1", "test2", "test3" );
@@ -141,7 +142,7 @@ public class SchemaAwareEntryAttributeSe
@Test
- public void testEntryAttributeNoBinaryValueSerialization() throws IOException, ClassNotFoundException
+ public void testEntryAttributeNoBinaryValueSerialization() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException, LdapInvalidAttributeValueException
{
EntryAttribute attribute1 = new DefaultEntryAttribute( userCertificate );
@@ -164,7 +165,7 @@ public class SchemaAwareEntryAttributeSe
@Test
- public void testEntryAttributeOneBinaryValueSerialization() throws IOException, ClassNotFoundException
+ public void testEntryAttributeOneBinaryValueSerialization() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
{
EntryAttribute attribute1 = new DefaultEntryAttribute( userCertificate, data1 );
@@ -187,7 +188,7 @@ public class SchemaAwareEntryAttributeSe
@Test
- public void testEntryAttributeManyBinaryValuesSerialization() throws IOException, ClassNotFoundException
+ public void testEntryAttributeManyBinaryValuesSerialization() throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
{
EntryAttribute attribute1 = new DefaultEntryAttribute( "UserCertificate", userCertificate, data1, data2, data3 );
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareModificationSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareModificationSerializationTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareModificationSerializationTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareModificationSerializationTest.java Sat Mar 26 19:17:40 2011
@@ -33,6 +33,8 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
import org.apache.directory.shared.ldap.model.entry.Modification;
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.schema.AttributeType;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
@@ -108,7 +110,7 @@ public class SchemaAwareModificationSeri
/**
* Deserialize a DefaultModification
*/
- private Modification deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException
+ private Modification deserializeValue( ByteArrayOutputStream out ) throws IOException, ClassNotFoundException, LdapInvalidAttributeValueException
{
ObjectInputStream oIn = null;
ByteArrayInputStream in = new ByteArrayInputStream( out.toByteArray() );
@@ -152,7 +154,7 @@ public class SchemaAwareModificationSeri
@Test
- public void testCreateServerModification()
+ public void testCreateServerModification() throws LdapException
{
EntryAttribute attribute = new DefaultEntryAttribute( "cn", CN_AT );
attribute.add( "test1", "test2" );
@@ -174,7 +176,7 @@ public class SchemaAwareModificationSeri
@Test
- public void testSerializationModificationADD() throws ClassNotFoundException, IOException
+ public void testSerializationModificationADD() throws ClassNotFoundException, IOException, LdapInvalidAttributeValueException
{
EntryAttribute attribute = new DefaultEntryAttribute( "cn", CN_AT );
attribute.add( "test1", "test2" );
@@ -188,7 +190,7 @@ public class SchemaAwareModificationSeri
@Test
- public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException
+ public void testSerializationModificationREPLACE() throws ClassNotFoundException, IOException, LdapInvalidAttributeValueException
{
EntryAttribute attribute = new DefaultEntryAttribute( "cn", CN_AT );
attribute.add( "test1", "test2" );
@@ -202,7 +204,7 @@ public class SchemaAwareModificationSeri
@Test
- public void testSerializationModificationREMOVE() throws ClassNotFoundException, IOException
+ public void testSerializationModificationREMOVE() throws ClassNotFoundException, IOException, LdapInvalidAttributeValueException
{
EntryAttribute attribute = new DefaultEntryAttribute( "cn", CN_AT );
attribute.add( "test1", "test2" );
@@ -216,7 +218,7 @@ public class SchemaAwareModificationSeri
@Test
- public void testSerializationModificationNoAttribute() throws ClassNotFoundException, IOException
+ public void testSerializationModificationNoAttribute() throws ClassNotFoundException, IOException, LdapInvalidAttributeValueException
{
DefaultModification mod = new DefaultModification();
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareValueSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareValueSerializationTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareValueSerializationTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/entry/SchemaAwareValueSerializationTest.java Sat Mar 26 19:17:40 2011
@@ -66,6 +66,7 @@ public class SchemaAwareValueSerializati
private static SchemaManager schemaManager;
private static AttributeType cn = null;
+ private static AttributeType dc = null;
private static AttributeType userCertificate = null;
/**
@@ -76,6 +77,7 @@ public class SchemaAwareValueSerializati
{
schemaManager = new DefaultSchemaManager();
cn = schemaManager.getAttributeType( "cn" );
+ dc = schemaManager.getAttributeType( "dc" );
userCertificate = schemaManager.getAttributeType( "userCertificate" );
bv1 = new BinaryValue( userCertificate, data );
@@ -85,11 +87,11 @@ public class SchemaAwareValueSerializati
bv2n = new BinaryValue( userCertificate, StringConstants.EMPTY_BYTES );
bv3n = new BinaryValue( userCertificate );
sv1 = new StringValue( cn, "test" );
- sv2 = new StringValue( cn, "" );
+ sv2 = new StringValue( dc, "" );
sv3 = new StringValue( cn );
sv1n = new StringValue( cn, "test" );
- sv2n = new StringValue( cn, "" );
- sv3n = new StringValue( cn );
+ sv2n = new StringValue( dc, "" );
+ sv3n = new StringValue( dc );
}
@@ -218,7 +220,7 @@ public class SchemaAwareValueSerializati
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
- bv1n.normalize();
+ bv1n.apply( userCertificate );
bv1n.writeExternal( out );
@@ -239,7 +241,7 @@ public class SchemaAwareValueSerializati
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
- bv2n.normalize();
+ bv2n.apply( userCertificate );
bv2n.writeExternal( out );
@@ -260,7 +262,7 @@ public class SchemaAwareValueSerializati
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
- bv3n.normalize();
+ bv3n.apply( userCertificate );
bv3n.writeExternal( out );
@@ -281,7 +283,7 @@ public class SchemaAwareValueSerializati
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
- sv1n.normalize();
+ sv1n.apply( cn );
sv1n.writeExternal( out );
@@ -302,7 +304,7 @@ public class SchemaAwareValueSerializati
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
- sv2n.normalize();
+ sv2n.apply( dc );
sv2n.writeExternal( out );
@@ -323,7 +325,7 @@ public class SchemaAwareValueSerializati
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
- sv3n.normalize();
+ sv3n.apply( dc );
sv3n.writeExternal( out );
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/AvaTest.java Sat Mar 26 19:17:40 2011
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertTru
import static org.junit.Assert.fail;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.name.Ava;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
import org.junit.BeforeClass;
@@ -108,25 +107,25 @@ public class AvaTest
@Test
public void testAttributeTypeAndValueValidType() throws LdapException
{
- Ava atav = new Ava( schemaManager, "CN", (String)null );
- assertEquals( "CN=", atav.toString() );
- assertEquals( "2.5.4.3=", atav.getNormName() );
- assertEquals( "CN=", atav.getUpName() );
+ Ava ava = new Ava( schemaManager, "CN", " " );
+ assertEquals( "CN= ", ava.toString() );
+ assertEquals( "2.5.4.3=\\ ", ava.getNormName() );
+ assertEquals( "CN= ", ava.getUpName() );
- atav = new Ava( schemaManager, " CN ", (String)null );
- assertEquals( " CN =", atav.toString() );
- assertEquals( "2.5.4.3=", atav.getNormName() );
- assertEquals( " CN =", atav.getUpName() );
-
- atav = new Ava( schemaManager, "cn", (String)null );
- assertEquals( "cn=", atav.toString() );
- assertEquals( "2.5.4.3=", atav.getNormName() );
- assertEquals( "cn=", atav.getUpName() );
+ ava = new Ava( schemaManager, " CN ", " " );
+ assertEquals( " CN = ", ava.toString() );
+ assertEquals( "2.5.4.3=\\ ", ava.getNormName() );
+ assertEquals( " CN = ", ava.getUpName() );
+
+ ava = new Ava( schemaManager, "cn", " " );
+ assertEquals( "cn= ", ava.toString() );
+ assertEquals( "2.5.4.3=\\ ", ava.getNormName() );
+ assertEquals( "cn= ", ava.getUpName() );
- atav = new Ava( schemaManager, " cn ", (String)null );
- assertEquals( " cn =", atav.toString() );
- assertEquals( "2.5.4.3=", atav.getNormName() );
- assertEquals( " cn =", atav.getUpName() );
+ ava = new Ava( schemaManager, " cn ", " " );
+ assertEquals( " cn = ", ava.toString() );
+ assertEquals( "2.5.4.3=\\ ", ava.getNormName() );
+ assertEquals( " cn = ", ava.getUpName() );
}
/**
Modified: directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java (original)
+++ directory/shared/trunk/integ/src/test/java/org/apache/directory/shared/ldap/model/name/SchemaAwareAvaSerializationTest.java Sat Mar 26 19:17:40 2011
@@ -31,7 +31,6 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.apache.directory.shared.ldap.model.exception.LdapException;
-import org.apache.directory.shared.ldap.model.name.Ava;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
import org.apache.directory.shared.ldap.schemamanager.impl.DefaultSchemaManager;
import org.apache.directory.shared.util.Strings;
@@ -137,7 +136,7 @@ public class SchemaAwareAvaSerialization
@Test
public void testNullUpValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
- Ava atav = new Ava( schemaManager, "uid", (String)null );
+ Ava atav = new Ava( schemaManager, "dc", (String)null );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -158,7 +157,7 @@ public class SchemaAwareAvaSerialization
@Test
public void testEmptyNormValueSerialization() throws LdapException, IOException, ClassNotFoundException
{
- Ava atav = new Ava( schemaManager, "CN", "" );
+ Ava atav = new Ava( schemaManager, "DC", "" );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -252,7 +251,7 @@ public class SchemaAwareAvaSerialization
@Test( expected = IOException.class )
public void testNullNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
{
- Ava atav = new Ava( schemaManager, "UID", (String)null );
+ Ava atav = new Ava( schemaManager, "DC", (String)null );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
@@ -265,7 +264,7 @@ public class SchemaAwareAvaSerialization
@Test
public void testEmptyNormValueStaticSerialization() throws LdapException, IOException, ClassNotFoundException
{
- Ava atav = new Ava( schemaManager, "UID", (String)"" );
+ Ava atav = new Ava( schemaManager, "DC", (String)"" );
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream( baos );
Modified: directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java (original)
+++ directory/shared/trunk/ldap/client/api/src/main/java/org/apache/directory/ldap/client/api/LdapNetworkConnection.java Sat Mar 26 19:17:40 2011
@@ -2767,13 +2767,13 @@ public class LdapNetworkConnection exten
compareRequest.setName( dn );
compareRequest.setAttributeId( attributeName );
- if ( value.isBinary() )
+ if ( value.isHR() )
{
- compareRequest.setAssertionValue( value.getBytes() );
+ compareRequest.setAssertionValue( value.getString() );
}
else
{
- compareRequest.setAssertionValue( value.getString() );
+ compareRequest.setAssertionValue( value.getBytes() );
}
return compare( compareRequest );
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/addRequest/AddAttributeValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/addRequest/AddAttributeValue.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/addRequest/AddAttributeValue.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/addRequest/AddAttributeValue.java Sat Mar 26 19:17:40 2011
@@ -24,6 +24,7 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.decorators.AddRequestDecorator;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,35 +71,41 @@ public class AddAttributeValue extends G
// Store the value. It can't be null
Object value = null;
- if ( tlv.getLength() == 0 )
+ try
{
- addRequest.addAttributeValue( "" );
- }
- else
- {
- if ( container.isBinary( addRequest.getCurrentAttributeType() ) )
+ if ( tlv.getLength() == 0 )
{
- value = tlv.getValue().getData();
-
- if ( IS_DEBUG )
- {
- LOG.debug( "Adding value {}", Strings.dumpBytes((byte[]) value) );
- }
-
- addRequest.addAttributeValue( ( byte[] ) value );
+ addRequest.addAttributeValue( "" );
}
else
{
- value = Strings.utf8ToString(tlv.getValue().getData());
-
- if ( IS_DEBUG )
+ if ( container.isBinary( addRequest.getCurrentAttributeType() ) )
{
- LOG.debug( "Adding value {}" + value );
+ value = tlv.getValue().getData();
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Adding value {}", Strings.dumpBytes((byte[]) value) );
+ }
+
+ addRequest.addAttributeValue( ( byte[] ) value );
+ }
+ else
+ {
+ value = Strings.utf8ToString(tlv.getValue().getData());
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Adding value {}" + value );
+ }
+
+ addRequest.addAttributeValue( ( String ) value );
}
-
- addRequest.addAttributeValue( ( String ) value );
}
-
+ }
+ catch ( LdapException le )
+ {
+ // Just swallow the exception, it can't occur here
}
// We can have an END transition
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/modifyRequest/StoreModifyRequestAttributeValue.java Sat Mar 26 19:17:40 2011
@@ -24,6 +24,7 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.decorators.ModifyRequestDecorator;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.util.StringConstants;
import org.apache.directory.shared.util.Strings;
import org.slf4j.Logger;
@@ -65,23 +66,30 @@ public class StoreModifyRequestAttribute
// Store the value. It can't be null
byte[] value = StringConstants.EMPTY_BYTES;
- if ( tlv.getLength() == 0 )
+ try
{
- modifyRequestDecorator.addAttributeValue( "" );
- }
- else
- {
- value = tlv.getValue().getData();
-
- if ( container.isBinary( modifyRequestDecorator.getCurrentAttributeType() ) )
+ if ( tlv.getLength() == 0 )
{
- modifyRequestDecorator.addAttributeValue( value );
+ modifyRequestDecorator.addAttributeValue( "" );
}
else
{
- modifyRequestDecorator.addAttributeValue( Strings.utf8ToString((byte[]) value) );
+ value = tlv.getValue().getData();
+
+ if ( container.isBinary( modifyRequestDecorator.getCurrentAttributeType() ) )
+ {
+ modifyRequestDecorator.addAttributeValue( value );
+ }
+ else
+ {
+ modifyRequestDecorator.addAttributeValue( Strings.utf8ToString((byte[]) value) );
+ }
}
}
+ catch ( LdapException le )
+ {
+ // Just swallow the exception, it can't occur here
+ }
// We can have an END transition
container.setGrammarEndAllowed( true );
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreSearchResultAttributeValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreSearchResultAttributeValue.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreSearchResultAttributeValue.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/actions/searchResultEntry/StoreSearchResultAttributeValue.java Sat Mar 26 19:17:40 2011
@@ -24,6 +24,7 @@ import org.apache.directory.shared.asn1.
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.ldap.codec.api.LdapMessageContainer;
import org.apache.directory.shared.ldap.codec.decorators.SearchResultEntryDecorator;
+import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,31 +71,38 @@ public class StoreSearchResultAttributeV
// Store the value
Object value = null;
- if ( tlv.getLength() == 0 )
+ try
{
- searchResultEntry.addAttributeValue( "" );
-
- LOG.debug( "The attribute value is null" );
- }
- else
- {
- if ( container.isBinary( searchResultEntry.getCurrentAttribute().getId() ) )
+ if ( tlv.getLength() == 0 )
{
- value = tlv.getValue().getData();
-
- if ( IS_DEBUG )
- {
- LOG.debug( "Attribute value {}", Strings.dumpBytes((byte[]) value) );
- }
+ searchResultEntry.addAttributeValue( "" );
+
+ LOG.debug( "The attribute value is null" );
}
else
{
- value = Strings.utf8ToString(tlv.getValue().getData());
-
- LOG.debug( "Attribute value {}", value );
+ if ( container.isBinary( searchResultEntry.getCurrentAttribute().getId() ) )
+ {
+ value = tlv.getValue().getData();
+
+ if ( IS_DEBUG )
+ {
+ LOG.debug( "Attribute value {}", Strings.dumpBytes((byte[]) value) );
+ }
+ }
+ else
+ {
+ value = Strings.utf8ToString(tlv.getValue().getData());
+
+ LOG.debug( "Attribute value {}", value );
+ }
+
+ searchResultEntry.addAttributeValue( value );
}
-
- searchResultEntry.addAttributeValue( value );
+ }
+ catch ( LdapException le )
+ {
+ // Just swallow the exception, it can't occur here
}
// We can have an END transition
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/AddRequestDecorator.java Sat Mar 26 19:17:40 2011
@@ -226,7 +226,7 @@ public final class AddRequestDecorator e
*
* @param value The value to add
*/
- public void addAttributeValue( String value )
+ public void addAttributeValue( String value ) throws LdapException
{
currentAttribute.add( value );
}
@@ -237,7 +237,7 @@ public final class AddRequestDecorator e
*
* @param value The value to add
*/
- public void addAttributeValue( Value<?> value )
+ public void addAttributeValue( Value<?> value ) throws LdapException
{
currentAttribute.add( value );
}
@@ -248,7 +248,7 @@ public final class AddRequestDecorator e
*
* @param value The value to add
*/
- public void addAttributeValue( byte[] value )
+ public void addAttributeValue( byte[] value ) throws LdapException
{
currentAttribute.add( value );
}
@@ -427,13 +427,13 @@ public final class AddRequestDecorator e
{
for ( org.apache.directory.shared.ldap.model.entry.Value<?> value : attribute )
{
- if ( value.isBinary() )
+ if ( value.isHR() )
{
- org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, value.getBytes() );
+ org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, value.getString() );
}
else
{
- org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, value.getString() );
+ org.apache.directory.shared.asn1.ber.tlv.Value.encode( buffer, value.getBytes() );
}
}
}
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/ModifyRequestDecorator.java Sat Mar 26 19:17:40 2011
@@ -38,6 +38,7 @@ import org.apache.directory.shared.ldap.
import org.apache.directory.shared.ldap.model.entry.EntryAttribute;
import org.apache.directory.shared.ldap.model.entry.Modification;
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.message.ModifyRequest;
import org.apache.directory.shared.ldap.model.message.ModifyResponse;
import org.apache.directory.shared.ldap.model.name.Dn;
@@ -214,7 +215,7 @@ public class ModifyRequestDecorator exte
*
* @param value The value to add
*/
- public void addAttributeValue( byte[] value )
+ public void addAttributeValue( byte[] value ) throws LdapException
{
currentAttribute.add( value );
}
@@ -225,7 +226,7 @@ public class ModifyRequestDecorator exte
*
* @param value The value to add
*/
- public void addAttributeValue( String value )
+ public void addAttributeValue( String value ) throws LdapException
{
currentAttribute.add( value );
}
@@ -574,7 +575,7 @@ public class ModifyRequestDecorator exte
{
for ( org.apache.directory.shared.ldap.model.entry.Value<?> value : modification.getAttribute() )
{
- if ( !value.isBinary() )
+ if ( value.isHR() )
{
Value.encode( buffer, value.getString() );
}
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/decorators/SearchResultEntryDecorator.java Sat Mar 26 19:17:40 2011
@@ -201,7 +201,7 @@ public class SearchResultEntryDecorator
*
* @param value The added value
*/
- public void addAttributeValue( Object value )
+ public void addAttributeValue( Object value ) throws LdapException
{
if ( value instanceof String )
{
@@ -455,7 +455,7 @@ public class SearchResultEntryDecorator
{
for ( org.apache.directory.shared.ldap.model.entry.Value<?> value : attribute )
{
- if ( !value.isBinary() )
+ if ( value.isHR() )
{
Value.encode( buffer, value.getString() );
}
Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java (original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/shared/ldap/codec/search/AttributeValueAssertionFilter.java Sat Mar 26 19:17:40 2011
@@ -23,9 +23,9 @@ package org.apache.directory.shared.ldap
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
+import org.apache.directory.shared.asn1.EncoderException;
import org.apache.directory.shared.asn1.ber.tlv.TLV;
import org.apache.directory.shared.asn1.ber.tlv.Value;
-import org.apache.directory.shared.asn1.EncoderException;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.codec.AttributeValueAssertion;
import org.apache.directory.shared.ldap.codec.api.LdapConstants;
@@ -221,13 +221,13 @@ public class AttributeValueAssertionFilt
Value.encode( buffer, assertion.getAttributeDesc() );
// The assertion desc
- if ( assertion.getAssertionValue().isBinary() )
+ if ( assertion.getAssertionValue().isHR() )
{
- Value.encode( buffer, assertion.getAssertionValue().getString() );
+ Value.encode( buffer, assertion.getAssertionValue().getBytes() );
}
else
{
- Value.encode( buffer, assertion.getAssertionValue().getBytes() );
+ Value.encode( buffer, assertion.getAssertionValue().getString() );
}
return buffer;
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/SchemaConstants.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/SchemaConstants.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/SchemaConstants.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/constants/SchemaConstants.java Sat Mar 26 19:17:40 2011
@@ -726,6 +726,12 @@ public final class SchemaConstants
// SyntaxChecker Syntax
public final static String SYNTAX_CHECKER_SYNTAX = "1.3.6.1.4.1.18060.0.4.1.0.7";
+ // SearchScope Syntax
+ public final static String SEARCH_SCOPE_SYNTAX = "1.3.6.1.4.1.18060.0.4.1.0.10";
+
+ // DerefAlias Syntax
+ public final static String DEREF_ALIAS_SYNTAX = "1.3.6.1.4.1.18060.0.4.1.0.11";
+
//-------------------------------------------------------------------------
// ---- MatchingRules -----------------------------------------------------
//-------------------------------------------------------------------------
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AbstractValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AbstractValue.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AbstractValue.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AbstractValue.java Sat Mar 26 19:17:40 2011
@@ -21,6 +21,8 @@ package org.apache.directory.shared.ldap
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.message.ResultCodeEnum;
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.MatchingRule;
@@ -50,7 +52,7 @@ public abstract class AbstractValue<T> i
protected T normalizedValue;
/** A flag set when the value has been normalized */
- protected boolean normalized;
+ //protected boolean normalized;
/** cached results of the isValid() method call */
protected Boolean valid;
@@ -100,50 +102,61 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
- public void apply( AttributeType attributeType )
+ public void apply( AttributeType attributeType ) throws LdapInvalidAttributeValueException
{
- if ( this.attributeType != null )
+ if ( attributeType == null )
{
- if ( !attributeType.equals( this.attributeType ) )
- {
- String message = I18n.err( I18n.ERR_04476, attributeType.getName(), this.attributeType.getName() );
- LOG.info( message );
- throw new IllegalArgumentException( message );
- }
- else
- {
- return;
- }
+ normalizedValue = wrappedValue;
+ return;
}
- // First, check that the value is syntaxically correct
+ this.attributeType = attributeType;
+
try
{
- if ( ! isValid( attributeType.getSyntax().getSyntaxChecker() ) )
+ MatchingRule equality = attributeType.getEquality();
+
+ if ( equality != null )
{
- String message = I18n.err( I18n.ERR_04476, attributeType.getName(), this.attributeType.getName() );
- LOG.info( message );
- throw new IllegalArgumentException( message );
+ Normalizer normalizer = equality.getNormalizer();
+
+ if ( normalizer != null )
+ {
+ if ( wrappedValue != null )
+ {
+ if ( isHR() )
+ {
+ normalizedValue = (T)normalizer.normalize( (String)wrappedValue );
+ }
+ else
+ {
+ normalizedValue = (T)normalizer.normalize( new BinaryValue( (byte[])wrappedValue ) ).getNormReference();
+ }
+ }
+ }
}
}
- catch ( LdapException le )
+ catch ( LdapException ne )
{
- String message = I18n.err( I18n.ERR_04447, le.getLocalizedMessage() );
+ String message = I18n.err( I18n.ERR_04447_CANNOT_NORMALIZE_VALUE, ne.getLocalizedMessage() );
LOG.info( message );
- normalized = false;
}
- this.attributeType = attributeType;
-
+ // and checks that the value is syntaxically correct
try
{
- normalize();
+ if ( ! isValid( attributeType.getSyntax().getSyntaxChecker() ) )
+ {
+ String message = I18n.err( I18n.ERR_04473_NOT_VALID_VALUE, wrappedValue );
+ LOG.info( message );
+ throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
+ }
}
- catch ( LdapException ne )
+ catch ( LdapException le )
{
- String message = I18n.err( I18n.ERR_04447, ne.getLocalizedMessage() );
+ String message = I18n.err( I18n.ERR_04447_CANNOT_NORMALIZE_VALUE, le.getLocalizedMessage() );
LOG.info( message );
- normalized = false;
+ throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
}
h=0;
@@ -262,7 +275,7 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
- public T getNormalizedValueReference()
+ public T getNormReference()
{
if ( isNull() )
{
@@ -275,7 +288,6 @@ public abstract class AbstractValue<T> i
}
return normalizedValue;
-
}
@@ -289,42 +301,6 @@ public abstract class AbstractValue<T> i
/**
- * This method is only used for serialization/deserialization
- *
- * @return Tells if the wrapped value and the normalized value are the same
- */
- /* no qualifier */ final boolean isSame()
- {
- return same;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public final boolean isValid()
- {
- if ( valid != null )
- {
- return valid;
- }
-
- if ( attributeType != null )
- {
- SyntaxChecker syntaxChecker = attributeType.getSyntax().getSyntaxChecker();
- T value = getNormalizedValue();
- valid = syntaxChecker.isValidSyntax( value );
- }
- else
- {
- valid = false;
- }
-
- return valid;
- }
-
-
- /**
* {@inheritDoc}
*/
public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapException
@@ -336,7 +312,7 @@ public abstract class AbstractValue<T> i
throw new LdapException( message );
}
- valid = syntaxChecker.isValidSyntax( getReference() );
+ valid = syntaxChecker.isValidSyntax( normalizedValue );
return valid;
}
@@ -345,242 +321,8 @@ public abstract class AbstractValue<T> i
/**
* {@inheritDoc}
*/
- public void normalize() throws LdapException
+ public final boolean isSchemaAware()
{
- normalized = true;
- normalizedValue = wrappedValue;
- h = 0;
- hashCode();
- }
-
-
- /**
- * {@inheritDoc}
- */
- public final boolean isNormalized()
- {
- return normalized;
- }
-
-
- /**
- * {@inheritDoc}
- */
- public final void setNormalized( boolean normalized )
- {
- this.normalized = normalized;
- }
-
-
- /**
- * Serializes a Value instance.
- *
- * @param value The Value instance to serialize
- * @param out The stream into which we will write the serialized instance
- * @throws IOException If the stream can't be written
- *
- @SuppressWarnings("unchecked")
- public static void serialize( Value<?> value, ObjectOutput out ) throws IOException
- {
- // The Value type
- out.writeBoolean( value.isBinary() );
-
- // The AttributeType's OID if we have one
- if ( value.getAttributeType() != null )
- {
- out.writeBoolean( true );
- out.writeUTF( value.getAttributeType().getOid() );
- }
- else
- {
- out.writeBoolean( false );
- }
-
- // The UP value and norm value
- if ( value.isBinary() )
- {
- byte[] upValue = (byte[])value.getReference();
-
- if ( upValue == null )
- {
- out.writeInt( -1 );
- }
- else
- {
- out.writeInt( upValue.length );
-
- if ( upValue.length > 0 )
- {
- out.write( upValue );
- }
- }
-
- byte[] normValue = (byte[])value.getNormalizedValueReference();
-
- if ( normValue == null )
- {
- out.writeInt( -1 );
- }
- else
- {
- out.writeInt( normValue.length );
-
- if ( normValue.length > 0 )
- {
- out.write( normValue );
- }
- }
- }
- else
- {
- if ( ((AbstractValue<String>)value).wrappedValue != null )
- {
- out.writeBoolean( true );
- out.writeUTF( ((AbstractValue<String>)value).wrappedValue );
- }
- else
- {
- out.writeBoolean( false );
- }
-
- if ( ((AbstractValue<String>)value).normalizedValue != null )
- {
- out.writeBoolean( true );
- out.writeUTF( ((AbstractValue<String>)value).normalizedValue );
- }
- else
- {
- out.writeBoolean( false );
- }
- }
-
- // The normalized flag
- out.writeBoolean( value.isNormalized() );
-
- // The valid flag
- out.writeBoolean( value.isValid() );
-
- // The same flag
- if ( value.isBinary() )
- {
- out.writeBoolean( ((BinaryValue)value).isSame() );
- }
- else
- {
- out.writeBoolean( ((StringValue)value).isSame() );
- }
-
- // The computed hashCode
- out.writeInt( value.hashCode() );
-
- out.flush();
- }
-
-
- /**
- * Deserializes a Value instance.
- *
- * @param schemaManager The schemaManager instance
- * @param in The input stream from which the Value is read
- * @return a deserialized Value
- * @throws IOException If the stream can't be read
- *
- @SuppressWarnings("unchecked")
- public static Value<?> deserialize( SchemaManager schemaManager, ObjectInput in ) throws IOException
- {
- // The value type
- boolean isBinary = in.readBoolean();
-
- Value<?> value = null;
-
- if ( isBinary )
- {
- value = new BinaryValue();
- }
- else
- {
- value = new StringValue();
- }
-
- // The attributeType presence's flag
- boolean hasAttributeType = in.readBoolean();
-
- if ( hasAttributeType )
- {
- String oid = in.readUTF();
-
- if ( schemaManager != null )
- {
- ((AbstractValue<?>)value).attributeType = schemaManager.getAttributeType( oid );
- }
- }
-
- if ( isBinary )
- {
- int upValueSize = in.readInt();
-
- switch ( upValueSize )
- {
- case -1 :
- break;
-
- case 0 :
- ((AbstractValue<byte[]>)value).wrappedValue = StringConstants.EMPTY_BYTES;
- break;
-
- default :
- ((AbstractValue<byte[]>)value).wrappedValue = new byte[upValueSize];
- in.read( ((AbstractValue<byte[]>)value).wrappedValue );
- break;
- }
-
- int normValueSize = in.readInt();
-
- switch ( normValueSize )
- {
- case -1 :
- break;
-
- case 0 :
- ((AbstractValue<byte[]>)value).normalizedValue = StringConstants.EMPTY_BYTES;
- break;
-
- default :
- ((AbstractValue<byte[]>)value).normalizedValue = new byte[normValueSize];
- in.read( ((AbstractValue<byte[]>)value).normalizedValue );
- break;
- }
- }
- else
- {
- boolean notNull = in.readBoolean();
-
- if ( notNull )
- {
- ((AbstractValue<String>)value).wrappedValue = in.readUTF();
- }
-
- notNull = in.readBoolean();
-
- if ( notNull )
- {
- ((AbstractValue<String>)value).normalizedValue = in.readUTF();
- }
- }
-
- // The normalized flag
- ((AbstractValue<?>)value).normalized = in.readBoolean();
-
- // The valid flag
- ((AbstractValue<?>)value).valid = in.readBoolean();
-
- // The same flag
- ((AbstractValue<?>)value).same = in.readBoolean();
-
- // The computed hashCode
- ((AbstractValue<?>)value).h = in.readInt();
-
- return value;
+ return attributeType != null;
}
- */
}
\ No newline at end of file
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AttributeUtils.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AttributeUtils.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AttributeUtils.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/AttributeUtils.java Sat Mar 26 19:17:40 2011
@@ -36,6 +36,7 @@ import org.apache.commons.lang.ArrayUtil
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.exception.LdapException;
import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeTypeException;
+import org.apache.directory.shared.ldap.model.exception.LdapInvalidAttributeValueException;
import org.apache.directory.shared.ldap.model.name.Dn;
import org.apache.directory.shared.ldap.model.schema.AttributeType;
import org.apache.directory.shared.ldap.model.schema.MatchingRule;
@@ -298,7 +299,7 @@ public final class AttributeUtils
{
byte[] comparedBytes = null;
- if ( !compared.isBinary() )
+ if ( compared.isHR() )
{
if ( compared.getString().length() < 3 )
{
@@ -1119,7 +1120,7 @@ public final class AttributeUtils
* @param attribute the BasicAttributes or AttributesImpl instance to convert
* @return An instance of a ClientEntry object
*/
- public static EntryAttribute toClientAttribute( Attribute attribute )
+ public static EntryAttribute toClientAttribute( Attribute attribute ) throws LdapInvalidAttributeValueException
{
if ( attribute == null )
{
@@ -1134,6 +1135,7 @@ public final class AttributeUtils
{
Object value = values.nextElement();
+
if ( value instanceof String )
{
clientAttribute.add( ( String ) value );
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/BinaryValue.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/BinaryValue.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/BinaryValue.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/BinaryValue.java Sat Mar 26 19:17:40 2011
@@ -27,12 +27,10 @@ import java.util.Comparator;
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;
-import org.apache.directory.shared.ldap.model.schema.SyntaxChecker;
import org.apache.directory.shared.ldap.model.schema.comparators.ByteArrayComparator;
-import org.apache.directory.shared.util.StringConstants;
import org.apache.directory.shared.util.Strings;
@@ -55,7 +53,6 @@ public class BinaryValue extends Abstrac
public BinaryValue()
{
wrappedValue = null;
- normalized = false;
valid = null;
normalizedValue = null;
}
@@ -95,16 +92,17 @@ public class BinaryValue extends Abstrac
if ( value != null )
{
this.wrappedValue = new byte[value.length];
+ this.normalizedValue = new byte[value.length];
System.arraycopy( value, 0, this.wrappedValue, 0, value.length );
+ System.arraycopy( value, 0, this.normalizedValue, 0, value.length );
}
else
{
this.wrappedValue = null;
+ this.normalizedValue = null;
}
- normalized = false;
valid = null;
- normalizedValue = null;
}
@@ -113,33 +111,13 @@ public class BinaryValue extends Abstrac
*
* @param attributeType the schema type associated with this BinaryValue
* @param value the binary value to wrap which may be null, or a zero length byte array
+ * @throws LdapInvalidAttributeValueException If the added value is invalid accordingly
+ * to the schema
*/
- public BinaryValue( AttributeType attributeType, byte[] value )
+ public BinaryValue( AttributeType attributeType, byte[] value ) throws LdapInvalidAttributeValueException
{
- this( attributeType );
-
- if ( attributeType != null )
- {
- SyntaxChecker syntaxChecker = attributeType.getSyntax().getSyntaxChecker();
-
- if ( syntaxChecker != null )
- {
- if ( syntaxChecker.isValidSyntax( value ) )
- {
- this.wrappedValue = value;
- }
- else
- {
- String msg = I18n.err( I18n.ERR_04479_INVALID_SYNTAX_VALUE, value, attributeType.getName() );
- LOG.info( msg );
- throw new IllegalArgumentException( msg );
- }
- }
- }
- else
- {
- this.wrappedValue = value;
- }
+ this( value );
+ apply( attributeType );
}
@@ -152,37 +130,16 @@ public class BinaryValue extends Abstrac
* @return the normalized version of the wrapped value
* @throws org.apache.directory.shared.ldap.model.exception.LdapException if schema entity resolution fails or normalization fails
*/
- public byte[] getNormalizedValue()
+ public byte[] getNormValue()
{
if ( isNull() )
{
return null;
}
- if ( !normalized )
- {
- try
- {
- normalize();
- }
- catch ( LdapException ne )
- {
- String message = "Cannot normalize the value :" + ne.getLocalizedMessage();
- LOG.warn( message );
- normalized = false;
- }
- }
-
- if ( normalizedValue != null )
- {
- byte[] copy = new byte[normalizedValue.length];
- System.arraycopy( normalizedValue, 0, copy, 0, normalizedValue.length );
- return copy;
- }
- else
- {
- return StringConstants.EMPTY_BYTES;
- }
+ byte[] copy = new byte[normalizedValue.length];
+ System.arraycopy( normalizedValue, 0, copy, 0, normalizedValue.length );
+ return copy;
}
@@ -203,88 +160,7 @@ public class BinaryValue extends Abstrac
return null;
}
- if ( !isNormalized() )
- {
- try
- {
- normalize();
- }
- catch ( LdapException ne )
- {
- String message = "Cannot normalize the value :" + ne.getLocalizedMessage();
- LOG.warn( message );
- normalized = false;
- }
- }
-
- if ( normalizedValue != null )
- {
- return normalizedValue;
- }
- else
- {
- return wrappedValue;
- }
- }
-
-
- /**
- * 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 )
- {
- if ( wrappedValue == null )
- {
- normalizedValue = wrappedValue;
- normalized = true;
- same = true;
- }
- else
- {
- normalizedValue = normalizer.normalize( this ).getBytes();
- normalized = true;
- same = Arrays.equals( wrappedValue, normalizedValue );
- }
- }
- else
- {
- normalizedValue = wrappedValue;
- normalized = false;
- same = true;
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- public void normalize() throws LdapException
- {
- if ( isNormalized() )
- {
- // Bypass the normalization if it has already been done.
- return;
- }
-
- if ( attributeType != null )
- {
- Normalizer normalizer = getNormalizer();
- normalize( normalizer );
- }
- else
- {
- normalizedValue = wrappedValue;
- normalized = true;
- same = true;
- }
+ return normalizedValue;
}
@@ -343,7 +219,7 @@ public class BinaryValue extends Abstrac
}
else
{
- return new ByteArrayComparator( null ).compare( getNormalizedValue(), binaryValue.getNormalizedValue() );
+ return new ByteArrayComparator( null ).compare( getNormValue(), binaryValue.getNormValue() );
}
}
@@ -504,13 +380,13 @@ public class BinaryValue extends Abstrac
/**
- * 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
+ * @return <code>true</code> if the value is HR, <code>false</code> otherwise
*/
- public boolean isBinary()
+ public boolean isHR()
{
- return true;
+ return false;
}
@@ -542,7 +418,7 @@ public class BinaryValue extends Abstrac
*/
public String getString()
{
- return Strings.utf8ToString(wrappedValue);
+ return Strings.utf8ToString( wrappedValue );
}
@@ -572,7 +448,7 @@ public class BinaryValue extends Abstrac
}
// Read the isNormalized flag
- normalized = in.readBoolean();
+ boolean normalized = in.readBoolean();
if ( normalized )
{
@@ -628,7 +504,7 @@ public class BinaryValue extends Abstrac
}
// Write the isNormalized flag
- if ( normalized )
+ if ( attributeType != null )
{
out.writeBoolean( true );
Modified: directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java?rev=1085789&r1=1085788&r2=1085789&view=diff
==============================================================================
--- directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java (original)
+++ directory/shared/trunk/ldap/model/src/main/java/org/apache/directory/shared/ldap/model/entry/DefaultEntry.java Sat Mar 26 19:17:40 2011
@@ -34,6 +34,7 @@ import java.util.Set;
import org.apache.directory.shared.i18n.I18n;
import org.apache.directory.shared.ldap.model.constants.SchemaConstants;
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.name.Dn;
import org.apache.directory.shared.ldap.model.schema.AttributeType;
import org.apache.directory.shared.ldap.model.schema.SchemaManager;
@@ -186,7 +187,7 @@ public final class DefaultEntry implemen
* @param schemaManager The reference to the schemaManager
* @param entry the entry to copy
*/
- public DefaultEntry( SchemaManager schemaManager, Entry entry )
+ public DefaultEntry( SchemaManager schemaManager, Entry entry ) throws LdapException
{
this.schemaManager = schemaManager;
@@ -230,6 +231,7 @@ public final class DefaultEntry implemen
{
// Just log a warning
LOG.warn( "The attribute '" + attribute.getId() + "' cannot be stored" );
+ throw ne;
}
}
}
@@ -436,16 +438,8 @@ public final class DefaultEntry implemen
// Initialize the ObjectClass object
initObjectClassAT();
-
- try
- {
- put( upId, attributeType, ( String ) null );
- }
- catch ( LdapException ne )
- {
- // Just discard the AttributeType
- LOG.error( I18n.err( I18n.ERR_04459, upId, ne.getLocalizedMessage() ) );
- }
+ set( attributeType );
+ set( upId );
}
@@ -591,7 +585,7 @@ public final class DefaultEntry implemen
*
* Updates the AttributeMap.
*/
- protected void createAttribute( String upId, AttributeType attributeType, byte[]... values )
+ protected void createAttribute( String upId, AttributeType attributeType, byte[]... values ) throws LdapInvalidAttributeValueException
{
EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
attribute.setUpId( upId, attributeType );
@@ -605,7 +599,7 @@ public final class DefaultEntry implemen
*
* Updates the AttributeMap.
*/
- protected void createAttribute( String upId, AttributeType attributeType, String... values )
+ protected void createAttribute( String upId, AttributeType attributeType, String... values ) throws LdapInvalidAttributeValueException
{
EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
attribute.setUpId( upId, attributeType );
@@ -619,7 +613,7 @@ public final class DefaultEntry implemen
*
* Updates the AttributeMap.
*/
- protected void createAttribute( String upId, AttributeType attributeType, Value<?>... values )
+ protected void createAttribute( String upId, AttributeType attributeType, Value<?>... values ) throws LdapInvalidAttributeValueException
{
EntryAttribute attribute = new DefaultEntryAttribute( attributeType, values );
attribute.setUpId( upId, attributeType );
@@ -2649,10 +2643,14 @@ public final class DefaultEntry implemen
*/
public boolean hasObjectClass( String objectClass )
{
+ if ( Strings.isEmpty( objectClass ) )
+ {
+ return false;
+ }
+
if ( schemaManager != null )
{
return contains( objectClassAttributeType, objectClass );
-
}
else
{