notifyListeners(getFormattedDoneWithLineBreak());
} catch (Exception e) {
LOG.log(Level.INFO,
"Error starting server in order to apply custom" +
"schema and/or configuration", e);
throw new ApplicationException(
ReturnCode.APPLICATION_ERROR,
INFO_ERROR_STARTING_SERVER.get(), e);
}
checkAbort();
if (migration.isSchemaCustomized()) {
try {
LOG.log(Level.INFO, "Applying schema customizations");
setCurrentProgressStep(
UpgradeProgressStep.APPLYING_SCHEMA_CUSTOMIZATIONS);
migration.migrateSchema();
notifyListeners(getFormattedDoneWithLineBreak());
LOG.log(Level.INFO, "custom schema application finished");
} catch (ApplicationException e) {
LOG.log(Level.INFO,
"Error applying schema customizations", e);
throw e;
}
}
checkAbort();
if (migration.isConfigurationCustomized()) {
try {
LOG.log(Level.INFO, "Applying config customizations");
setCurrentProgressStep(
UpgradeProgressStep.APPLYING_CONFIGURATION_CUSTOMIZATIONS);
migration.migrateConfiguration();
notifyListeners(getFormattedDoneWithLineBreak());
LOG.log(Level.INFO, "custom config application finished");
} catch (ApplicationException e) {
LOG.log(Level.INFO,
"Error applying configuration customizations", e);
throw e;
}
}
checkAbort();
if (migration.mustMigrateADS())
{
try {
LOG.log(Level.INFO, "Applying registration changes");
if (isVerbose())
{
setCurrentProgressStep(
UpgradeProgressStep.APPLYING_ADS_CUSTOMIZATIONS);
}
migration.migrateADS(
getStagedInstallation().getADSBackendFile());
if (isVerbose())
{
notifyListeners(getFormattedDone());
}
LOG.log(Level.INFO, "custom registration application finished");
} catch (ApplicationException e) {
LOG.log(Level.INFO,
"Error applying registration customizations", e);
throw e;
}
}
checkAbort();
if (migration.mustMigrateToolProperties())
{
try {
LOG.log(Level.INFO, "Applying tools properties");
migration.migrateToolPropertiesFile(
getStagedInstallation().getToolsPropertiesFile());
LOG.log(Level.INFO, "tools properties application finished");
} catch (ApplicationException e) {
LOG.log(Level.INFO,
"Error applying tools properties changes", e);
throw e;
}
}
if (migration.mustRunDSJavaProperties())
{
try {
LOG.log(Level.INFO, "Upgrading script with java properties");
// Launch the script
String propertiesFile = new File(
getInstallation().getConfigurationDirectory(),
Installation.DEFAULT_JAVA_PROPERTIES_FILE).getAbsolutePath();
String setJavaFile =
getInstallation().getSetJavaHomeFile().getAbsolutePath();
String[] args =
{
"--propertiesFile", propertiesFile,
"--destinationFile", setJavaFile,
"--quiet"
};
int returnValue = JavaPropertiesTool.mainCLI(args);
if ((returnValue !=
JavaPropertiesTool.ErrorReturnCode.SUCCESSFUL.getReturnCode()) &&
returnValue !=
JavaPropertiesTool.ErrorReturnCode.SUCCESSFUL_NOP.getReturnCode())
{
throw new ApplicationException(ReturnCode.APPLICATION_ERROR,
ERR_ERROR_CREATING_JAVA_HOME_SCRIPTS.get(returnValue), null);
}
LOG.log(Level.INFO, "scripts successfully upgraded");
} catch (ApplicationException e) {
LOG.log(Level.INFO,
"Error upgrading scripts", e);
throw e;
}
}
checkAbort();
try {
LOG.log(Level.INFO, "stopping server");
// This class imports classes from the server
if (isVerbose())
{
notifyListeners(INFO_PROGRESS_UPGRADE_INTERNAL_STOP.get());
}
new InProcessServerController(
getInstallation()).stopServer();
InProcessServerController.disableConnectionHandlers(false);
if (isVerbose())
{
notifyListeners(getFormattedDone());
}
LOG.log(Level.INFO, "server stopped");
} catch (Throwable t) {
LOG.log(Level.INFO, "Error stopping server", t);
throw new ApplicationException(ReturnCode.BUG,
INFO_ERROR_STOPPING_SERVER.get(), t);
}
}
checkAbort();
// This allows you to test whether or not he upgrader can successfully
// abort an upgrade once changes have been made to the installation
// path's filesystem.
if ("true".equals(
System.getProperty(SYS_PROP_CREATE_ERROR))) {
LOG.log(Level.WARNING, "creating artificial error");
throw new ApplicationException(
null, INFO_ERROR_ARTIFICIAL.get(), null);
}
List<Message> errors;
try {
LOG.log(Level.INFO, "verifying upgrade");
setCurrentProgressStep(UpgradeProgressStep.VERIFYING);
Installation installation = getInstallation();
ServerHealthChecker healthChecker =
new ServerHealthChecker(installation);
healthChecker.checkServer();
errors = healthChecker.getProblemMessages();
} catch (Exception e) {
LOG.log(Level.INFO, "error performing server health check", e);
throw e;
}
// For testing
if ("true".equals(
System.getProperty(SYS_PROP_CREATE_VERIFY_ERROR))) {
LOG.log(Level.WARNING, "creating artificial verification error");
if (errors == null || errors.size() == 0) {
errors = new ArrayList<Message>();
errors.add(Message.raw("Artificial verification error for testing"));
}
}
if (errors != null && errors.size() > 0) {
notifyListeners(getFormattedErrorWithLineBreak());
Message formattedDetails =
Utils.listToMessage(errors,
Constants.LINE_SEPARATOR, /*bullet=*/"\u2022 ", "");
ApplicationException ae = new ApplicationException(
ReturnCode.APPLICATION_ERROR,
INFO_ERROR_UPGRADED_SERVER_STARTS_WITH_ERRORS.get(
Constants.LINE_SEPARATOR + formattedDetails), null);
UserInteraction ui = userInteraction();
if (ui != null) {
// We are about to present the problems with the upgrade to the
// user and ask if they would like to continue. Regardless of
// whether or not they continue at this point, since they will
// have seen the errors we consider the errors as warnings.
runWarning = ae;
// Ask the user if they would like to continue.
Message cancel = INFO_UPGRADE_VERIFICATION_FAILURE_CANCEL.get();
if (cancel.equals(ui.confirm(
INFO_UPGRADE_VERIFICATION_FAILURE_TITLE.get(),
INFO_UPGRADE_VERIFICATION_FAILURE_PROMPT.get(),
formattedDetails,
INFO_UPGRADE_VERIFICATION_FAILURE_TITLE.get(),
UserInteraction.MessageType.ERROR,
new Message[]{INFO_CONTINUE_BUTTON_LABEL.get(), cancel},
cancel,
INFO_UPGRADE_VERIFICATION_FAILURE_VIEW_DETAILS.get()))) {
// User indicated cancel
cancel();
checkAbort();
} else {
// User wants to continue; nothing to do
}
} else {
// We can't ask the user if they want to continue so we
// just bail on the upgrade by throwing an exception which
// will cause upgrader to exit unsuccessfully
throw ae;
}
} else {
notifyListeners(getFormattedDoneWithLineBreak());
}
LOG.log(Level.INFO, "upgrade verification complete");
// Leave the server in the state requested by the user via the
// checkbox on the review panel. The upgrade has already been
// verified at this point to in the unlikely event of an error,
// we call this a warning instead of an error.
try {
ServerController control = new ServerController(getInstallation());
boolean serverRunning = getInstallation().getStatus().isServerRunning();
boolean userRequestsStart = getUserData().getStartServer();
if (userRequestsStart && !serverRunning) {
try {
LOG.log(Level.INFO, "starting server");
setCurrentProgressStep(UpgradeProgressStep.STARTING_SERVER);
if (isVerbose())
{
notifyListeners(getTaskSeparator());
}
else
{
notifyListeners(getFormattedWithPoints(
INFO_PROGRESS_STARTING_NON_VERBOSE.get()));
}
int port = getInstallation().getCurrentConfiguration().getPort();
if (port != -1 && !Utils.canUseAsPort(port)) {
throw new ApplicationException(
ReturnCode.APPLICATION_ERROR,
INFO_ERROR_PORT_IN_USE.get(Integer.toString(port)),
null);
}
control.startServer(!isVerbose());
if (!isVerbose())
{
notifyListeners(getFormattedDoneWithLineBreak());
}
else
{
notifyListeners(getLineBreak());
}
} catch (ApplicationException e) {
if (isVerbose())
{
notifyListeners(getLineBreak());
}
notifyListeners(getFormattedErrorWithLineBreak());
LOG.log(Level.INFO, "error starting server");
this.runWarning = e;
}
} else if (!userRequestsStart && serverRunning) {
try {
LOG.log(Level.INFO, "stopping server");
if (isVerbose())
{
notifyListeners(getTaskSeparator());
}
else
{
notifyListeners(getFormattedWithPoints(
INFO_PROGRESS_STOPPING_NON_VERBOSE.get()));
}
setCurrentProgressStep(UpgradeProgressStep.STOPPING_SERVER);
control.stopServer(!isVerbose());
if (!isVerbose())
{
notifyListeners(getFormattedDoneWithLineBreak());
}
else
{
notifyListeners(getLineBreak());
}
} catch (ApplicationException e) {
if (isVerbose())
{
notifyListeners(getLineBreak());
}
notifyListeners(getFormattedErrorWithLineBreak());
LOG.log(Level.INFO, "error stopping server");
this.runWarning = e;
}
}
} catch (IOException ioe) {
LOG.log(Level.INFO, "error determining if server running");
this.runWarning = new ApplicationException(
ReturnCode.TOOL_ERROR,
INFO_ERROR_SERVER_STATUS.get(), ioe);
}
} catch (ApplicationException ae) {
// We don't consider a user cancelation exception
// to be an error.
if (ae.getType() != ReturnCode.CANCELED) {
this.runError = ae;
} else {
this.abort = true;
}
} catch (Throwable t) {
this.runError =
new ApplicationException(ReturnCode.BUG,
INFO_BUG_MSG.get(), t);
} finally {
try {
HistoricalRecord.Status status;
String note = null;