From 81d36161ce5367fa7aa9a5d99dc8b80eacfa7cdf Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Fri, 24 Jan 2014 14:43:46 +0000
Subject: [PATCH] Checkpoint commit for OPENDJ-1288 : Migrate I18n and logging support to i18n framework and SLF4J
---
opendj3-server-dev/src/server/org/opends/server/replication/protocol/ErrorMsg.java | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ErrorMsg.java b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ErrorMsg.java
index 362be92..d88a057 100644
--- a/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ErrorMsg.java
+++ b/opendj3-server-dev/src/server/org/opends/server/replication/protocol/ErrorMsg.java
@@ -22,10 +22,10 @@
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
- * Portions copyright 2013 ForgeRock AS.
+ * Portions Copyright 2013-2014 ForgeRock AS.
*/
package org.opends.server.replication.protocol;
-import org.opends.messages.Message;
+import org.forgerock.i18n.LocalizableMessage;
import static org.opends.server.loggers.debug.DebugLogger.debugEnabled;
import static org.opends.server.loggers.debug.DebugLogger.getTracer;
@@ -47,10 +47,10 @@
private static final DebugTracer TRACER = getTracer();
// Specifies the messageID built from the error that was detected
- private int msgID;
+ private String msgID;
// Specifies the complementary details about the error that was detected
- private Message details = null;
+ private LocalizableMessage details = null;
// The time of creation of this message.
// protocol version previous to V4
@@ -64,10 +64,10 @@
* @param details The message containing the details of the error.
*/
public ErrorMsg(int sender, int destination,
- Message details)
+ LocalizableMessage details)
{
super(sender, destination);
- this.msgID = details.getDescriptor().getId();
+ this.msgID = getMessageId(details);
this.details = details;
this.creationTime = System.currentTimeMillis();
@@ -82,10 +82,10 @@
* @param i replication server id
* @param details details of the error
*/
- public ErrorMsg(int i, Message details)
+ public ErrorMsg(int i, LocalizableMessage details)
{
super(-2, i);
- this.msgID = details.getDescriptor().getId();
+ this.msgID = getMessageId(details);
this.details = details;
this.creationTime = System.currentTimeMillis();
@@ -94,9 +94,17 @@
}
/**
+ * Returns the unique message Id.
+ */
+ private String getMessageId(LocalizableMessage details)
+ {
+ return details.resourceName() + "-" + details.ordinal();
+ }
+
+ /**
* Creates a new ErrorMsg by decoding the provided byte array.
*
- * @param in A byte array containing the encoded information for the Message
+ * @param in A byte array containing the encoded information for the LocalizableMessage
* @param version The protocol version to use to decode the msg.
* @throws DataFormatException If the in does not contain a properly
* encoded message.
@@ -127,13 +135,12 @@
// MsgID
length = getNextLength(in, pos);
- String msgIdString = new String(in, pos, length, "UTF-8");
- msgID = Integer.valueOf(msgIdString);
+ msgID = new String(in, pos, length, "UTF-8");
pos += length +1;
// Details
length = getNextLength(in, pos);
- details = Message.raw(new String(in, pos, length, "UTF-8"));
+ details = LocalizableMessage.raw(new String(in, pos, length, "UTF-8"));
pos += length +1;
if (version >= ProtocolVersion.REPLICATION_PROTOCOL_V4)
@@ -156,7 +163,7 @@
*
* @return the details from this message.
*/
- public Message getDetails()
+ public LocalizableMessage getDetails()
{
return details;
}
@@ -166,7 +173,7 @@
*
* @return the msgID from this message.
*/
- public int getMsgID()
+ public String getMsgID()
{
return msgID;
}
--
Gitblit v1.10.0