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) {
addErrorMessage(actionRequest, getLocalizedString(actionRequest, "errorMsg04"), null);
log.error(getLocalizedString(actionRequest, "errorMsg04"));
return;
}
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 = getLocalizedString(actionRequest, !isRedeploy ? "infoMsg01" : "infoMsg02");
addInfoMessage(actionRequest, abbrStatusMessage);
// 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 = getLocalizedString(actionRequest, "infoMsg03");
addInfoMessage(actionRequest, abbrStatusMessage);
} else {
abbrStatusMessage = getLocalizedString(actionRequest, "errorMsg02");
fullStatusMessage = progress.getDeploymentStatus().getMessage();
addErrorMessage(actionRequest, abbrStatusMessage, fullStatusMessage);
log.error(abbrStatusMessage + "\n" + fullStatusMessage);
}
}
} 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 = getLocalizedString(actionRequest, "errorMsg01");
addErrorMessage(actionRequest, abbrStatusMessage, fullStatusMessage);
log.error(abbrStatusMessage + "\n" + fullStatusMessage);