From adb9e3cf2b113a17e0073a2d3185cf17336149d3 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 05 Jan 2009 01:29:32 +0000
Subject: [PATCH] Fix for issue 3689 (Control Panel: incorrect value for hostname option in the equivalent command line)

---
 opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java b/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
index cfc0420..2f147e5 100644
--- a/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
+++ b/opends/src/guitools/org/opends/guitools/controlpanel/task/Task.java
@@ -68,6 +68,20 @@
  */
 public abstract class Task
 {
+  private static String localHostName = null;
+  static
+  {
+    // Do this since by default the hostname used by the connection is
+    // 0.0.0.0, so try to figure the name of the host.  This is used to
+    // display the equivalent command-line.
+    try
+    {
+      localHostName = java.net.InetAddress.getLocalHost().getHostName();
+    }
+    catch (Throwable t)
+    {
+    }
+  }
   /**
    * The different task types.
    *
@@ -709,7 +723,11 @@
     }
     if (isServerRunning() && (ctx != null))
     {
-      String hostName = ConnectionUtils.getHostName(ctx);
+      String hostName = localHostName;
+      if (hostName == null)
+      {
+        hostName = ConnectionUtils.getHostName(ctx);
+      }
       int port = ConnectionUtils.getPort(ctx);
       boolean isSSL = ConnectionUtils.isSSL(ctx);
       boolean isStartTLS = ConnectionUtils.isStartTLS(ctx);

--
Gitblit v1.10.0