private void deploy(String deploymentName, URL url) throws DeploymentException
{
Exception failure = null;
try
{
DeploymentProgress distribute = deploymentManager.distribute(deploymentName, DeploymentPhase.APPLICATION, url, true);
distribute.run();
DeploymentStatus uploadStatus = distribute.getDeploymentStatus();
if(uploadStatus.isFailed())
{
failure = uploadStatus.getFailure();
undeploy(deploymentName);
}
else
{
DeploymentProgress progress = deploymentManager.start(DeploymentPhase.APPLICATION, deploymentName);
progress.run();
DeploymentStatus status = progress.getDeploymentStatus();
if (status.isFailed())
{
failure = status.getFailure();
undeploy(deploymentName);
}