| | |
| | | |
| | | package org.opends.server.tools.upgrade; |
| | | |
| | | import static org.opends.messages.ToolMessages. |
| | | ERR_UPGRADE_DISPLAY_NOTIFICATION_ERROR; |
| | | import static org.opends.messages.ToolMessages. |
| | | ERR_UPGRADE_DISPLAY_CONFIRM_ERROR; |
| | | import static org.opends.messages.ToolMessages.INFO_PROMPT_NO_COMPLETE_ANSWER; |
| | | import static org.opends.messages.ToolMessages.INFO_PROMPT_YES_COMPLETE_ANSWER; |
| | | import static org.opends.messages.ToolMessages.INFO_TASKINFO_CMD_CANCEL_CHAR; |
| | | |
| | | |
| | | import static org.opends.messages.ToolMessages.*; |
| | | import static org.opends.server.tools.upgrade.Upgrade.EXIT_CODE_ERROR; |
| | | |
| | | import javax.security.auth.callback.Callback; |
| | |
| | | import org.opends.server.tools.ClientException; |
| | | import org.opends.server.util.BuildVersion; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Context information which is passed to upgrade tasks. This might include |
| | | * server configuration, etc. |
| | |
| | | /** |
| | | * The call-back handler for interacting with the upgrade application. |
| | | */ |
| | | private CallbackHandler handler; |
| | | private final CallbackHandler handler; |
| | | |
| | | /** |
| | | * If ignore errors is enabled. |
| | |
| | | private boolean isForceUpgradeMode; |
| | | |
| | | |
| | | |
| | | /** |
| | | * Constructor for the upgrade context. |
| | | * |
| | |
| | | * The call-back handler for interacting with the upgrade |
| | | * application. |
| | | */ |
| | | UpgradeContext(final BuildVersion fromVersion, final BuildVersion toVersion, |
| | | CallbackHandler handler) |
| | | public UpgradeContext(final BuildVersion fromVersion, |
| | | final BuildVersion toVersion, CallbackHandler handler) |
| | | { |
| | | this.fromVersion = fromVersion; |
| | | this.toVersion = toVersion; |
| | | this.handler = handler; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the old version. |
| | | * |
| | | * @return The old version. |
| | | */ |
| | | public BuildVersion getFromVersion() |
| | | BuildVersion getFromVersion() |
| | | { |
| | | return fromVersion; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the new version. |
| | | * |
| | | * @return The new version. |
| | | */ |
| | | public BuildVersion getToVersion() |
| | | BuildVersion getToVersion() |
| | | { |
| | | return toVersion; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the ignore error mode. |
| | | * |
| | | * @return {code true} if ignore error mode is activated. |
| | | */ |
| | | public boolean isIgnoreErrorsMode() |
| | | boolean isIgnoreErrorsMode() |
| | | { |
| | | return isIgnoreErrorsMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the ignore errors mode. |
| | | * |
| | |
| | | this.isIgnoreErrorsMode = isIgnoreErrorsMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the accept license mode. |
| | | * |
| | | * @return {@code true} if accept license mode is activated. |
| | | */ |
| | | public boolean isAcceptLicenseMode() |
| | | boolean isAcceptLicenseMode() |
| | | { |
| | | return isAcceptLicenseMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the accept license mode. |
| | | * |
| | |
| | | this.isAcceptLicenseMode = isAcceptLicenseMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the callback handler. |
| | | * |
| | | * @return The actual callback handler. |
| | | */ |
| | | public CallbackHandler getHandler() |
| | | CallbackHandler getHandler() |
| | | { |
| | | return handler; |
| | | } |
| | | |
| | | /** |
| | | * Sets the upgrade callback handler. |
| | | * |
| | | * @param handler |
| | | * The call-back handler for interacting with the upgrade |
| | | * application. |
| | | */ |
| | | public void setHandler(CallbackHandler handler) |
| | | { |
| | | this.handler = handler; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns the status of the interactive mode. |
| | | * |
| | | * @return {@code true} if interactive mode is activated. |
| | | */ |
| | | public boolean isInteractiveMode() |
| | | boolean isInteractiveMode() |
| | | { |
| | | return isInteractiveMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the interactive mode. |
| | | * |
| | |
| | | this.isInteractiveMode = isInteractiveMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the status of the force upgrade mode. |
| | | * |
| | | * @return {@code true} if the force upgrade mode is activated. |
| | | */ |
| | | public boolean isForceUpgradeMode() |
| | | boolean isForceUpgradeMode() |
| | | { |
| | | return isForceUpgradeMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sets the force upgrade mode. |
| | | * |
| | |
| | | this.isForceUpgradeMode = isForceUpgradeMode; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends notification message to the application via the call-back handler. |
| | | * |
| | |
| | | * @throws ClientException |
| | | * If an error occurred while reporting the message. |
| | | */ |
| | | public void notify(final Message message) throws ClientException |
| | | void notify(final Message message) throws ClientException |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Sends notification message to the application via the call-back handler |
| | | * containing specific sub type message. |
| | |
| | | * @throws ClientException |
| | | * If an error occurred while reporting the message. |
| | | */ |
| | | public void notify(final Message message, final int msgType) |
| | | throws ClientException |
| | | void notify(final Message message, final int msgType) throws ClientException |
| | | { |
| | | try |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Displays a progress callback. |
| | | * |
| | |
| | | * @throws ClientException |
| | | * If an error occurred while reporting the message. |
| | | */ |
| | | public void notifyProgress(final ProgressNotificationCallback callback) |
| | | void notifyProgress(final ProgressNotificationCallback callback) |
| | | throws ClientException |
| | | { |
| | | try |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Asks a confirmation to the user. Answer is yes or no. |
| | | * |
| | |
| | | * If an error occurred while reporting the message. |
| | | * @return an integer corresponding to the user's answer. |
| | | */ |
| | | public int confirmYN(final Message message, final int defaultOption) |
| | | int confirmYN(final Message message, final int defaultOption) |
| | | throws ClientException |
| | | { |
| | | final ConfirmationCallback confirmYNCallback = |
| | | new ConfirmationCallback(message.toString(), |
| | | ConfirmationCallback.WARNING, ConfirmationCallback.YES_NO_OPTION, |
| | | defaultOption); |
| | | final ConfirmationCallback confirmYNCallback = new ConfirmationCallback( |
| | | message.toString(), ConfirmationCallback.WARNING, |
| | | ConfirmationCallback.YES_NO_OPTION, defaultOption); |
| | | try |
| | | { |
| | | handler.handle(new Callback[] { confirmYNCallback }); |
| | |
| | | return confirmYNCallback.getSelectedIndex(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * Returns the default option string. |
| | | * |