From 240bd8adc6f824ba2d6738464fb90bf83e98ae5a 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).
---
opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java | 31 +++++++++++++++++++++----------
1 files changed, 21 insertions(+), 10 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 364c0c9..21f2247 100644
--- a/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
+++ b/opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -72,7 +72,6 @@
import org.opends.server.admin.client.ManagedObjectDecodingException;
import org.opends.server.admin.client.ManagementContext;
import org.opends.server.tools.ClientException;
-import org.opends.server.types.CommonSchemaElements;
import org.opends.server.util.ServerConstants;
import org.opends.server.util.args.Argument;
import org.opends.server.util.args.ArgumentException;
@@ -1399,24 +1398,36 @@
}
}
+ /**
+ * Returns the string value for a given object as it will be displayed
+ * in the equivalent command-line. The code will cast the provided object
+ * using the property definition.
+ * @param propertyDefinition the property definition.
+ * @param o the value.
+ * @param <T> the type of the property to be retrieved.
+ * @return the String value to be displayed in the equivalent command-line.
+ */
+ protected static <T> String castAndGetArgumentValue(
+ PropertyDefinition<T> propertyDefinition, Object o)
+ {
+ String value = propertyDefinition.encodeValue(
+ propertyDefinition.castValue(o));
+ return value;
+ }
/**
* Returns the string value for a given object as it will be displayed
* in the equivalent command-line.
+ * @param propertyDefinition the property definition.
* @param o the value.
+ * @param <T> the type of the property to be retrieved.
* @return the String value to be displayed in the equivalent command-line.
*/
- protected static String getArgumentValue(Object o)
+ protected static <T> String getArgumentValue(
+ PropertyDefinition<T> propertyDefinition, T o)
{
String value;
- if (o instanceof CommonSchemaElements)
- {
- value = ((CommonSchemaElements)o).getNameOrOID();
- }
- else
- {
- value = String.valueOf(o);
- }
+ value = propertyDefinition.encodeValue(o);
return value;
}
--
Gitblit v1.10.0