From 57bd606eb6ae1f9daf876fe405e6f40ec17787d7 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Wed, 14 Sep 2011 16:15:47 +0000
Subject: [PATCH] Fix OPENDJ-282: dsreplication enable fails with duplicate server ID, while it's about the same server being referenced. Added a test to make sure when we find duplicated ID, we're not considering the same server.

---
 opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java |   15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index 9aa3260..c072205 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2007-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2011 ForgeRock AS
  */
 
 package org.opends.server.tools.dsreplication;
@@ -11149,14 +11150,15 @@
         if (server1.isReplicationServer())
         {
           int replicationID1 = server1.getReplicationServerId();
+          String replServerHostPort1 = server1.getReplicationServerHostPort();
           boolean found = false;
           for (ServerDescriptor server2 : cache2.getServers())
           {
             if (server2.isReplicationServer())
             {
-              int replicationID2 = server2.getReplicationServerId();
-              found = replicationID2 == replicationID1;
-              if (found)
+              if ((server2.getReplicationServerId() == replicationID1)
+                  && (! server2.getReplicationServerHostPort()
+                          .equalsIgnoreCase(replServerHostPort1)))
               {
                 commonRepServerIDErrors.add(
                     ERR_REPLICATION_ENABLE_COMMON_REPLICATION_SERVER_ID_ARG.get(
@@ -11181,7 +11183,7 @@
         {
           if (replica1.isReplicated())
           {
-            int domain1 = replica1.getReplicationId();
+            int domain1Id = replica1.getReplicationId();
             boolean found = false;
             for (SuffixDescriptor suffix2 : cache2.getSuffixes())
             {
@@ -11195,8 +11197,7 @@
               {
                 if (replica2.isReplicated())
                 {
-                  int domain2 = replica2.getReplicationId();
-                  if (domain1 == domain2)
+                  if (domain1Id == replica2.getReplicationId())
                   {
                     commonDomainIDErrors.add(
                         ERR_REPLICATION_ENABLE_COMMON_DOMAIN_ID_ARG.get(
@@ -11204,7 +11205,7 @@
                             suffix1.getDN(),
                             replica2.getServer().getHostPort(true),
                             suffix2.getDN(),
-                            domain1));
+                            domain1Id));
                     found = true;
                     break;
                   }

--
Gitblit v1.10.0