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

matthew_swift
17.37.2007 f602b47990df4c70cd62e679702b013aca1c855c
Fix issue 1923: dsconfig - provide better help when users attempt to reset a mandatory property.
3 files modified
51 ■■■■■ changed files
opends/src/server/org/opends/server/messages/ToolMessages.java 15 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java 24 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java 12 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/messages/ToolMessages.java
@@ -9023,6 +9023,17 @@
  public static final int MSGID_VERIFYINDEX_DESCRIPTION_COUNT_ERRORS =
    CATEGORY_MASK_TOOLS | SEVERITY_MASK_INFORMATIONAL | 1199;
  /**
   * The message ID for the message that will be used if the user
   * attempts to modify a property which is mandatory and which does
   * not have any default values. This takes three arguments which are
   * the name of the managed object, the name of the mandatory
   * property, and the name of the option which should be used to give
   * the property a new value.
   */
  public static final int MSGID_DSCFG_ERROR_UNABLE_TO_RESET_MANDATORY_PROPERTY =
    CATEGORY_MASK_TOOLS | SEVERITY_MASK_SEVERE_ERROR | 1200;
  /**
   * Associates a set of generic messages with the message IDs defined in this
@@ -11415,6 +11426,10 @@
                    "The %s property \"%s\" is mandatory and must " +
                    "be specified");
    registerMessage(MSGID_DSCFG_ERROR_UNABLE_TO_RESET_MANDATORY_PROPERTY,
                    "The %s property \"%s\" is mandatory cannot be reset. " +
                    "Use the \"%s\" option to specify a new value");
    registerMessage(MSGID_DSCFG_ERROR_PROPERTY_SINGLE_VALUED,
                    "It is not possible to specify multiple values for the " +
                    "%s property \"%s\" as it is single-valued");
opends/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
@@ -293,6 +293,30 @@
  /**
   * Creates an argument exception which should be used when an
   * attempt is made to reset a mandatory property that does not have
   * any default values.
   *
   * @param d
   *          The managed object definition.
   * @param name
   *          The name of the mandatory property.
   * @param setOption
   *          The name of the option which should be used to set the
   *          property's values.
   * @return Returns an argument exception.
   */
  public static ArgumentException unableToResetMandatoryProperty(
      AbstractManagedObjectDefinition d, String name, String setOption) {
    int msgID = MSGID_DSCFG_ERROR_UNABLE_TO_RESET_MANDATORY_PROPERTY;
    String message = getMessage(msgID, d.getUserFriendlyPluralName(), name,
        setOption);
    return new ArgumentException(msgID, message);
  }
  /**
   * Creates an argument exception which should be used when a
   * property name is not recognized.
   *
opends/src/server/org/opends/server/tools/dsconfig/SetPropSubCommandHandler.java
@@ -48,8 +48,10 @@
import org.opends.server.admin.OptionalRelationDefinition;
import org.opends.server.admin.PropertyDefinition;
import org.opends.server.admin.PropertyException;
import org.opends.server.admin.PropertyOption;
import org.opends.server.admin.RelationDefinition;
import org.opends.server.admin.SingletonRelationDefinition;
import org.opends.server.admin.UndefinedDefaultBehaviorProvider;
import org.opends.server.admin.client.AuthorizationException;
import org.opends.server.admin.client.CommunicationException;
import org.opends.server.admin.client.ConcurrentModificationException;
@@ -348,6 +350,16 @@
        throw ArgumentExceptionFactory.unknownProperty(d, m);
      }
      // Mandatory properties which have no defined defaults cannot be
      // reset.
      if (pd.hasOption(PropertyOption.MANDATORY)) {
        if (pd.getDefaultBehaviorProvider()
            instanceof UndefinedDefaultBehaviorProvider) {
          throw ArgumentExceptionFactory.unableToResetMandatoryProperty(d, m,
              OPTION_DSCFG_LONG_SET);
        }
      }
      // Save the modification type.
      lastModTypes.put(m, ModificationType.SET);