From f354fdb634f5e8c4ca27774650f7addb6586cb32 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Fri, 21 Sep 2012 16:41:52 +0000
Subject: [PATCH] Fix issue OPENDJ-591- dsconfig --quiet isn't when using --batchFilePath. Now quiet is quiet and otherwise, commands are printed in an understandable way.

---
 opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java b/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
index 2a587ce..52b398b 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/DSConfig.java
@@ -23,6 +23,7 @@
  *
  *
  *      Copyright 2007-2010 Sun Microsystems, Inc.
+ *      Portions Copyright 2012 ForgeRock AS
  */
 package org.opends.server.tools.dsconfig;
 
@@ -123,6 +124,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public MenuResult<Integer> invoke(ConsoleApplication app)
     throws CLIException {
       try {
@@ -252,6 +254,7 @@
     /**
      * {@inheritDoc}
      */
+    @Override
     public final MenuResult<Integer> invoke(ConsoleApplication app)
     throws CLIException {
       try {
@@ -650,6 +653,7 @@
 
       Comparator<SubCommand> c = new Comparator<SubCommand>() {
 
+        @Override
         public int compare(SubCommand o1, SubCommand o2) {
           return o1.getName().compareTo(o2.getName());
         }
@@ -858,6 +862,7 @@
     Comparator<RelationDefinition<?, ?>> c =
       new Comparator<RelationDefinition<?, ?>>() {
 
+      @Override
       public int compare(RelationDefinition<?, ?> rd1,
           RelationDefinition<?, ?> rd2) {
         String s1 = rd1.getUserFriendlyName().toString();
@@ -1196,7 +1201,6 @@
   }
 
   private void handleBatchFile(String[] args) {
-    BufferedReader reader = null;
     try {
       // Build a list of initial arguments,
       // removing the batch file option + its value
@@ -1216,7 +1220,7 @@
         initialArgs.remove(batchFileArgIndex);
       }
       String batchFilePath = batchFileArgument.getValue().trim();
-      reader =
+      BufferedReader reader =
               new BufferedReader(new FileReader(batchFilePath));
       String line;
       String command = "";
@@ -1239,36 +1243,35 @@
         command = command.trim();
         // string between quotes support
         command = replaceSpacesInQuotes(command);
+        String displayCommand = new String(command);
+
         // "\ " support
         command = command.replace("\\ ", "##");
+        displayCommand = displayCommand.replace("\\ ", " ");
+
         String[] fileArguments = command.split("\\s+");
         // reset command
         command = "";
         for (int ii = 0; ii < fileArguments.length; ii++) {
           fileArguments[ii] = fileArguments[ii].replace("##", " ");
-          System.out.println(fileArguments[ii]);
         }
 
+        printlnBatchProgress(displayCommand);
+
         // Append initial arguments to the file line
         List<String> allArguments = new ArrayList<String>();
         Collections.addAll(allArguments, fileArguments);
         allArguments.addAll(initialArgs);
         String[] allArgsArray = allArguments.toArray(new String[]{});
 
-        // Build a single CLI string for display
-        StringBuffer cli = new StringBuffer();
-        for (String arg : allArgsArray) {
-          cli.append(arg + " ");
-        }
-
         int exitCode =
                 main(allArgsArray, false, getOutputStream(), getErrorStream());
         if (exitCode != 0) {
           reader.close();
           System.exit(filterExitCode(exitCode));
         }
+        printlnBatchProgress("");
       }
-
       reader.close();
 
     } catch (IOException ex) {

--
Gitblit v1.10.0