|| ( !hasEMR && modifyModeNoEMR == ModifyMode.ADD_DELETE );
boolean isOrderedValue = atd.getExtensions().containsKey( "X-ORDERED" ) //$NON-NLS-1$
&& atd.getExtensions().get( "X-ORDERED" ).contains( "VALUES" ); //$NON-NLS-1$ //$NON-NLS-2$
// get old an new values for comparison
IAttribute oldAttribute = oldEntry.getAttribute( attributeDescription );
Set<String> oldValues = new HashSet<String>();
Map<String, LdifAttrValLine> oldAttrValLines = new LinkedHashMap<String, LdifAttrValLine>();
if ( oldAttribute != null )
{
for ( IValue value : oldAttribute.getValues() )
{
LdifAttrValLine attrValLine = computeDiffCreateAttrValLine( value );
oldValues.add( attrValLine.getUnfoldedValue() );
oldAttrValLines.put( attrValLine.getUnfoldedValue(), attrValLine );
}
}
IAttribute newAttribute = newEntry.getAttribute( attributeDescription );
Set<String> newValues = new HashSet<String>();
Map<String, LdifAttrValLine> newAttrValLines = new LinkedHashMap<String, LdifAttrValLine>();
if ( newAttribute != null )
{
for ( IValue value : newAttribute.getValues() )
{
LdifAttrValLine attrValLine = computeDiffCreateAttrValLine( value );
newValues.add( attrValLine.getUnfoldedValue() );
newAttrValLines.put( attrValLine.getUnfoldedValue(), attrValLine );
}
}
// check what to do
if ( oldAttribute != null && newAttribute == null )
{
// attribute only exists in the old entry: delete all values
LdifModSpec modSpec;
if ( isReplaceForced )
{
// replace (empty value list)
modSpec = LdifModSpec.createReplace( attributeDescription );
}
else
// addDelForced or default
{
// delete all
modSpec = LdifModSpec.createDelete( attributeDescription );
}
modSpec.finish( LdifModSpecSepLine.create() );
record.addModSpec( modSpec );
}
else if ( oldAttribute == null && newAttribute != null )
{
// attribute only exists in the new entry: add all values
LdifModSpec modSpec;
if ( isReplaceForced )
{
// replace (all values)
modSpec = LdifModSpec.createReplace( attributeDescription );
}
else
// addDelForced or default
{
// add (all new values)
modSpec = LdifModSpec.createAdd( attributeDescription );
}
for ( IValue value : newAttribute.getValues() )
{
modSpec.addAttrVal( computeDiffCreateAttrValLine( value ) );
}
modSpec.finish( LdifModSpecSepLine.create() );
record.addModSpec( modSpec );
}
else if ( oldAttribute != null && newAttribute != null && !oldValues.equals( newValues ) )
{
// attribute exists in both entries, check modifications
if ( isReplaceForced )
{
// replace (all new values)
LdifModSpec modSpec = LdifModSpec.createReplace( attributeDescription );
for ( IValue value : newAttribute.getValues() )
{
modSpec.addAttrVal( computeDiffCreateAttrValLine( value ) );
}
modSpec.finish( LdifModSpecSepLine.create() );
record.addModSpec( modSpec );