AttrHistorical code cleanup
AttrHistorical.java:
assign(HistAttrModificationKey, AttributeType, ByteString, CSN) becomes assign(HistoricalAttributeValue)
| | |
| | | import java.util.Iterator; |
| | | import java.util.Set; |
| | | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.replication.common.CSN; |
| | | import org.opends.server.types.Entry; |
| | |
| | | public abstract CSN getDeleteTime(); |
| | | |
| | | /** |
| | | * Assign the provided information to this object. |
| | | * Assign the provided historical value to this object. |
| | | * |
| | | * @param histKey the key to assign. |
| | | * @param attrType the associated attribute type. |
| | | * @param value the associated value or null if there is no value; |
| | | * @param csn the associated CSN. |
| | | * @param histVal the historical value |
| | | */ |
| | | public abstract void assign(HistAttrModificationKey histKey, AttributeType attrType, ByteString value, CSN csn); |
| | | public abstract void assign(HistoricalAttributeValue histVal); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void assign(HistAttrModificationKey histKey, AttributeType attrType, ByteString value, CSN csn) |
| | | public void assign(HistoricalAttributeValue histVal) |
| | | { |
| | | switch (histKey) |
| | | final ByteString value = histVal.getAttributeValue(); |
| | | final AttributeType attrType = histVal.getAttributeDescription().getAttributeType(); |
| | | final CSN csn = histVal.getCSN(); |
| | | switch (histVal.getHistKey()) |
| | | { |
| | | case ADD: |
| | | if (value != null) |
| | |
| | | */ |
| | | public class AttrHistoricalSingle extends AttrHistorical |
| | | { |
| | | /** Attribute type of this historical value */ |
| | | private AttributeType attributeType; |
| | | /** Last added value. */ |
| | | private ByteString value; |
| | | /** Attribute type for this historical value */ |
| | | private AttributeType attributeType; |
| | | /** Last time when a value was added. */ |
| | | private CSN addTime; |
| | | /** Last time when the attribute was deleted. */ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void assign(HistAttrModificationKey histKey, AttributeType attrType, ByteString value, CSN csn) |
| | | public void assign(HistoricalAttributeValue histVal) |
| | | { |
| | | switch (histKey) |
| | | final ByteString value = histVal.getAttributeValue(); |
| | | final CSN csn = histVal.getCSN(); |
| | | |
| | | switch (histVal.getHistKey()) |
| | | { |
| | | case ADD: |
| | | this.addTime = csn; |
| | |
| | | } |
| | | else |
| | | { |
| | | AttributeDescription attrDesc = histVal.getAttributeDescription(); |
| | | final AttributeDescription attrDesc = histVal.getAttributeDescription(); |
| | | if (attrDesc == null) |
| | | { |
| | | /* |
| | |
| | | attrInfo = AttrHistorical.createAttributeHistorical(attrDesc.getAttributeType()); |
| | | newHistorical.attributesHistorical.put(attrDesc, attrInfo); |
| | | } |
| | | attrInfo.assign(histVal.getHistKey(), attrDesc.getAttributeType(), histVal.getAttributeValue(), csn); |
| | | attrInfo.assign(histVal); |
| | | } |
| | | } |
| | | } |
| | |
| | | * <p> |
| | | * Could multi-threading make this scenario possible? |
| | | * <p> |
| | | * Or is it due to {@link AttrHistoricalSingle#assign(HistAttrModificationKey, ByteString, CSN)} ? |
| | | * Or is it due to {@link AttrHistoricalSingle#assign(HistoricalAttributeValue)} ? |
| | | */ |
| | | @Test |
| | | public void replay_deleteDubious() throws Exception |
| | | { |
| | | AttributeType attrType = Schema.getDefaultSchema().getAttributeType(ATTRIBUTE_NAME); |
| | | HistoricalAttributeValue histAttrVal = new HistoricalAttributeValue(ATTRIBUTE_NAME + ":" + csn + ":add:X"); |
| | | attrHist.assign(histAttrVal.getHistKey(), attrType, histAttrVal.getAttributeValue(), csn); |
| | | attrHist.assign(new HistoricalAttributeValue(ATTRIBUTE_NAME + ":" + csn + ":add:X")); |
| | | mod = newModification(ADD, "X"); |
| | | entry.applyModification(mod); |
| | | assertAttributeValue(entry, "X"); |