From 7ad3b49f29529fc14f6f0732dc39062a1faf94e2 Mon Sep 17 00:00:00 2001
From: lutoff <lutoff@localhost>
Date: Tue, 25 Sep 2007 07:32:05 +0000
Subject: [PATCH] With these modificationd, if both useSSL and useStartTls are set to false in the properties file, dsconfig interactive mode will not prompt for protocol.

---
 opendj-sdk/opends/src/server/org/opends/server/util/args/Argument.java                        |   28 ++++++++++++++
 opendj-sdk/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java |    6 +++
 opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java        |   22 ++---------
 opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java                  |   11 +----
 4 files changed, 40 insertions(+), 27 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/args/Argument.java b/opendj-sdk/opends/src/server/org/opends/server/util/args/Argument.java
index b91815c..bf75801 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/args/Argument.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/args/Argument.java
@@ -88,6 +88,9 @@
   // information.
   private String valuePlaceholder;
 
+  // Indicates whether this argument was provided in the set of properties
+  // found is a properties file.
+  private boolean isValueSetByProperty;
 
 
   /**
@@ -139,6 +142,7 @@
     this.defaultValue     = defaultValue;
     this.propertyName     = propertyName;
     this.description      = description;
+    this.isValueSetByProperty = false ;
 
     if ((shortIdentifier == null) && (longIdentifier == null))
     {
@@ -434,7 +438,31 @@
     this.propertyName = propertyName;
   }
 
+  /**
+   * Indicates whether this argument was provided in the set of
+   * properties found is a properties file.
+   *
+   * @return <CODE>true</CODE> if this argument was provided in the
+   *         set of properties found is a properties file, or
+   *         <CODE>false</CODE> if not.
+   */
+  public boolean isValueSetByProperty()
+  {
+    return isValueSetByProperty;
+  }
 
+  /**
+   * Specifies whether this argument was provided in the set of
+   * properties found is a properties file.
+   *
+   * @param isValueSetByProperty
+   *          Specify whether this argument was provided in the set
+   *          of properties found is a properties file.
+   */
+  public void setValueSetByProperty(boolean isValueSetByProperty)
+  {
+    this.isValueSetByProperty = isValueSetByProperty;
+  }
 
   /**
    * Retrieves the human-readable description for this argument.
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java
index 7495b99..1fa2afd 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/args/ArgumentParser.java
@@ -1002,19 +1002,12 @@
               .toLowerCase());
           if (value != null)
           {
+            a.addValue(value);
             if (a.needsValue())
             {
-              a.addValue(value);
               a.setPresent(true);
             }
-            else
-            if (value.toLowerCase().equals(CONFIG_VALUE_TRUE))
-            {
-              // Boolean value. Set to "present" only if
-              // value property value is "true"
-              // (insensitive case)
-              a.setPresent(true);
-            }
+            a.setValueSetByProperty(true);
           }
         }
       }
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java b/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
index 9adc76d..9acaa64 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/args/SubCommandArgumentParser.java
@@ -1241,19 +1241,12 @@
               .toLowerCase());
           if (value != null)
           {
+            a.addValue(value);
             if (a.needsValue())
             {
-              a.addValue(value);
               a.setPresent(true);
             }
-            else
-            if (value.toLowerCase().equals(CONFIG_VALUE_TRUE))
-            {
-              // Boolean value. Set to "present" only if
-              // value property value is "true"
-              // (insensitive case)
-              a.setPresent(true);
-            }
+            a.setValueSetByProperty(true);
           }
         }
       }
@@ -1293,19 +1286,12 @@
                 .toLowerCase());
             if (value != null)
             {
+              a.addValue(value);
               if (a.needsValue())
               {
-                a.addValue(value);
                 a.setPresent(true);
               }
-              else
-              if (value.toLowerCase().equals(CONFIG_VALUE_TRUE))
-              {
-                // Boolean value. Set to "present" only if
-                // value property value is "true"
-                // (insensitive case)
-                a.setPresent(true);
-              }
+              a.setValueSetByProperty(true);
             }
           }
         }
diff --git a/opendj-sdk/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java b/opendj-sdk/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
index 993ddbd..5d6ce55 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/util/cli/LDAPConnectionConsoleInteraction.java
@@ -335,6 +335,12 @@
         secureArgsList.useSSLArg.isPresent()
         ||
         secureArgsList.useStartTLSArg.isPresent()
+        ||
+        (
+          secureArgsList.useSSLArg.isValueSetByProperty()
+          &&
+          secureArgsList.useStartTLSArg.isValueSetByProperty()
+        )
       );
     if (app.isInteractive() && !connectionTypeIsSet)
     {

--
Gitblit v1.10.0