mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
02.02.2016 27053769cfc943bda17d6107368e8f1c9305f6bb
AttrHistorical code cleanup

AttrHistorical.java:
assign(HistAttrModificationKey, AttributeType, ByteString, CSN) becomes assign(HistoricalAttributeValue)
5 files modified
38 ■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistorical.java 10 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java 7 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalSingle.java 11 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java 4 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistorical.java
@@ -19,7 +19,6 @@
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;
@@ -82,12 +81,9 @@
  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);
}
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
@@ -563,9 +563,12 @@
  }
  @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)
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalSingle.java
@@ -38,10 +38,10 @@
 */
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. */
@@ -275,9 +275,12 @@
  }
  @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;
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
@@ -555,7 +555,7 @@
          }
          else
          {
            AttributeDescription attrDesc = histVal.getAttributeDescription();
            final AttributeDescription attrDesc = histVal.getAttributeDescription();
            if (attrDesc == null)
            {
              /*
@@ -581,7 +581,7 @@
              attrInfo = AttrHistorical.createAttributeHistorical(attrDesc.getAttributeType());
              newHistorical.attributesHistorical.put(attrDesc, attrInfo);
            }
            attrInfo.assign(histVal.getHistKey(), attrDesc.getAttributeType(), histVal.getAttributeValue(), csn);
            attrInfo.assign(histVal);
          }
        }
      }
opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
@@ -211,14 +211,12 @@
   * <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");