opends/src/guitools/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -43,6 +43,7 @@ import static org.opends.messages.AdminToolMessages.*; import static org.opends.messages.QuickSetupMessages.*; import static org.opends.messages.UtilityMessages.*; import org.opends.quicksetup.*; import org.opends.quicksetup.event.ProgressUpdateEvent; @@ -255,7 +256,6 @@ println(); } return userData; } @@ -297,6 +297,8 @@ builder.setDefault(Message.raw(String.valueOf(REMOVE_ALL)), MenuResult.success(REMOVE_ALL)); builder.setMaxTries(CONFIRMATION_MAX_TRIES); Menu<Integer> menu = builder.toMenu(); int choice; try @@ -320,7 +322,12 @@ catch (CLIException ce) { choice = REMOVE_ALL; cancelled = true; LOG.log(Level.WARNING, "Error reading input: "+ce, ce); if (ce.getMessageObject().getDescriptor().equals(ERR_TRIES_LIMIT_REACHED)) { println(ce.getMessageObject()); } } if (cancelled) @@ -634,7 +641,7 @@ { println(ce.getMessageObject()); println(); cancelled = false; cancelled = true; } } else opends/src/quicksetup/org/opends/quicksetup/Launcher.java
@@ -296,6 +296,10 @@ printUsage(true); System.exit(ReturnCode.USER_DATA_ERROR.getReturnCode()); } else if (returnValue.equals(ReturnCode.CANCELLED)) { System.exit(ReturnCode.CANCELLED.getReturnCode()); } return returnValue.getReturnCode(); } opends/src/quicksetup/org/opends/quicksetup/QuickSetupCli.java
@@ -36,8 +36,7 @@ import org.opends.messages.Message; /** * This enum contains the different type of ApplicationException that we can * have. * Class used by Launcher to start a CLI application. * */ public class QuickSetupCli { opends/src/server/org/opends/server/util/cli/ConsoleApplication.java
@@ -685,8 +685,7 @@ } nTries++; } throw new CLIException(ERR_CONFIRMATION_TRIES_LIMIT_REACHED.get( maxTries)); throw new CLIException(ERR_TRIES_LIMIT_REACHED.get(maxTries)); } /** @@ -726,9 +725,10 @@ } catch (CLIException ce) { if (ce.getMessageObject().equals( ERR_CONFIRMATION_TRIES_LIMIT_REACHED.get( CONFIRMATION_MAX_TRIES))) if (ce.getMessageObject().getDescriptor().equals( ERR_CONFIRMATION_TRIES_LIMIT_REACHED) || ce.getMessageObject().getDescriptor().equals( ERR_TRIES_LIMIT_REACHED)) { throw ce; } opends/src/server/org/opends/server/util/cli/MenuBuilder.java
@@ -145,13 +145,16 @@ // The menu title. private final Message title; // The maximum number of times we display the menu if the user provides // bad input (-1 for unlimited). private int nMaxTries; // Private constructor. private MenuImpl(ConsoleApplication app, Message title, Message prompt, TableBuilder ntable, TableBuilder ctable, TablePrinter printer, Map<String, MenuCallback<T>> callbacks, boolean allowMultiSelect, MenuCallback<T> defaultCallback, Message defaultDescription) { MenuCallback<T> defaultCallback, Message defaultDescription, int nMaxTries) { this.app = app; this.title = title; this.prompt = prompt; @@ -162,6 +165,7 @@ this.allowMultiSelect = allowMultiSelect; this.defaultCallback = defaultCallback; this.defaultDescription = defaultDescription; this.nMaxTries = nMaxTries; } @@ -276,7 +280,16 @@ } // Get the user's choice. MenuCallback<T> choice = app.readValidatedInput(promptMsg, validator); MenuCallback<T> choice; if (nMaxTries != -1) { choice = app.readValidatedInput(promptMsg, validator, nMaxTries); } else { choice = app.readValidatedInput(promptMsg, validator); } // Invoke the user's selected choice. MenuResult<T> result = choice.invoke(app); @@ -371,7 +384,9 @@ // The menu prompt. private Message prompt = null; // The maximum number of times that we allow the user to provide an invalid // answer (-1 if unlimited). private int nMaxTries = -1; /** * Creates a new menu. @@ -805,6 +820,18 @@ } return new MenuImpl<T>(app, title, prompt, nbuilder, cbuilder, printer, callbacks, allowMultiSelect, defaultCallback, defaultDescription); callbacks, allowMultiSelect, defaultCallback, defaultDescription, nMaxTries); } /** * Sets the maximum number of tries that the user can provide an invalid * value in the menu. -1 for unlimited tries (the default). If this limit is * reached a CLIException will be thrown. * @param nTries the maximum number of tries. */ public void setMaxTries(int nTries) { nMaxTries = nTries; } }