if ( isHR != isHumanReadable() )
{
String message = "The '" + attributeType.getName() + "' AttributeType and values must " +
"both be String or binary";
LOG.error( message );
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
}
try
{
if ( isHumanReadable() )
{
normalizedValue = ( T ) normalizer.normalize( ( String ) wrappedValue );
}
else
{
normalizedValue = ( T ) normalizer.normalize( new BinaryValue( ( byte[] ) wrappedValue ) )
.getNormReference();
}
}
catch ( LdapException ne )
{
String message = I18n.err( I18n.ERR_04447_CANNOT_NORMALIZE_VALUE, ne.getLocalizedMessage() );
LOG.info( message );
}
}
}
else
{
String message = "The '" + attributeType.getName() + "' AttributeType does not have" +
" a normalizer";
LOG.error( message );
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
}
}
else
{
// No MatchingRule, there is nothing we can do but make the normalized value
// to be a reference on the user provided value
normalizedValue = wrappedValue;
}
// and checks that the value syntax is valid
try
{
LdapSyntax syntax = attributeType.getSyntax();
if ( syntax != null )
{
// Check the syntax
if ( !isValid( syntax.getSyntaxChecker() ) )
{
String message = I18n.err( I18n.ERR_04473_NOT_VALID_VALUE, wrappedValue, attributeType );
LOG.info( message );
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message );
}
}
}
catch ( LdapException le )
{
String message = I18n.err( I18n.ERR_04447_CANNOT_NORMALIZE_VALUE, le.getLocalizedMessage() );
LOG.info( message );
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message, le );
}
// Rehash the Value now
h = 0;
hashCode();