/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Portions Copyright 2013-2015 ForgeRock AS.
*/
/**
* This class provides the CLI used for upgrading the OpenDJ product.
*/
{
/** Upgrade's logger. */
/** The command-line argument parser. */
/** The argument which should be used to specify the config class. */
/** The argument which should be used to specify the config file. */
/** The argument which should be used to specify non interactive mode. */
/** The argument which should be used to request usage information. */
/**
* Flag indicating whether or not the global arguments have
* already been initialized.
*/
private boolean globalArgumentsInitialized;
{
this.parser =
INFO_UPGRADE_DESCRIPTION_CLI.get(), false);
}
/**
* Provides the command-line arguments to the main application for processing.
*
* @param args
* The set of command-line arguments provided to this program.
*/
{
if (exitCode != 0)
{
}
}
/**
* Provides the command-line arguments to the main application for processing
* and returns the exit code as an integer.
*
* @param args
* The set of command-line arguments provided to this program.
* @param initializeServer
* Indicates whether to perform basic initialization (which should
* not be done if the tool is running in the same JVM as the server).
* @param outStream
* The output stream for standard output.
* @param errStream
* The output stream for standard error.
* @return Zero to indicate that the program completed successfully, or
* non-zero to indicate that an error occurred.
*/
{
// Run the application.
}
/** {@inheritDoc} */
public boolean isAdvancedMode()
{
return false;
}
/** {@inheritDoc} */
public boolean isInteractive()
{
}
/** {@inheritDoc} */
public boolean isMenuDrivenMode()
{
return false;
}
/** {@inheritDoc} */
public boolean isQuiet()
{
}
/** {@inheritDoc} */
public boolean isScriptFriendly()
{
return false;
}
/** {@inheritDoc} */
public boolean isVerbose()
{
}
/**
* Force the upgrade. All critical questions will be forced to 'yes'.
*
* @return {@code true} if the upgrade process is forced.
*/
private boolean isForceUpgrade()
{
}
/**
* Force to ignore the errors during the upgrade process.
* Continues rather than fails.
*
* @return {@code true} if the errors are forced to be ignored.
*/
private boolean isIgnoreErrors()
{
return ignoreErrors.isPresent();
}
/**
* Automatically accepts the license if it's present.
*
* @return {@code true} if license is accepted by default.
*/
private boolean isAcceptLicense()
{
return acceptLicense.isPresent();
}
/** Initialize arguments provided by the command line. */
{
{
.get());
// Register the global arguments.
globalArgumentsInitialized = true;
}
}
{
// Initialize the arguments
try
{
}
catch (ArgumentException e)
{
return EXIT_CODE_ERROR;
}
// Parse the command-line arguments provided to this program.
try
{
if (isInteractive() && isQuiet())
{
final LocalizableMessage message =
"interactive mode");
return EXIT_CODE_ERROR;
}
if (isInteractive() && isForceUpgrade())
{
final LocalizableMessage message =
"interactive mode");
return EXIT_CODE_ERROR;
}
{
final LocalizableMessage message =
return EXIT_CODE_ERROR;
}
}
catch (ArgumentException ae)
{
parser.displayMessageAndUsageReference(getErrStream(), ERR_ERROR_PARSING_ARGS.get(ae.getMessage()));
return EXIT_CODE_ERROR;
}
// to do anything else.
if (parser.usageOrVersionDisplayed())
{
return EXIT_CODE_SUCCESS;
}
// Main process
try
{
// Creates the log file.
// Upgrade's context.
// Starts upgrade.
}
catch (ClientException ex)
{
return ex.getReturnCode();
}
{
.getMessage()), 0);
return EXIT_CODE_ERROR;
}
return EXIT_CODE_SUCCESS;
}
/** {@inheritDoc} */
{
{
// Displays progress eg. for a task.
if (c instanceof ProgressNotificationCallback)
{
final ProgressNotificationCallback pnc =
}
else if (c instanceof FormattedNotificationCallback)
{
// Displays formatted notifications.
final FormattedNotificationCallback fnc =
switch (fnc.getMessageSubType())
{
case TITLE_CALLBACK:
break;
case SUBTITLE_CALLBACK:
4);
break;
case NOTICE_CALLBACK:
break;
case ERROR_CALLBACK:
break;
case WARNING:
break;
default:
+ fnc.getMessage()));
throw new IOException("Unsupported message type: ");
}
}
else if (c instanceof TextOutputCallback)
{
// Usual output text.
} else {
+ toc.getMessage()));
throw new IOException("Unsupported message type: ");
}
}
else if (c instanceof ConfirmationCallback)
{
// Default answers.
// Generating prompt and possible answers list.
{
.append("/")
}
else if (cc.getOptionType()
{
}
// Displays the output and
// while it hasn't a valid response, question is repeated.
if (isInteractive())
{
while (true)
{
try
{
value =
}
catch (ClientException e)
{
break;
}
{
break;
}
{
break;
}
{
break;
}
}
}
else // Non interactive mode :
{
// Force mode.
if (isForceUpgrade())
{
}
else // Default non interactive mode.
{
}
// Displays the prompt
}
}
else
{
throw new UnsupportedCallbackException(c, "Unrecognized Callback");
}
}
}
{
{
}
{
}
{
}
return null;
}
}