Package org.cloudfoundry.ide.eclipse.server.core.internal.client

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.client.DeploymentInfoWorkingCopy


   * manifest file.
   */
  public DeploymentInfoWorkingCopy load(IProgressMonitor monitor) throws CoreException {
    SubMonitor subMonitor = SubMonitor.convert(monitor);
    subMonitor.beginTask("Parsing and loading application manifest file", 6); //$NON-NLS-1$
    DeploymentInfoWorkingCopy workingCopy;
    try {
      workingCopy = appModule.resolveDeploymentInfoWorkingCopy(subMonitor);

      Map<?, ?> application = getApplication(null);

      subMonitor.worked(1);
      if (application == null) {
        return null;
      }

      // NOTE: When reading from manifest, the manifest may be INCOMPLETE,
      // therefore do not automatically
      // set all properties in the deployment info. Check if the value of
      // the
      // property is actually set before set value
      // in the info
      String appName = getStringValue(application, NAME_PROP);

      subMonitor.worked(1);
      if (appName != null) {
        workingCopy.setDeploymentName(appName);
      }

      readMemory(application, workingCopy);
      subMonitor.worked(1);

      readApplicationURL(application, workingCopy, appName, monitor);
      subMonitor.worked(1);

      String buildpackurl = getStringValue(application, BUILDPACK_PROP);
      if (buildpackurl != null) {
        Staging staging = new Staging(null, buildpackurl);
        workingCopy.setStaging(staging);
      }

      readEnvars(workingCopy, application);
      subMonitor.worked(1);

      readServices(workingCopy, application);
      subMonitor.worked(1);

      String archiveURL = getStringValue(application, PATH_PROP);
      if (archiveURL != null) {
        workingCopy.setArchive(archiveURL);
      }

    }
    finally {
      subMonitor.done();
View Full Code Here


    // descriptor.
    if (!applicationModule.isDeployed()) {
      runnable = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) {
          try {
            DeploymentInfoWorkingCopy wc = applicationModule.resolveDeploymentInfoWorkingCopy(monitor);
            wc.setUris(page.getURLs());
            wc.save();
          }
          catch (CoreException e) {
            result[0] = e.getStatus();
          }
        }
View Full Code Here

    // Can only republish modules that have an accessible project
    if (project != null) {

      // Get the descriptor from the existing application module
      DeploymentInfoWorkingCopy workingCopy = appModule.resolveDeploymentInfoWorkingCopy(monitor);
      workingCopy.setUris(uris);
      workingCopy.save();
      IServer server = cloudServer.getServer();

      final IModule[] modules = ServerUtil.getModules(project);

      if (modules != null && modules.length == 1) {
View Full Code Here

      // null);

      // Update the mapping of bound services in the application
      List<CloudService> updatedServices = new ArrayList<CloudService>();

      DeploymentInfoWorkingCopy deploymentInfo = null;
      List<String> serviceNames = null;
      try {
        // FIXNS: Not ideal to pass a default monitor, but this also
        // cannot be
        // run asynchronously as a Job, as refreshing the viewer
        // asynchronously may result in the job running after the viewer
        // is disposed (e.g. the editor is closed between scheduling the
        // job and the job actually running)
        deploymentInfo = appModule.resolveDeploymentInfoWorkingCopy(ProgressManager.getInstance()
            .getDefaultMonitor());

        serviceNames = deploymentInfo.asServiceBindingList();
      }
      catch (CoreException e) {
        logError(NLS.bind(Messages.ApplicationDetailsPart_ERROR_INCORRECT_SERVICE,
            appModule.getDeployedApplicationName()));
      }

      if (serviceNames == null) {
        serviceNames = Collections.emptyList();
      }

      List<CloudService> allServices = editorPage.getServices();

      // Only show bound services that actually exist
      if (allServices != null && !serviceNames.isEmpty()) {
        for (CloudService service : allServices) {
          if (serviceNames.contains(service.getName())) {
            updatedServices.add(service);
          }
        }

        // Update the bound services mapping in the application
        if (!updatedServices.isEmpty() && deploymentInfo != null) {
          deploymentInfo.setServices(updatedServices);
          deploymentInfo.save();
        }
      }
      servicesViewer.setInput(updatedServices.toArray(new CloudService[updatedServices.size()]));

      servicesDropListener.setModule(appModule);
View Full Code Here

          if (appModule != null) {
            UIJob uiJob = new UIJob(Messages.ApplicationDetailsPart_JOB_EDIT_ENV_VAR) {

              public IStatus runInUIThread(IProgressMonitor monitor) {
                try {
                  DeploymentInfoWorkingCopy infoWorkingCopy = appModule
                      .resolveDeploymentInfoWorkingCopy(monitor);

                  EnvVarsWizard wizard = new EnvVarsWizard(cloudServer, appModule, infoWorkingCopy);
                  WizardDialog dialog = new WizardDialog(editorPage.getEditorSite().getShell(),
                      wizard);
View Full Code Here

  protected ICloudFoundryOperation getOperation(IProgressMonitor monitor) throws CoreException {
    List<String> existingServices = null;

    final List<String> updatedServices = new ArrayList<String>();

    DeploymentInfoWorkingCopy workingCopy = appModule.resolveDeploymentInfoWorkingCopy(monitor);

    // Check the deployment information to see if it has an existing list of
    // bound services.
    existingServices = workingCopy.asServiceBindingList();

    // Must iterate rather than passing to constructor or using
    // addAll, as some
    // of the entries in existing services may be null.
    if (existingServices != null) {
      for (String existingService : existingServices) {
        if (existingService != null) {
          updatedServices.add(existingService);
        }
      }
    }

    // This leads to duplicate services, as a user could drop an existing
    // service already
    // added to an application
    boolean serviceChanges = false;
    List<String> servicesToAdd = getServicesToAdd();
    for (String serviceToAdd : servicesToAdd) {
      if (!updatedServices.contains(serviceToAdd)) {
        updatedServices.add(serviceToAdd);
        serviceChanges = true;
      }
    }

    serviceChanges |= updatedServices.removeAll(getServicesToRemove());

    if (serviceChanges) {
      // Save the changes even if an app is not deployed
      List<CloudService> boundServices = new ArrayList<CloudService>();
      for (String serName : updatedServices) {
        boundServices.add(new LocalCloudService(serName));
      }
      workingCopy.setServices(boundServices);
      workingCopy.save();

      if (appModule.getApplication() != null) {
        // update services right away, if app is already deployed
        return new ModifyEditorOperation() {
          protected void performOperation(IProgressMonitor monitor) throws CoreException {
View Full Code Here

        .untagForAutomaticRepublish(module);

    if (repModule != null) {
      ApplicationDeploymentInfo republishDeploymentInfo = repModule.getDeploymentInfo();
      if (republishDeploymentInfo != null) {
        DeploymentInfoWorkingCopy copy = appModule.resolveDeploymentInfoWorkingCopy(monitor);
        copy.setInfo(republishDeploymentInfo);
        copy.save();
      }
    }

    // Validate the existing deployment info. Do NOT save or make changes to
    // the deployment info prior to this stage
    // (for example, saving a working copy of the deployment info with
    // default values), unless it was done so for a module that is being
    // republished, as if the deployment info is valid,
    // the wizard will not open. We want the deployment wizard to ALWAYS
    // open when deploying an application for the first time (i.e the app
    // will not have
    // a deployment info set), even if we have to populate that deployment
    // info with default values or values from the manifest file. The latter
    // should only occur AFTER the handler decides to open the wizard.
    if (!appModule.validateDeploymentInfo().isOK()) {

      // Any application that can be pushed to a CF server
      // MUST have a delegate
      // which knows how to configure that application. If no
      // delegate is found,
      // the application is not currently deployable to a CF
      // server. In that case, a delegate
      // may be required to be registered for that application
      // type.
      final ApplicationWizardDelegate providerDelegate = ApplicationWizardRegistry.getWizardProvider(appModule
          .getLocalModule());

      if (providerDelegate == null) {
        throw CloudErrorUtil.toCoreException("Failed to open application deployment wizard for: " //$NON-NLS-1$
            + appModule.getDeployedApplicationName() + " when attempting to push application to " //$NON-NLS-1$
            + server.getServer().getName()
            + ". No application provider found that corresponds to the application type: " //$NON-NLS-1$
            + appModule.getLocalModule().getModuleType().getId());
      }

      // Now parse the manifest file, if it exists, and load into a
      // deployment info working copy.
      // Do NOT save the working copy yet, as a user may cancel the
      // operation from the wizard.
      // THe working copy should only be saved by the wizard if a user
      // clicks "OK".
      DeploymentInfoWorkingCopy workingCopy = null;
      try {
        workingCopy = new ManifestParser(appModule, server).load(monitor);
      }
      catch (Throwable ce) {
        // Some failure occurred reading the manifest file. Proceed
        // anyway, to allow the user to manually enter deployment
        // values.
        CloudFoundryPlugin.logError(ce);
      }

      // A working copy of the deployment descriptor is needed in order to
      // prepopulate the application deployment wizard.
      if (workingCopy == null) {
        workingCopy = appModule.resolveDeploymentInfoWorkingCopy(monitor);
      }

      // Get the old working copy in case during the deployment wizard,
      // the app name changes
      // Apps are looked up by app name in the manifest, therefore if the
      // app name changed,
      // the old entry in the manifest
      ApplicationDeploymentInfo oldInfo = workingCopy.copy();

      final boolean[] cancelled = { false };
      final boolean[] writeToManifest = { false };
      final IStatus[] status = { Status.OK_STATUS };
      final DeploymentInfoWorkingCopy finWorkingCopy = workingCopy;
      final DeploymentConfiguration[] configuration = new DeploymentConfiguration[1];
      Display.getDefault().syncExec(new Runnable() {
        public void run() {

          CloudFoundryApplicationWizard wizard = new CloudFoundryApplicationWizard(server, appModule,
View Full Code Here

    // substitute
    // for
    // the
    // Application

    DeploymentInfoWorkingCopy copy = module.resolveDeploymentInfoWorkingCopy(monitor);
    copy.setDeploymentName(appName);
    copy.setMemory(CloudUtil.DEFAULT_MEMORY);

    if (url != null) {
      copy.setUris(Collections.singletonList(url));
    }
    else {
      // Derive the URL from the app name specified in the test call back.
      // NOTE that although the working copy SHOULD have a default URL
      // generated from a default application name
      // (generally, the project name), since the appname and project name
      // can be different,
      // and such difference would be specified manually by the user in
      // the deployment wizard,
      // be sure to generate a URL from the actual app name specified in
      // this Test call back, to be sure
      // the URL is built off the app name rather than the project name,
      // as the test case may have specified
      // a different app name than the default app name from the project
      // name.

      ApplicationUrlLookupService urlLookup = ApplicationUrlLookupService.update(server, monitor);

      CloudApplicationURL url = urlLookup.getDefaultApplicationURL(copy.getDeploymentName());
      if (url != null) {
        copy.setUris(Arrays.asList(url.getUrl()));
      }
    }

    copy.save();

    ApplicationAction mode = deployStopped ? ApplicationAction.STOP : ApplicationAction.START;

    return new DeploymentConfiguration(mode);
  }
View Full Code Here

TOP

Related Classes of org.cloudfoundry.ide.eclipse.server.core.internal.client.DeploymentInfoWorkingCopy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.