From e1404672e50c8f6b3c80b522a1988c9827c251e8 Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 22 Sep 2015 11:50:17 +0000
Subject: [PATCH] Improve AttributeDescription: now implements Comparable, align with SDK
---
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/EntryHistorical.java | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)
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 7adbf56..49a0de2 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
@@ -61,6 +61,8 @@
*/
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";
/**
@@ -72,8 +74,6 @@
/** 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>
@@ -303,7 +303,7 @@
// 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)
{
@@ -350,8 +350,7 @@
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();
@@ -370,7 +369,7 @@
// 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)
@@ -387,18 +386,18 @@
// 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);
@@ -412,8 +411,7 @@
// 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));
}
}
@@ -445,16 +443,14 @@
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;
}
/**
@@ -580,7 +576,7 @@
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);
--
Gitblit v1.10.0