summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEndi Sukma Dewata <edewata@redhat.com>2013-02-02 11:46:57 -0500
committerEndi Sukma Dewata <edewata@redhat.com>2013-02-03 00:06:26 -0500
commitbff39f7ded97cf92aefa9ffd2892b1cdf0be5272 (patch)
treec57d308121da02d30cf37eb681ff448b24c949da
parent1465ca82ef3436344992f8a428b5781c437b901a (diff)
downloadpki-ticket-477-2.tar.gz
pki-ticket-477-2.tar.xz
pki-ticket-477-2.zip
Fixed CLI.ticket-477-2
-rw-r--r--base/java-tools/src/com/netscape/cmstools/cert/CertRequestReviewCLI.java32
1 files changed, 12 insertions, 20 deletions
diff --git a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestReviewCLI.java b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestReviewCLI.java
index 06db7db36..774d1f403 100644
--- a/base/java-tools/src/com/netscape/cmstools/cert/CertRequestReviewCLI.java
+++ b/base/java-tools/src/com/netscape/cmstools/cert/CertRequestReviewCLI.java
@@ -4,6 +4,8 @@ import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.List;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
@@ -12,6 +14,7 @@ import javax.xml.bind.Unmarshaller;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.ParseException;
+import org.apache.commons.lang.StringUtils;
import com.netscape.certsrv.base.PKIException;
import com.netscape.certsrv.cert.CertReviewResponse;
@@ -22,6 +25,9 @@ import com.netscape.cmstools.cli.MainCLI;
public class CertRequestReviewCLI extends CLI {
CertCLI parent;
+ List<String> actions = Arrays.asList(
+ "approve", "reject", "cancel", "update", "validate", "assign", "unassign"
+ );
public CertRequestReviewCLI(CertCLI parent) {
super("request-review", "Review certificate request");
@@ -37,7 +43,7 @@ public class CertRequestReviewCLI extends CLI {
public void execute(String[] args) throws Exception {
CommandLine cmd = null;
- Option option = new Option(null, "action", true, "Action (approve/reject/cancel/update/validate/assign/unassign)");
+ Option option = new Option(null, "action", true, "Action: " + StringUtils.join(actions, ", "));
option.setArgName("action");
options.addOption(option);
@@ -112,28 +118,14 @@ public class CertRequestReviewCLI extends CLI {
System.out.println();
while (action == null) {
- // Wait for action.
- System.out.print("Action (approve/reject/cancel/update/validate/assign/unassign): ");
+ // Prompt for action.
+ System.out.print("Action (" + StringUtils.join(actions, "/") + "): ");
System.out.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- action = reader.readLine();
-
- if (action.equalsIgnoreCase("approve")) {
- action = "approve";
- } else if (action.equalsIgnoreCase("reject")) {
- action = "reject";
- } else if (action.equalsIgnoreCase("cancel")) {
- action = "cancel";
- } else if (action.equalsIgnoreCase("update")) {
- action = "update";
- } else if (action.equalsIgnoreCase("validate")) {
- action = "validate";
- } else if (action.equalsIgnoreCase("assign")) {
- action = "assign";
- } else if (action.equalsIgnoreCase("unassign")) {
- action = "unassign";
- } else {
+ action = reader.readLine().trim().toLowerCase();
+
+ if (!actions.contains(action)) {
action = null;
}
}