From 27053769cfc943bda17d6107368e8f1c9305f6bb Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 09 Sep 2016 13:21:38 +0000
Subject: [PATCH] AttrHistorical code cleanup

---
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistorical.java           |   10 +++-------
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalSingle.java     |   11 +++++++----
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java   |    7 +++++--
 opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java          |    4 ++--
 opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java |    6 ++----
 5 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistorical.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistorical.java
index 7b83f30..78aa10d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistorical.java
+++ b/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);
 }
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
index 6b70441..b787305 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalMultiple.java
+++ b/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)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalSingle.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalSingle.java
index 9543edb..4e3e06c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/AttrHistoricalSingle.java
+++ b/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;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
index 59d0ab3..e9b49b0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java
+++ b/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);
           }
         }
       }
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
index 2afb988..36096f3 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/plugin/AttrHistoricalSingleTest.java
+++ b/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");

--
Gitblit v1.10.0