mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

matthew_swift
17.29.2007 d97613453f1162868c1353b5d8f6cc0fbaea5107
Fix issue 1946: make it easier to read multi-valued DN properties. The get-xxx-prop sub-commands separate multi-valued properties using comma separators. This makes the display quite hard to read when the values are DNs because the DNs themselves contain commas. This change modifies the property value printing for dsconfig so that any values containing a comma or that entirely comprise of white-space are double-quoted. Thus, the DN dc=com stays as dc=com and the value dc=example,dc=com becomes "dc=example,dc=com".

Note that the get-xxx-prop sub-commands also support a one value per line mode (-E) which makes multi-valued properties easier to read. The sub-commands also support a script-friendly mode where no quoting is performed.
1 files modified
11 ■■■■■ changed files
opends/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java 11 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/PropertyValuePrinter.java
@@ -156,7 +156,16 @@
    public <T> String visitUnknown(PropertyDefinition<T> d, T v, Void p) {
      // For all other property definition types the default encoding
      // will do.
      return d.encodeValue(v);
      String s = d.encodeValue(v);
      if (isScriptFriendly) {
        return s;
      } else if (s.trim().length() == 0 || s.contains(",")) {
        // Quote empty strings or strings containing commas
        // non-scripting mode.
        return "\"" + s + "\"";
      } else {
        return s;
      }
    }
  }