From f5abff29450dc88d7f4432dc93499bb5a05f2924 Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Fri, 30 Jul 2010 13:32:00 +0000
Subject: [PATCH] Fixes an issue with dsconfig --displayCommand sometime displaying a wrong command. It was using the friendly name and not the actual name. Most of the time, the 2 names are the same, but for the ones that are not, the displayed command would be incorrect.

---
 opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java b/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
index 21f2247..22e7dfe 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2007-2009 Sun Microsystems, Inc.
+ *      Copyright 2007-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.tools.dsconfig;
 
@@ -1231,12 +1231,25 @@
             arg.addValue(children.get(children.firstKey()));
           } else {
             // Set relation: need the short type name.
-            String longName = children.firstKey();
-            try {
-              AbstractManagedObjectDefinition<?,?> cd = d.getChild(longName);
+            String friendlyName = children.firstKey();
+            String shortName = children.get(friendlyName);
+            try
+            {
+              AbstractManagedObjectDefinition<?, ?> cd = null;
+              try
+              {
+                cd = d.getChild(shortName);
+              }
+              catch (IllegalArgumentException e)
+              {
+                // Last resource: try with friendly name
+                cd = d.getChild(friendlyName);
+              }
               arg.addValue(getShortTypeName(r.getChildDefinition(), cd));
-            } catch (IllegalArgumentException e) {
-              arg.addValue(children.get(children.firstKey()));
+            }
+            catch (IllegalArgumentException e)
+            {
+              arg.addValue(shortName);
             }
           }
           getCommandBuilder().addArgument(arg);

--
Gitblit v1.10.0