* all the values that have been updated after the DELETE time
* If a value is present in the entry without any state information
* it must be removed so we simply ignore them
*/
Attribute modAttr = m.getAttribute();
if (modAttr.isEmpty())
{
/*
* We are processing a DELETE attribute modification
*/
m.setModificationType(ModificationType.REPLACE);
AttributeBuilder builder = new AttributeBuilder(modAttr, true);
for (Iterator<AttrValueHistorical> it = getValuesHistorical().iterator();
it.hasNext();)
{
AttrValueHistorical valInfo; valInfo = it.next();
if (changeNumber.older(valInfo.getValueUpdateTime()))
{
/*
* this value has been updated after this delete, therefore
* this value must be kept
*/
builder.add(valInfo.getAttributeValue());
}
else
{
/*
* this value is going to be deleted, remove it from historical
* information unless it is a Deleted attribute value that is
* more recent than this DELETE
*/
if (changeNumber.newerOrEquals(valInfo.getValueDeleteTime()))
{
it.remove();
}
}
}
m.setAttribute(builder.toAttribute());
if (changeNumber.newer(getDeleteTime()))
{
deleteTime = changeNumber;
}
if (changeNumber.newer(getLastUpdateTime()))
{
lastUpdateTime = changeNumber;
}
}
else
{
/*
* we are processing DELETE of some attribute values
*/
ArrayList<AttrValueHistorical> valuesInfo = getValuesHistorical();
AttributeBuilder builder = new AttributeBuilder(modAttr);
for (AttributeValue val : modAttr)
{
Boolean deleteIt = true; // true if the delete must be done
Boolean addedInCurrentOp = false;
/* update historical information */
AttrValueHistorical valInfo =
new AttrValueHistorical(val, null, changeNumber);
int index = valuesInfo.indexOf(valInfo);
if (index != -1)
{
/* this value already exist in the historical information */
AttrValueHistorical oldValInfo = valuesInfo.get(index);
if (changeNumber.equals(oldValInfo.getValueUpdateTime()))
{
// This value was added earlier in the same operation
// we need to keep the delete.
addedInCurrentOp = true;
}
if (changeNumber.newerOrEquals(oldValInfo.getValueDeleteTime()) &&
changeNumber.newerOrEquals(oldValInfo.getValueUpdateTime()))
{
valuesInfo.remove(index);
valuesInfo.add(valInfo);
}
else if (oldValInfo.isUpdate())
{
deleteIt = false;
}
}
else
{
valuesInfo.add(valInfo);
}
/* if the attribute value is not to be deleted
* or if attribute value is not present suppress it from the
* MOD to make sure the delete is going to succeed
*/
if (!deleteIt
|| (!modifiedEntry.hasValue(modAttr.getAttributeType(), modAttr
.getOptions(), val) && ! addedInCurrentOp))
{
// this value was already deleted before and therefore
// this should not be replayed.
builder.remove(val);