private void deploy(String deploymentName, URL url) throws DeploymentException {
   Exception failure = null;
   try {
     DeploymentProgress distribute = deploymentManager.distribute(deploymentName, url, true);
     distribute.run();
     DeploymentStatus uploadStatus = distribute.getDeploymentStatus();
     if (uploadStatus.isFailed()) {
       failure = uploadStatus.getFailure();
       undeploy(deploymentName);
     } else {
       DeploymentProgress progress = deploymentManager.start(deploymentName);
       progress.run();
       DeploymentStatus status = progress.getDeploymentStatus();
       if (status.isFailed()) {
         failure = status.getFailure();
         undeploy(deploymentName);
       }
     }
   } catch (Exception e) {
     throw new DeploymentException("Could not deploy " + deploymentName, e);
   }
   if (failure != null) {
     throw new DeploymentException("Failed to deploy " + deploymentName, failure);
   }
 }
Exemple #2
0
  @Override
  public void deleteResource() throws Exception {

    DeploymentManager deploymentManager = getConnection().getDeploymentManager();

    log.debug("Stopping deployment [" + this.deploymentUrl + "]..."); // $NON-NLS-1$ //$NON-NLS-2$
    DeploymentProgress progress = deploymentManager.stop(this.deploymentUrl);
    DeploymentStatus stopStatus = DeploymentUtils.run(progress);
    if (stopStatus.isFailed()) {
      log.error(
          "Failed to stop deployment '"
              + this.deploymentUrl // $NON-NLS-1$
              + "'.",
          stopStatus.getFailure()); // $NON-NLS-1$
      throw new Exception(
          "Failed to stop deployment '" //$NON-NLS-1$
              + this.deploymentName
              + "' - cause: " //$NON-NLS-1$
              + stopStatus.getFailure());
    }
    log.debug("Removing deployment [" + this.deploymentUrl + "]..."); // $NON-NLS-1$ //$NON-NLS-2$
    progress = deploymentManager.remove(this.deploymentUrl);
    DeploymentStatus removeStatus = DeploymentUtils.run(progress);
    if (removeStatus.isFailed()) {
      log.error(
          "Failed to remove deployment '"
              + this.deploymentUrl // $NON-NLS-1$
              + "'.",
          removeStatus.getFailure()); // $NON-NLS-1$
      throw new Exception(
          "Failed to remove deployment '" //$NON-NLS-1$
              + this.deploymentName
              + "' - cause: " //$NON-NLS-1$
              + removeStatus.getFailure());
    }
  }