| | |
| | | */ |
| | | public class EntryHistorical |
| | | { |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Name of the attribute used to store historical information. */ |
| | | public static final String HISTORICAL_ATTRIBUTE_NAME = "ds-sync-hist"; |
| | | /** |
| | |
| | | /** Name of the entryuuid attribute. */ |
| | | public static final String ENTRYUUID_ATTRIBUTE_NAME = "entryuuid"; |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** |
| | | * The delay to purge the historical information. |
| | | * <p> |
| | |
| | | |
| | | // Read from this entryHistorical, |
| | | // Create one empty if none was existing in this entryHistorical. |
| | | AttributeDescription attrDesc = new AttributeDescription(modAttr); |
| | | AttributeDescription attrDesc = AttributeDescription.create(modAttr); |
| | | AttrHistorical attrHist = attributesHistorical.get(attrDesc); |
| | | if (attrHist == null) |
| | | { |
| | |
| | | for (Map.Entry<AttributeDescription, AttrHistorical> mapEntry : attributesHistorical.entrySet()) |
| | | { |
| | | AttributeDescription attrDesc = mapEntry.getKey(); |
| | | AttributeType type = attrDesc.attributeType; |
| | | String optionsString = attrDesc.toOptionsString(); |
| | | String options = attrDesc.toString(); |
| | | AttrHistorical attrHist = mapEntry.getValue(); |
| | | |
| | | CSN deleteTime = attrHist.getDeleteTime(); |
| | |
| | | // this hist must be purged now, so skip its encoding |
| | | continue; |
| | | } |
| | | String strValue = encode(DEL, type, optionsString, attrValHist.getValueDeleteTime(), value); |
| | | String strValue = encode(DEL, options, attrValHist.getValueDeleteTime(), value); |
| | | builder.add(strValue); |
| | | } |
| | | else if (attrValHist.getValueUpdateTime() != null) |
| | |
| | | // unit tests do not like changing it |
| | | if (attrDel && updateTime == deleteTime && value != null) |
| | | { |
| | | strValue = encode(REPL, type, optionsString, updateTime, value); |
| | | strValue = encode(REPL, options, updateTime, value); |
| | | attrDel = false; |
| | | } |
| | | else if (value != null) |
| | | { |
| | | strValue = encode(ADD, type, optionsString, updateTime, value); |
| | | strValue = encode(ADD, options, updateTime, value); |
| | | } |
| | | else |
| | | { |
| | | // "add" without any value is suspicious. Tests never go there. |
| | | // Is this used to encode "add" with an empty string? |
| | | strValue = encode(ADD, type, optionsString, updateTime); |
| | | strValue = encode(ADD, options, updateTime); |
| | | } |
| | | |
| | | builder.add(strValue); |
| | |
| | | // this hist must be purged now, so skip its encoding |
| | | continue; |
| | | } |
| | | String strValue = encode(ATTRDEL, type, optionsString, deleteTime); |
| | | builder.add(strValue); |
| | | builder.add(encode(ATTRDEL, options, deleteTime)); |
| | | } |
| | | } |
| | | |
| | |
| | | return needsPurge; |
| | | } |
| | | |
| | | private String encode(HistAttrModificationKey modKey, AttributeType type, |
| | | String optionsString, CSN changeTime) |
| | | private String encode(HistAttrModificationKey modKey, String options, CSN changeTime) |
| | | { |
| | | return type.getNormalizedPrimaryName() + optionsString + ":" + changeTime + ":" + modKey; |
| | | return options + ":" + changeTime + ":" + modKey; |
| | | } |
| | | |
| | | private String encode(HistAttrModificationKey modKey, AttributeType type, |
| | | String optionsString, CSN changeTime, ByteString value) |
| | | private String encode(HistAttrModificationKey modKey, String options, CSN changeTime, ByteString value) |
| | | { |
| | | return type.getNormalizedPrimaryName() + optionsString + ":" + changeTime + ":" + modKey + ":" + value; |
| | | return options + ":" + changeTime + ":" + modKey + ":" + value; |
| | | } |
| | | |
| | | /** |
| | |
| | | AttrHistorical attrInfo = newHistorical.attributesHistorical.get(attrDesc); |
| | | if (attrInfo == null) |
| | | { |
| | | attrInfo = AttrHistorical.createAttributeHistorical(attrDesc.attributeType); |
| | | attrInfo = AttrHistorical.createAttributeHistorical(attrDesc.getAttributeType()); |
| | | newHistorical.attributesHistorical.put(attrDesc, attrInfo); |
| | | } |
| | | attrInfo.assign(histVal.getHistKey(), histVal.getAttributeValue(), csn); |