From 283a18593e644225e24b5463d1bf948d4cb3b706 Mon Sep 17 00:00:00 2001
From: jvergara <jvergara@localhost>
Date: Mon, 04 May 2009 15:13:57 +0000
Subject: [PATCH] Fix for issue 3968 (dsconfig --displayCommand does not provide valid value with duration and size syntaxes) Use the property definition to retrieve the string representation of the attribute (instead of calling String.valueOf or doing some analysis of the class of the value).

---
 opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
index 40a039b..879ad7d 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/tools/dsconfig/CreateSubCommandHandler.java
@@ -772,7 +772,7 @@
         app.printVerboseMessage(msg);
 
         if (handler != null) {
-          for (PropertyEditorModification mod : editor.getModifications()) {
+          for (PropertyEditorModification<?> mod : editor.getModifications()) {
             try {
               Argument arg = createArgument(mod);
               handler.getCommandBuilder().addArgument(arg);
@@ -1492,12 +1492,13 @@
    * @return the argument representing the modification.
    * @throws ArgumentException if there is a problem creating the argument.
    */
-  private static Argument createArgument(PropertyEditorModification mod)
+  private static <T> Argument createArgument(PropertyEditorModification<T> mod)
   throws ArgumentException
   {
     StringArgument arg;
 
-    String propName = mod.getPropertyDefinition().getName();
+    PropertyDefinition<T> propertyDefinition = mod.getPropertyDefinition();
+    String propName = propertyDefinition.getName();
 
     switch (mod.getType())
     {
@@ -1506,9 +1507,9 @@
           OPTION_DSCFG_SHORT_SET, OPTION_DSCFG_LONG_SET, false, true, true,
           INFO_VALUE_SET_PLACEHOLDER.get(), null, null,
           INFO_DSCFG_DESCRIPTION_PROP_VAL.get());
-      for (Object value : mod.getModificationValues())
+      for (T value : mod.getModificationValues())
       {
-        arg.addValue(propName+':'+getArgumentValue(value));
+        arg.addValue(propName+':'+getArgumentValue(propertyDefinition, value));
       }
       break;
     case SET:
@@ -1516,9 +1517,9 @@
           OPTION_DSCFG_SHORT_SET, OPTION_DSCFG_LONG_SET, false, true, true,
           INFO_VALUE_SET_PLACEHOLDER.get(), null, null,
           INFO_DSCFG_DESCRIPTION_PROP_VAL.get());
-      for (Object value : mod.getModificationValues())
+      for (T value : mod.getModificationValues())
       {
-        arg.addValue(propName+':'+getArgumentValue(value));
+        arg.addValue(propName+':'+getArgumentValue(propertyDefinition, value));
       }
       break;
     case RESET:
@@ -1533,9 +1534,9 @@
           null, OPTION_DSCFG_LONG_REMOVE, false, true,
           true, INFO_VALUE_SET_PLACEHOLDER.get(), null, null,
           INFO_DSCFG_DESCRIPTION_REMOVE_PROP_VAL.get());
-      for (Object value : mod.getModificationValues())
+      for (T value : mod.getModificationValues())
       {
-        arg.addValue(propName+':'+getArgumentValue(value));
+        arg.addValue(propName+':'+getArgumentValue(propertyDefinition, value));
       }
       arg = null;
       break;

--
Gitblit v1.10.0