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

jvergara
26.30.2007 03889aa19bbeb860d9e460df2a2023df366da89d
Fix for issue 2010.

The fix consists in including a little bit more on context to the error message.

For command-line dsconfig list-local-db-indexes --backend-name tasks -n -p 1389 -w s

The output was:

"Task Backend" is not a recognized component type

With the fix the output is:

"Task Backend" component type cannot be used with subcommand
{list-local-db-indexes}
4 files modified
48 ■■■■■ changed files
opends/src/messages/messages/dsconfig.properties 6 ●●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java 28 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java 6 ●●●● patch | view | raw | blame | history
opends/src/messages/messages/dsconfig.properties
@@ -167,8 +167,8 @@
 following syntax: property:value
SEVERE_ERR_DSCFG_ERROR_SUB_TYPE_UNRECOGNIZED_1066=The sub-type "%s" is not a \
 recognized type of %s. It should be one of: %s
SEVERE_ERR_DSCFG_ERROR_TYPE_UNRECOGNIZED_1067="%s" is not a recognized \
 component type
SEVERE_ERR_DSCFG_ERROR_TYPE_UNRECOGNIZED_FOR_CATEGORY_1067="%s" component \
 type that cannot be used with category "%s"
SEVERE_ERR_DSCFG_ERROR_NO_SEPARATOR_IN_PROPERTY_MOD_1068=The property \
 modification "%s" does not contain a name/value separator. The argument \
 should have the following syntax: property[+|-]:value
@@ -415,6 +415,8 @@
INFO_DSCFG_PROMPT_SECURITY_PROTOCOL_DEFAULT_CHOICE_1391=%d
SEVERE_ERR_DSCFG_PROMPT_SECURITY_INVALID_FILE_PATH_1392=The provided path is not valid
INFO_DSCFG_PROMPT_EDIT_AGAIN_1393=Would you like to edit the properties of the %s again in order to resolve this problem?
SEVERE_ERR_DSCFG_ERROR_TYPE_UNRECOGNIZED_FOR_SUBCOMMAND_1394="%s" component \
 type cannot be used with subcommand {%s}
INFO_EDITOR_PROMPT_SELECT_COMPONENT_MULTI_127=Select one or more %s for the "%s" property:
INFO_EDITOR_PROMPT_SELECT_COMPONENT_SINGLE_128=Select a %s for the "%s" property:
INFO_EDITOR_HEADING_COMPONENT_SUMMARY_129=The "%s" property references the following %s:
opends/src/server/org/opends/server/tools/dsconfig/ArgumentExceptionFactory.java
@@ -584,22 +584,6 @@
  }
  /**
   * Creates an argument exception which should be used when a managed
   * object type argument is not recognized.
   *
   * @param typeName
   *          The unrecognized component type.
   * @return Returns an argument exception.
   */
  public static ArgumentException unknownType(String typeName) {
    Message msg = ERR_DSCFG_ERROR_TYPE_UNRECOGNIZED.get(typeName);
    return new ArgumentException(msg);
  }
  /**
   * Creates an argument exception which should be used when a managed
   * object type argument is not associated with a category.
@@ -610,8 +594,8 @@
   *          The unrecognized component type.
   * @return Returns an argument exception.
   */
  public static ArgumentException unknownTypeInCategory(String categoryName,
      String typeName) {
  public static ArgumentException unknownTypeForCategory(String typeName,
      String categoryName) {
    Message msg =
        ERR_DSCFG_ERROR_CATEGORY_TYPE_UNRECOGNIZED.get(typeName, categoryName);
    return new ArgumentException(msg);
@@ -628,12 +612,14 @@
   *          The relation definition.
   * @param d
   *          The definition of the managed object that was retrieved.
   *
   * @param subcommandName the sub-command name.
   * @return Returns a CLI exception.
   */
  public static CLIException wrongManagedObjectType(RelationDefinition<?, ?> r,
      ManagedObjectDefinition<?, ?> d) {
    Message msg = ERR_DSCFG_ERROR_TYPE_UNRECOGNIZED
        .get(d.getUserFriendlyName());
      ManagedObjectDefinition<?, ?> d, String subcommandName) {
    Message msg = ERR_DSCFG_ERROR_TYPE_UNRECOGNIZED_FOR_SUBCOMMAND.get(
        d.getUserFriendlyName(), subcommandName);
    return new CLIException(msg);
  }
opends/src/server/org/opends/server/tools/dsconfig/HelpSubCommandHandler.java
@@ -825,7 +825,6 @@
          throw ArgumentExceptionFactory.unknownCategory(categoryName);
        }
        categoryName = null;
        subTypes = tagMap.get(tag);
        if (subTypes == null) {
          throw ArgumentExceptionFactory.unknownCategory(categoryName);
@@ -838,8 +837,8 @@
      if (typeName != null) {
        AbstractManagedObjectDefinition<?, ?> d = subTypes.get(typeName);
        if (d == null) {
          throw ArgumentExceptionFactory.unknownTypeInCategory(categoryName,
              typeName);
          throw ArgumentExceptionFactory.unknownTypeForCategory(typeName,
              categoryName);
        }
        dlist.add(d);
@@ -863,7 +862,8 @@
      }
      if (!isFound) {
        throw ArgumentExceptionFactory.unknownType(typeName);
        throw ArgumentExceptionFactory.unknownTypeForCategory(typeName,
            categoryName);
      }
    } else {
      // User did not specify a category nor a sub-type.
opends/src/server/org/opends/server/tools/dsconfig/SubCommandHandler.java
@@ -175,7 +175,7 @@
          // definition.
          if (!child.getManagedObjectDefinition().isChildOf(d)) {
            clie = ArgumentExceptionFactory.wrongManagedObjectType(r, child
                .getManagedObjectDefinition());
                .getManagedObjectDefinition(), getSubCommand().getName());
            result = MenuResult.quit();
          } else {
            result = MenuResult.<ManagedObject<?>>success(child);
@@ -219,7 +219,7 @@
          // definition.
          if (!child.getManagedObjectDefinition().isChildOf(d)) {
            clie = ArgumentExceptionFactory.wrongManagedObjectType(r, child
                .getManagedObjectDefinition());
                .getManagedObjectDefinition(), getSubCommand().getName());
            result = MenuResult.quit();
          } else {
            result = MenuResult.<ManagedObject<?>>success(child);
@@ -263,7 +263,7 @@
          // definition.
          if (!child.getManagedObjectDefinition().isChildOf(d)) {
            clie = ArgumentExceptionFactory.wrongManagedObjectType(r, child
                .getManagedObjectDefinition());
                .getManagedObjectDefinition(), getSubCommand().getName());
            result = MenuResult.quit();
          } else {
            result = MenuResult.<ManagedObject<?>>success(child);