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

jvergara
26.10.2009 c652314f4886517e73f2d1d0f8815067d2dfa727
Fix for issue 2616 (ldapsearch: error parsing command-line arguments)

Use a MultiChoiceArgument instead of a StringArgument for the scope argument. The consequence of this is that the error message refers to the scope argument if no scope value is specified but the user provided the -s value. In addition to this the code has been modified to allow specifying capital letters for scopes (so now -b ONE is accepted by the command-line).
2 files modified
23 ■■■■■ changed files
opends/src/server/org/opends/server/tools/LDAPSearch.java 15 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPSearchOptions.java 8 ●●●● patch | view | raw | blame | history
opends/src/server/org/opends/server/tools/LDAPSearch.java
@@ -44,6 +44,7 @@
import org.opends.server.util.args.BooleanArgument;
import org.opends.server.util.args.FileBasedArgument;
import org.opends.server.util.args.IntegerArgument;
import org.opends.server.util.args.MultiChoiceArgument;
import org.opends.server.util.args.StringArgument;
import org.opends.server.protocols.asn1.ASN1Exception;
import org.opends.server.protocols.ldap.LDAPAttribute;
@@ -657,7 +658,7 @@
    StringArgument    proxyAuthzID             = null;
    StringArgument    pSearchInfo              = null;
    StringArgument    saslOptions              = null;
    StringArgument    searchScope              = null;
    MultiChoiceArgument searchScope              = null;
    StringArgument    sortOrder                = null;
    StringArgument    trustStorePath           = null;
    StringArgument    trustStorePassword       = null;
@@ -748,11 +749,18 @@
      baseDN.setPropertyName(OPTION_LONG_BASEDN);
      argParser.addArgument(baseDN);
      searchScope = new StringArgument(
      HashSet<String> allowedScopes = new HashSet<String>();
      allowedScopes.add("base");
      allowedScopes.add("one");
      allowedScopes.add("sub");
      allowedScopes.add("subordinate");
      searchScope = new MultiChoiceArgument(
              "searchScope", 's', "searchScope", false,
              false, true, INFO_SEARCH_SCOPE_PLACEHOLDER.get(), null, null,
              true, INFO_SEARCH_SCOPE_PLACEHOLDER.get(), allowedScopes,
              false,
              INFO_SEARCH_DESCRIPTION_SEARCH_SCOPE.get());
      searchScope.setPropertyName("searchScope");
      searchScope.setDefaultValue("sub");
      argParser.addArgument(searchScope);
      filename = new StringArgument("filename", OPTION_SHORT_FILENAME,
@@ -1043,7 +1051,6 @@
    }
    catch (ArgumentException ae)
    {
      Message message = ERR_ERROR_PARSING_ARGS.get(ae.getMessage());
      err.println(wrapText(message, MAX_LINE_WIDTH));
opends/src/server/org/opends/server/tools/LDAPSearchOptions.java
@@ -120,16 +120,16 @@
      {
        searchScope = WHOLE_SUBTREE;
      }
      else if(scope.equals("base"))
      else if(scope.equalsIgnoreCase("base"))
      {
        searchScope = BASE_OBJECT;
      } else if(scope.equals("one"))
      } else if(scope.equalsIgnoreCase("one"))
      {
        searchScope = SINGLE_LEVEL;
      } else if (scope.equals("sub"))
      } else if (scope.equalsIgnoreCase("sub"))
      {
        searchScope = WHOLE_SUBTREE;
      } else if (scope.equals("subordinate"))
      } else if (scope.equalsIgnoreCase("subordinate"))
      {
        searchScope = SUBORDINATE_SUBTREE;
      } else