{
SerializableDeploymentStatus status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
status.setMessage("Running distribute 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("Distribute has been cancelled");
currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
break;
}
try
{
// TODO, percent complete info in upload and overall distribute
status = new SerializableDeploymentStatus(command, StateType.UPLOADING);
status.setTarget(target);
status.setRunning(true);
status.setMessage("Begining distribute to target: "+target);
currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
// TODO, cancellation of in progress distribution
target.distribute(deployment);
status = new SerializableDeploymentStatus(command, StateType.DEPLOYING);
status.setTarget(target);
status.setMessage("Completed distribute to target: "+target);
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;
}
}
if(currentStatus.isFailed() == false)
{
status = new SerializableDeploymentStatus(command, StateType.COMPLETED);
status.setMessage("Completed distribute to all targets");
currentStatus = status;
event = new ProgressEvent(deployment, currentStatus);
notify(event);
}
status.setCompleted(true);
}