/**
  * Undeploy a previously {@link #deploy(DeploymentInfo) deployed} application
  *
  * @param deploymentInfo The deployment information to remove
  * @param deleteServices if any services should also be removed during un-deployment. This flag
  *     will be ignored for targets such as Tomcat that do not support services.
  * @return the result of the deployment. The message "SUCCESS" is used to indicate success,
  */
 public String undeploy(DeploymentInfo deploymentInfo, boolean deleteServices) {
   if (deploymentInfo.getDeploymentType() != DeploymentType.FILE) {
     try {
       this.deploymentTargetManager
           .getDeploymentTarget(deploymentInfo.getDeploymentType())
           .undeploy(deploymentInfo, deleteServices);
     } catch (DeploymentStatusException e) {
       // FIXME Before this exception existed the string return was ignored, we continue to do so
       // but this
       // should be reviewed.
     }
   }
   return SUCCESS;
 }
 public String getDeploymentURL(DeploymentInfo deploymentInfo) {
   String ret =
       this.deploymentTargetManager
           .getDeploymentTarget(deploymentInfo.getDeploymentType())
           .getUrl(deploymentInfo);
   return ret;
 }
 @Override
 public String deploy(Project project, DeploymentInfo deploymentInfo, java.io.File tempWebAppRoot)
     throws DeploymentStatusException {
   File warFile =
       project
           .getRootFolder()
           .getFile(DeploymentManager.DIST_DIR_DEFAULT + project.getProjectName() + ".war");
   TomcatManager tomcat = initTomcat(deploymentInfo);
   tomcat.deploy(deploymentInfo.getApplicationName(), warFile);
   return "SUCCESS";
 }
 private TomcatManager initTomcat(DeploymentInfo deploymentInfo) {
   if (SystemUtils.isEncrypted(deploymentInfo.getPassword())) {
     deploymentInfo.setPassword(SystemUtils.decrypt(deploymentInfo.getPassword()));
   }
   return new TomcatManager(
       deploymentInfo.getHost(),
       deploymentInfo.getPort(),
       deploymentInfo.getUsername(),
       deploymentInfo.getPassword());
 }
  /**
   * Deploy the current project to a specific target (identified by the {@link DeploymentInfo}
   * parameter.
   *
   * @param deploymentInfo information about the deployment.
   * @return the result of the deployment. The message "SUCCESS" or any message starting "OK" are
   *     considered successful. Other results are considered failures and will be displayed to the
   *     user.
   * @throws IOException
   */
  public String deploy(DeploymentInfo deploymentInfo) throws IOException {
    File tempWebAppRoot = null;
    try {
      if (deploymentInfo.getDeploymentType() != DeploymentType.FILE
          && deploymentInfo.getDeploymentType() != DeploymentType.CLOUD_FOUNDRY) {
        this.deploymentTargetManager
            .getDeploymentTarget(deploymentInfo.getDeploymentType())
            .validateDeployment(deploymentInfo);
      }

      if (!WMAppContext.getInstance().isCloudFoundry()
          || deploymentInfo.getDeploymentType() == DeploymentType.FILE) {
        tempWebAppRoot = IOUtils.createTempDirectory();
        com.wavemaker.tools.io.File f =
            this.serviceDeploymentManager.generateWebapp(deploymentInfo, tempWebAppRoot);
        if (!f.exists()) {
          throw new AssertionError("Application archive file doesn't exist at " + f.toString());
        }
        if (deploymentInfo.getDeploymentType() == DeploymentType.FILE) {
          return SUCCESS;
        }
      }

      String ret =
          this.deploymentTargetManager
              .getDeploymentTarget(deploymentInfo.getDeploymentType())
              .deploy(
                  this.serviceDeploymentManager.getProjectManager().getCurrentProject(),
                  deploymentInfo,
                  tempWebAppRoot);

      return ret;
    } catch (DeploymentStatusException e) {
      return e.getStatusMessage();
    } finally {
      if (tempWebAppRoot != null) {
        try {
          IOUtils.deleteRecursive(tempWebAppRoot);
        } catch (IOException ex) {
          try {
            Thread.sleep(3000);
            IOUtils.deleteRecursive(tempWebAppRoot);
          } catch (InterruptedException ex1) {
            throw new WMRuntimeException(ex1);
          }
        }
      }
    }
  }
 @Override
 public void undeploy(DeploymentInfo deploymentInfo, boolean deleteServices)
     throws DeploymentStatusException {
   TomcatManager tomcat = initTomcat(deploymentInfo);
   tomcat.undeploy(deploymentInfo.getApplicationName());
 }