final OperationalString deploy,
final DeployOptions deployOptions,
final BufferedReader br,
final PrintStream out) {
try {
DeployAdmin deployAdmin = (DeployAdmin)CLI.getInstance().getServiceFinder().getPreparedAdmin(item.service);
Boolean wait = (Boolean) CLI.getInstance().settings.get(CLI.DEPLOY_BLOCK);
if (deployAdmin.hasDeployed(deploy.getName())) {
if (deployOptions.update()) {
try {
out.print("The [" + deploy.getName() + "] is currently deployed, updating ...\n");
OperationalStringManager mgr = deployAdmin.getOperationalStringManager(deploy.getName());
mgr.update(deploy);
} catch (Exception e) {
e.printStackTrace();
return ("Exception "+e.getClass()+":"+e.getLocalizedMessage()+", check log for details");
}
} else {
if (deployOptions.noPrompt()) {
return ("The [" + deploy.getName() + "] is currently deployed, interactive mode disabled, " +
"returning");
}
out.print("The ["+deploy.getName()+"] is currently deployed, update the deployment? [y/n] ");
BufferedReader reader = br;
try {
if (reader == null)
reader = new BufferedReader(new InputStreamReader(System.in));
String response = reader.readLine();
if (response == null) {
return ("");
}
if (response.startsWith("y") || response.startsWith("Y")) {
OperationalStringManager mgr = deployAdmin.getOperationalStringManager(deploy.getName());
mgr.update(deploy);
return ("Updated");
} else {
return ("Skipped");
}
} catch (Exception e) {
e.printStackTrace();
return ("Exception "+e.getClass()+":"+e.getLocalizedMessage()+", check log for details");
}
}
} else {
if (deployOptions.getDeployTimeout() > 0 && wait) {
ServiceProvisionNotification spn = CLI.getInstance().provisionNotifier;
deployAdmin.deploy(deploy, spn.getServiceProvisionListener());
long t0 = System.currentTimeMillis();
out.println("Deploying [" +
ServiceProvisionNotification.getDeploymentNames(deploy) + "], " +
"total services ["+ServiceProvisionNotification.sumUpServices(deploy) + "] ...");
spn.notify(
ServiceProvisionNotification.sumUpServices(deploy),
deployOptions.getDeployTimeout());
long t1 = System.currentTimeMillis();
return ((deployOptions.verbose ?
"Deployment notification time " +(t1 - t0) + " millis, Command completed"
: ""));
} else {
deployAdmin.deploy(deploy, null);
}
}
return ((deployOptions.verbose ? "Command completed" : ""));
} catch (Exception e) {
e.printStackTrace();