List<DeploymentOption> deploymentOptions = new ArrayList<DeploymentOption>();
if (deployExploded) {
deploymentOptions.add(DeploymentOption.Explode);
}
DeploymentProgress progress = null;
DeploymentStatus distributeStatus;
Exception distributeFailure = null;
try {
progress = deploymentManager.distribute(archiveFileName, contentURL,
deploymentOptions.toArray(new DeploymentOption[deploymentOptions.size()]));
distributeStatus = run(progress);
if (distributeStatus.isFailed()) {
distributeFailure = (distributeStatus.getFailure() != null) ? distributeStatus.getFailure()
: new Exception("Distribute failed for unknown reason.");
}
} catch (Exception e) {
distributeFailure = e;
}
if (distributeFailure != null) {
throw new Exception("Failed to distribute '" + contentURL + "' to '" + archiveFileName + "' - cause: "
+ ThrowableUtil.getAllMessages(distributeFailure));
}
// Now that we've successfully distributed the deployment, try to start it.
String[] deploymentNames = progress.getDeploymentID().getRepositoryNames();
DeploymentStatus startStatus;
Exception startFailure = null;
try {
progress = deploymentManager.start(deploymentNames);
startStatus = run(progress);
if (startStatus.isFailed()) {
startFailure = (startStatus.getFailure() != null) ? startStatus.getFailure() : new Exception(
"Start failed for unknown reason.");
}
} catch (Exception e) {
startFailure = e;
}