From cb23430920141d1a79c7a593a27a5c59f8df40a3 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 03 Jul 2014 10:30:55 +0000
Subject: [PATCH] Factorized code into CommonArguments.getSearchScope().

---
 opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
index 9e4a9a3..97767fd 100644
--- a/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
+++ b/opendj-cli/src/main/java/com/forgerock/opendj/cli/CommonArguments.java
@@ -30,6 +30,7 @@
 import static com.forgerock.opendj.cli.CliConstants.DEFAULT_LDAP_CONNECT_TIMEOUT;
 
 import org.forgerock.i18n.LocalizableMessage;
+import org.forgerock.opendj.ldap.SearchScope;
 
 /**
  * This class regroup commons arguments used by the different CLI.
@@ -719,6 +720,24 @@
     }
 
     /**
+     * Returns the "searchScope" string argument.<br>
+     * <i> N.B : the 's' short option is also used by servicestate, sourceldif, randomSeed, script-friendly.</i>
+     *
+     * @return The "searchScope" argument.
+     * @throws ArgumentException
+     *             If there is a problem with any of the parameters used to create this argument.
+     */
+    public static  MultiChoiceArgument<SearchScope> getSearchScope() throws ArgumentException {
+        final MultiChoiceArgument<SearchScope> searchScope = new MultiChoiceArgument<SearchScope>(
+                OPTION_LONG_SEARCHSCOPE, OPTION_SHORT_SEARCHSCOPE, OPTION_LONG_SEARCHSCOPE, false, true,
+                INFO_SEARCH_SCOPE_PLACEHOLDER.get(), SearchScope.values(), false,
+                INFO_SEARCH_DESCRIPTION_SEARCH_SCOPE.get());
+        searchScope.setPropertyName(OPTION_LONG_SEARCHSCOPE);
+        searchScope.setDefaultValue(SearchScope.WHOLE_SUBTREE);
+        return searchScope;
+    }
+
+    /**
      * Returns the "serverRoot" string argument. <br>
      * <i> N.B : the 'R' short option is also used by rejectfile, restart.</i>
      *
@@ -735,7 +754,7 @@
 
     /**
      * Returns the "servicestate" boolean argument. <br>
-     * <i> N.B : the 's' short option is also used by sourceldif, randomSeed, script-friendly.</i>
+     * <i> N.B : the 's' short option is also used by searchScope, sourceldif, randomSeed, script-friendly.</i>
      *
      * @return The "servicestate" argument.
      * @throws ArgumentException
@@ -747,8 +766,8 @@
     }
 
     /**
-     * Returns the "script-friendly" boolean argument. <i> N.B : the 's' short option is also used by servicestate,
-     * sourceldif, randomSeed.</i>
+     * Returns the "script-friendly" boolean argument.<br>
+     * <i> N.B : the 's' short option is also used by searchScope, servicestate, sourceldif, randomSeed.</i>
      *
      * @return The "script-friendly" argument.
      * @throws ArgumentException
@@ -849,7 +868,7 @@
 
     /**
      * Returns the "sourceldif" string argument. <br>
-     * <i> N.B : the 's' short option is also used by servicestate, randomSeed, script-friendly.</i>
+     * <i> N.B : the 's' short option is also used by searchScope, servicestate, randomSeed, script-friendly.</i>
      *
      * @param description
      *            The description of this argument.

--
Gitblit v1.10.0