final String domainDir = getDomainsRoot();
CLILogger.getInstance().printDebugMessage("domainDir = " + domainDir);
final String installDir = System.getProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY);
CLILogger.getInstance().printDebugMessage("installDir = " + installDir);
CLILogger.getInstance().printDebugMessage("domainName = " + domainName);
final InplaceDomainUpgradeHandler ipuh =
new InplaceDomainUpgradeHandler(config);
if (ipuh.needsUpgrade()) {
String domainDirOption = getOption(DOMAINDIR);
String domainsDirProperty = System.getProperty(SystemPropertyConstants.DOMAINS_ROOT_PROPERTY);
if (domainDirOption != null && domainDirOption.indexOf(domainsDirProperty) == -1){
throw new CommandException(getLocalizedString("UpgradeUnsupported", new Object[]{domainsDirProperty}));
}
if (ipuh.isCommsApplicationServer()) {
try {
String profile = getOption(PROFILE);
if (peformUpgradeForCommsAppServer(installDir, domainDir, domainName, profile, ipuh.getFromVersion(), ipuh.getToVersion())) {
CLILogger.getInstance().printDetailMessage((getLocalizedString("UpgradeSuccessful")));
ipuh.touchUpgradedToFile();
} else {
throw new CommandException(getLocalizedString("UpgradeFailedForCommsAppServer"));
}
} catch (Exception ex) {
throw new CommandException(getLocalizedString("UpgradeFailedForCommsAppServer"), ex);
}
} else {
try {
final String sPasswordFile = createPasswordFileText();
final String[] upgradeCmd;
/*Need to prefix the upgrade command with CMD /c in case of Windows*/
if(OS.isWindows())
upgradeCmd = new String[] {"CMD",
"/c",
installDir + File.separator +
"bin" + File.separator +
"asupgrade", "-c", "-s",
domainDir+File.separator+domainName,
"-t", installDir +File.separator+ "domains",
"-noprompt" };
else
upgradeCmd = new String[] {installDir + File.separator +
"bin" + File.separator +
"asupgrade", "-c", "-s",
domainDir+File.separator+domainName,
"-t", installDir +File.separator+ "domains",
"-noprompt" };
ProcessExecutor pe = new ProcessExecutor(upgradeCmd, UPGRADE_TIMEOUT);
/*
* ProcessExecutor's constructor replaces all the '/'s with '\' in case the OS is Windows.
* We don't want that for CMD /c. Hence need to replace it again
*/
if(OS.isWindows())
upgradeCmd[1] ="/c";
CLILogger.getInstance().printDetailMessage((getLocalizedString("StartingUpgrade")));
pe.execute(); // timeout in 600sec or 10min
Process process = pe.getSubProcess();
int exitValue = process.waitFor();
if (exitValue != 0) {
throw new CommandException(getLocalizedString("UpgradeFailed"));
}else {
CLILogger.getInstance().printDetailMessage((getLocalizedString("UpgradeSuccessful")));
ipuh.touchUpgradedToFile();
}
}
catch (Exception e) {
//e.printStackTrace();
throw new CommandException(getLocalizedString("UpgradeFailed"), e);
}
}
} else {
try {
ipuh.touchUpgradedToFile();
} catch(final IOException ioe) {
throw new CommandException(ioe);
}
}
}