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

jcambon
10.07.2008 93ad50f0e8b182978c790c0707bd0a910ae2a39e
Fix for Issue #3569: dsconfig does not handle correctly multi-valued properties

3 files modified
64 ■■■■ changed files
opends/src/messages/messages/dsconfig.properties 3 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java 19 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java 42 ●●●●● patch | view | raw | blame | history
opends/src/messages/messages/dsconfig.properties
@@ -179,7 +179,7 @@
 modification "%s" does not contain a property value. The argument should have \
 the following syntax: property[+|-]:value
SEVERE_ERR_DSCFG_ERROR_INCOMPATIBLE_PROPERTY_MOD_1071=The property \
 modification "%s" is incompatible with a previous modification to the same \
 modification "%s" is incompatible with another modification to the same \
 property
SEVERE_ERR_DSCFG_ERROR_WRONG_MANAGED_OBJECT_TYPE_1072=The %s could not be \
 retrieved because it was the wrong type of managed object: %s
@@ -470,3 +470,4 @@
 server at %s on port %s. Check this port is an administration port
SEVERE_ERR_DSCFG_ERROR_LDAP_FAILED_TO_CONNECT_NOT_TRUSTED_158=Unable to connect to the \
 server at %s on port %s. In non-interactive mode, you must use the '--trustAll' option
SEVERE_ERR_DSCFG_ERROR_VALUE_DOES_NOT_EXIST_159=The value %s for the %s property does not exist
opends/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
@@ -604,6 +604,25 @@
  /**
   * Creates an argument exception which should be used when a multi-valued
   * property does not contain a given value.
   *
   * @param value
   *          The property value.
   * @param propertyName
   *          The property name.
   * @return Returns an argument exception.
   */
  public static ArgumentException unknownValueForMultiValuedProperty(
    String value, String propertyName) {
          Message msg = ERR_DSCFG_ERROR_VALUE_DOES_NOT_EXIST.get(
            value, propertyName);
    return new ArgumentException(msg);
  }
  /**
   * Creates a CLI exception which should be used when a managed
   * object is retrieved but does not have the correct type
   * appropriate for the associated sub-command.
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -754,6 +754,9 @@
    // Set properties.
    for (String m : propertySetArgument.getValues()) {
      if (!propertyResetArgument.getValues().isEmpty()) {
        throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
      }
      // Parse the property "property:value".
      int sep = m.indexOf(':');
@@ -790,6 +793,9 @@
    // Remove properties.
    for (String m : propertyRemoveArgument.getValues()) {
      if (!propertyResetArgument.getValues().isEmpty()) {
        throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
      }
      // Parse the property "property:value".
      int sep = m.indexOf(':');
@@ -816,19 +822,20 @@
      }
      // Apply the modification.
      if (lastModTypes.containsKey(propertyName)) {
        if (lastModTypes.get(propertyName) == ModificationType.SET) {
          throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
        }
      } else {
        lastModTypes.put(propertyName, ModificationType.REMOVE);
        modifyPropertyValues(child, pd, changes, ModificationType.REMOVE,
            value);
      if (lastModTypes.containsKey(propertyName) &&
        (lastModTypes.get(propertyName) == ModificationType.SET)) {
        throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
      }
      lastModTypes.put(propertyName, ModificationType.REMOVE);
      modifyPropertyValues(child, pd, changes, ModificationType.REMOVE, value);
    }
    // Add properties.
    for (String m : propertyAddArgument.getValues()) {
      if (!propertyResetArgument.getValues().isEmpty()) {
        throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
      }
      // Parse the property "property:value".
      int sep = m.indexOf(':');
@@ -855,14 +862,13 @@
      }
      // Apply the modification.
      if (lastModTypes.containsKey(propertyName)) {
        if (lastModTypes.get(propertyName) == ModificationType.SET) {
          throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
        }
      } else {
        lastModTypes.put(propertyName, ModificationType.ADD);
        modifyPropertyValues(child, pd, changes, ModificationType.ADD, value);
      if (lastModTypes.containsKey(propertyName) &&
        (lastModTypes.get(propertyName) == ModificationType.SET)) {
        throw ArgumentExceptionFactory.incompatiblePropertyModification(m);
      }
      lastModTypes.put(propertyName, ModificationType.ADD);
      modifyPropertyValues(child, pd, changes, ModificationType.ADD, value);
    }
    // Apply the command line changes.
@@ -931,7 +937,11 @@
        values.add(value);
        break;
      case REMOVE:
        values.remove(value);
        if (values.remove(value) != true) {
          // value was not part of values
          throw ArgumentExceptionFactory.
            unknownValueForMultiValuedProperty(s, pd.getName());
        }
        break;
      case SET:
        values = new TreeSet<T>(pd);