{
SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.RUNNING);
status.setMessage("Running redeploy to: "+targets);
status.setRunning(true);
currentStatus = status;
ProgressEvent event = new ProgressEvent(deployment, currentStatus);
notify(event);
for(DeploymentTarget target : targets)
{
if(isCancelled)
{
status = new SerializableDeploymentStatus(command, StateType.CANCELLED);
status.setMessage("Redeploy has been cancelled");
currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
break;
}
try
{
target.redeploy(deployment);
status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
status.setTarget(target);
status.setMessage("Completed redeploy for target: "+target);
status.setCompleted(true);
currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
}
catch(Exception e)
{
status = new SerializableDeploymentStatus(command, StateType.FAILED);
status.setTarget(target);
status.setFailure(e);
status.setFailed(true);
currentStatus = status;
ProgressEvent error = new ProgressEvent(deployment, currentStatus);
notify(error);
break;
}
}
}