// First check that the removed attribute exists
if ( !tempEntry.containsAttribute( attributeType ) )
{
String msg = I18n.err( I18n.ERR_55, attributeType );
LOG.error( msg );
throw new LdapNoSuchAttributeException( msg );
}
// We may have to remove the attribute or only some values
if ( attribute.size() == 0 )
{
// No value : we have to remove the entire attribute
tempEntry.removeAttributes( attributeType );
}
else
{
currentAttribute = tempEntry.get( attributeType );
// Now remove all the values
for ( Value<?> value : attribute )
{
// We can only remove existing values.
if ( currentAttribute.contains( value ) )
{
currentAttribute.remove( value );
}
else
{
String msg = I18n.err( I18n.ERR_56, attributeType );
LOG.error( msg );
throw new LdapNoSuchAttributeException( msg );
}
}
// If the current attribute is empty, we have to remove
// it from the entry