From dfbe880eb338a1d752ce790f689b5133761d7079 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 26 Sep 2013 07:35:55 +0000
Subject: [PATCH] OPENDJ-1116 Introduce abstraction for the changelog DB
---
opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java b/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
index c2a0da1..40388d7 100644
--- a/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
+++ b/opends/src/server/org/opends/server/replication/protocol/ServerStartMsg.java
@@ -31,6 +31,8 @@
import java.util.zip.DataFormatException;
import org.opends.server.replication.common.ServerState;
+import org.opends.server.types.DN;
+import org.opends.server.types.DirectoryException;
/**
* This message is used by LDAP server when they first connect.
@@ -41,7 +43,7 @@
{
private int serverId; // Id of the LDAP server that sent this message
private String serverURL;
- private String baseDn;
+ private DN baseDN;
private int maxReceiveQueue;
private int maxSendQueue;
private int maxReceiveDelay;
@@ -69,7 +71,7 @@
* @param serverId2 The serverId of the server for which the ServerStartMsg
* is created.
* @param serverURL directory server URL
- * @param baseDn The base DN.
+ * @param baseDN The base DN.
* @param windowSize The window size used by this server.
* @param heartbeatInterval The requested heartbeat interval.
* @param serverState The state of this server.
@@ -78,7 +80,7 @@
* after the start messages have been exchanged.
* @param groupId The group id of the DS for this DN
*/
- public ServerStartMsg(int serverId2, String serverURL, String baseDn,
+ public ServerStartMsg(int serverId2, String serverURL, DN baseDN,
int windowSize, long heartbeatInterval, ServerState serverState,
long generationId, boolean sslEncryption,
byte groupId)
@@ -87,7 +89,7 @@
this.serverId = serverId2;
this.serverURL = serverURL;
- this.baseDn = baseDn;
+ this.baseDN = baseDN;
this.maxReceiveDelay = 0;
this.maxReceiveQueue = 0;
this.maxSendDelay = 0;
@@ -123,7 +125,7 @@
* first calculate the length then construct the string
*/
int length = getNextLength(in, pos);
- baseDn = new String(in, pos, length, "UTF-8");
+ baseDN = DN.decode(new String(in, pos, length, "UTF-8"));
pos += length +1;
/*
@@ -199,10 +201,15 @@
// have more than one ServerState field.
serverState = new ServerState(in, pos, in.length - 1);
- } catch (UnsupportedEncodingException e)
+ }
+ catch (UnsupportedEncodingException e)
{
throw new DataFormatException("UTF-8 is not supported by this jvm.");
}
+ catch (DirectoryException e)
+ {
+ throw new DataFormatException(e.getLocalizedMessage());
+ }
}
/**
@@ -224,12 +231,13 @@
}
/**
- * Get the baseDn.
- * @return Returns the baseDn.
+ * Get the baseDN.
+ *
+ * @return Returns the baseDN.
*/
- public String getBaseDn()
+ public DN getBaseDN()
{
- return baseDn;
+ return baseDN;
}
/**
@@ -284,7 +292,7 @@
public byte[] getBytes(short sessionProtocolVersion)
{
try {
- byte[] byteDn = baseDn.getBytes("UTF-8");
+ byte[] byteDn = baseDN.toString().getBytes("UTF-8");
byte[] byteServerId = String.valueOf(serverId).getBytes("UTF-8");
byte[] byteServerUrl = serverURL.getBytes("UTF-8");
byte[] byteMaxRecvDelay =
@@ -393,7 +401,7 @@
"\nprotocolVersion: " + protocolVersion +
"\ngenerationId: " + generationId +
"\ngroupId: " + groupId +
- "\nbaseDn: " + baseDn +
+ "\nbaseDN: " + baseDN +
"\nheartbeatInterval: " + heartbeatInterval +
"\nmaxReceiveDelay: " + maxReceiveDelay +
"\nmaxReceiveQueue: " + maxReceiveQueue +
@@ -405,4 +413,4 @@
"\nsslEncryption: " + sslEncryption +
"\nwindowSize: " + windowSize;
}
- }
+}
--
Gitblit v1.10.0