From 88cdfff756887b6d8d1cedc3bb6d5db82ecdac48 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 03 Feb 2014 15:46:52 +0000
Subject: [PATCH] Factorized a lot of String joining code into Utils.joinAsString().

---
 opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java |   56 +++++++++++++++++++-------------------------------------
 1 files changed, 19 insertions(+), 37 deletions(-)

diff --git a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
index 93433cf..4ea97db 100644
--- a/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
+++ b/opendj3-server-dev/src/server/org/opends/server/tools/dsreplication/ReplicationCliMain.java
@@ -97,6 +97,7 @@
 
 import org.forgerock.i18n.slf4j.LocalizedLogger;
 
+import static org.forgerock.util.Utils.*;
 import static org.opends.admin.ads.ServerDescriptor.*;
 import static org.opends.messages.AdminToolMessages.*;
 import static org.opends.messages.QuickSetupMessages.*;
@@ -878,7 +879,7 @@
     printlnProgress();
     LocalizableMessage msg = formatter.getFormattedProgress(
         INFO_PROGRESS_PURGE_HISTORICAL.get(separator,
-            Utils.getStringFromCollection(uData.getBaseDNs(), separator)));
+            joinAsString(separator, uData.getBaseDNs())));
     printProgress(msg);
     printlnProgress();
 
@@ -1366,8 +1367,7 @@
       {
         println();
         println(ERR_REPLICATION_PURGE_SUFFIXES_NOT_FOUND.get(
-                Utils.getStringFromCollection(notFound,
-                    Constants.LINE_SEPARATOR)));
+                joinAsString(Constants.LINE_SEPARATOR, notFound)));
       }
       if (interactive)
       {
@@ -4836,10 +4836,8 @@
       if (userProvidedReplicatedSuffixes.size() > 0)
       {
         println();
-        println(
-            INFO_ALREADY_REPLICATED_SUFFIXES.get(
-                Utils.getStringFromCollection(userProvidedReplicatedSuffixes,
-                    Constants.LINE_SEPARATOR)));
+        println(INFO_ALREADY_REPLICATED_SUFFIXES.get(
+            joinAsString(Constants.LINE_SEPARATOR, userProvidedReplicatedSuffixes)));
       }
       suffixes.clear();
     }
@@ -4886,15 +4884,13 @@
       {
         println();
         println(ERR_REPLICATION_ENABLE_SUFFIXES_NOT_FOUND.get(
-              Utils.getStringFromCollection(notFound,
-                  Constants.LINE_SEPARATOR)));
+              joinAsString(Constants.LINE_SEPARATOR, notFound)));
       }
       if (alreadyReplicated.size() > 0)
       {
         println();
         println(INFO_ALREADY_REPLICATED_SUFFIXES.get(
-            Utils.getStringFromCollection(alreadyReplicated,
-                Constants.LINE_SEPARATOR)));
+            joinAsString(Constants.LINE_SEPARATOR, alreadyReplicated)));
       }
       if (interactive)
       {
@@ -5016,9 +5012,7 @@
       {
         println();
         println(INFO_ALREADY_NOT_REPLICATED_SUFFIXES.get(
-            Utils.getStringFromCollection(
-                userProvidedNotReplicatedSuffixes,
-                Constants.LINE_SEPARATOR)));
+            joinAsString(Constants.LINE_SEPARATOR, userProvidedNotReplicatedSuffixes)));
       }
       suffixes.clear();
     }
@@ -5065,15 +5059,13 @@
       {
         println();
         println(ERR_REPLICATION_DISABLE_SUFFIXES_NOT_FOUND.get(
-                Utils.getStringFromCollection(notFound,
-                    Constants.LINE_SEPARATOR)));
+                joinAsString(Constants.LINE_SEPARATOR, notFound)));
       }
       if (alreadyNotReplicated.size() > 0 && displayErrors)
       {
         println();
         println(INFO_ALREADY_NOT_REPLICATED_SUFFIXES.get(
-                Utils.getStringFromCollection(alreadyNotReplicated,
-                    Constants.LINE_SEPARATOR)));
+                joinAsString(Constants.LINE_SEPARATOR, alreadyNotReplicated)));
       }
       if (interactive)
       {
@@ -5205,9 +5197,7 @@
       {
         println();
         println(INFO_ALREADY_NOT_REPLICATED_SUFFIXES.get(
-            Utils.getStringFromCollection(
-                userProvidedNotReplicatedSuffixes,
-                Constants.LINE_SEPARATOR)));
+            joinAsString(Constants.LINE_SEPARATOR, userProvidedNotReplicatedSuffixes)));
       }
       suffixes.clear();
     }
@@ -5254,15 +5244,13 @@
       {
         println();
         println(ERR_REPLICATION_INITIALIZE_LOCAL_SUFFIXES_NOT_FOUND.get(
-                Utils.getStringFromCollection(notFound,
-                    Constants.LINE_SEPARATOR)));
+                joinAsString(Constants.LINE_SEPARATOR, notFound)));
       }
       if (alreadyNotReplicated.size() > 0)
       {
         println();
         println(INFO_ALREADY_NOT_REPLICATED_SUFFIXES.get(
-                Utils.getStringFromCollection(alreadyNotReplicated,
-                    Constants.LINE_SEPARATOR)));
+                joinAsString(Constants.LINE_SEPARATOR, alreadyNotReplicated)));
       }
       if (interactive)
       {
@@ -5414,8 +5402,7 @@
       {
         println();
         println(ERR_SUFFIXES_CANNOT_BE_INITIALIZED.get(
-                Utils.getStringFromCollection(notFound,
-                    Constants.LINE_SEPARATOR)));
+                joinAsString(Constants.LINE_SEPARATOR, notFound)));
       }
       if (interactive)
       {
@@ -5604,8 +5591,7 @@
     {
       LocalizableMessage errorMsg =
         ERR_REPLICATION_NO_REPLICATION_SERVER.get(
-            Utils.getStringFromCollection(baseDNsWithNoReplicationServer,
-                Constants.LINE_SEPARATOR));
+            joinAsString(Constants.LINE_SEPARATOR, baseDNsWithNoReplicationServer));
       throw new ReplicationCliException(
           errorMsg,
           ReplicationCliReturnCode.ERROR_USER_DATA, null);
@@ -5616,8 +5602,7 @@
       {
         LocalizableMessage confirmMsg =
           INFO_REPLICATION_ONLY_ONE_REPLICATION_SERVER_CONFIRM.get(
-              Utils.getStringFromCollection(baseDNsWithOneReplicationServer,
-                  Constants.LINE_SEPARATOR));
+              joinAsString(Constants.LINE_SEPARATOR, baseDNsWithOneReplicationServer));
         try
         {
           if (!confirmAction(confirmMsg, false))
@@ -5638,8 +5623,7 @@
       {
         LocalizableMessage warningMsg =
           INFO_REPLICATION_ONLY_ONE_REPLICATION_SERVER_WARNING.get(
-              Utils.getStringFromCollection(baseDNsWithOneReplicationServer,
-                  Constants.LINE_SEPARATOR));
+              joinAsString(Constants.LINE_SEPARATOR, baseDNsWithOneReplicationServer));
         println(warningMsg);
         println();
       }
@@ -6397,8 +6381,7 @@
         }
         if (!baseDNs.isEmpty())
         {
-          String arg =
-            Utils.getStringFromCollection(baseDNs, Constants.LINE_SEPARATOR);
+          String arg = joinAsString(Constants.LINE_SEPARATOR, baseDNs);
           if (!isInteractive())
           {
             println(INFO_DISABLE_REPLICATION_ONE_POINT_OF_FAILURE.get(arg));
@@ -6484,8 +6467,7 @@
 
         if (!suffixArg.isEmpty())
         {
-          String arg =
-            Utils.getStringFromCollection(suffixArg, Constants.LINE_SEPARATOR);
+          String arg = joinAsString(Constants.LINE_SEPARATOR, suffixArg);
           if (!isInteractive())
           {
             println(INFO_DISABLE_REPLICATION_DISABLE_IN_REMOTE.get(arg));

--
Gitblit v1.10.0