Target[] all = mgr.getTargets();
if (null == all) {
throw new IllegalStateException("No target to distribute to");
}
ProgressObject progress;
if(isRedeploy) {
TargetModuleID[] targets = identifyTargets(moduleFile, planFile, mgr.getAvailableModules(null, all));
if(targets.length == 0) {
throw new PortletException("Unable to identify modules to replace. Please include a Geronimo deployment plan or use the command-line deployment tool.");
}
progress = mgr.redeploy(targets, moduleFile, planFile);
} else {
progress = mgr.distribute(new Target[] {all[0]}, moduleFile, planFile);
}
while(progress.getDeploymentStatus().isRunning()) {
Thread.sleep(100);
}
String abbrStatusMessage;
String fullStatusMessage = null;
if(progress.getDeploymentStatus().isCompleted()) {
abbrStatusMessage = "The application was successfully "+(isRedeploy ? "re" : "")+"deployed.<br/>";
// start installed app/s
if (!isRedeploy && startApp != null && !startApp.equals("")) {
progress = mgr.start(progress.getResultTargetModuleIDs());
while(progress.getDeploymentStatus().isRunning()) {
Thread.sleep(100);
}
if (progress.getDeploymentStatus().isCompleted()) {
abbrStatusMessage += "The application was successfully started";
} else {
abbrStatusMessage += "The application was not successfully started";
fullStatusMessage = progress.getDeploymentStatus().getMessage();
}
}
} else {
fullStatusMessage = progress.getDeploymentStatus().getMessage();
// for the abbreviated status message clip off everything
// after the first line, which in most cases means the gnarly stacktrace
abbrStatusMessage = "Deployment failed:<br/>"
+ fullStatusMessage.substring(0, fullStatusMessage.indexOf('\n'));
// try to provide an upgraded version of the plan