Examples of CloudFoundryServer


Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

    @Override
    protected void performDeployment(CloudFoundryApplicationModule appModule, IProgressMonitor monitor)
        throws CoreException {
      final Server server = (Server) getServer();
      final CloudFoundryServer cloudServer = getCloudFoundryServer();
      final IModule module = modules[0];

      try {

        // Update the local cloud module representing the application
        // first.
        appModule.setErrorStatus(null);

        server.setModuleState(modules, IServer.STATE_STARTING);

        final String deploymentName = appModule.getDeploymentInfo().getDeploymentName();

        // This request does three things:
        // 1. Checks if the application external or mapped to a local
        // project. If mapped to a local project
        // it creates an archive of the application's content
        // 2. If an archive file was created, it pushes the archive
        // file.
        // 3. While pushing the archive file, a check is made to see if
        // the application exists remotely. If not, the application is
        // created in the
        // CF server.

        if (!modules[0].isExternal()) {

          printlnToConsole(appModule, Messages.CONSOLE_GENERATING_ARCHIVE);

          final ApplicationArchive applicationArchive = generateApplicationArchiveFile(
              appModule.getDeploymentInfo(), appModule, modules, server, incrementalPublish, monitor);
          File warFile = null;
          if (applicationArchive == null) {
            // Create a full war archive
            warFile = CloudUtil.createWarFile(modules, server, monitor);
            if (warFile == null || !warFile.exists()) {
              throw new CoreException(new Status(IStatus.ERROR, CloudFoundryPlugin.PLUGIN_ID,
                  "Unable to create war file for application: " + deploymentName)); //$NON-NLS-1$
            }

            CloudFoundryPlugin.trace("War file " + warFile.getName() + " created"); //$NON-NLS-1$ //$NON-NLS-2$
          }
          // Tell webtools the module has been published
          setModulePublishState(modules, IServer.PUBLISH_STATE_NONE);

          // update server publish status
          IModule[] serverModules = server.getModules();
          boolean allSynched = true;
          for (IModule serverModule : serverModules) {
            int modulePublishState = server.getModulePublishState(new IModule[] { serverModule });
            if (modulePublishState == IServer.PUBLISH_STATE_INCREMENTAL
                || modulePublishState == IServer.PUBLISH_STATE_FULL) {
              allSynched = false;
            }
          }

          if (allSynched) {
            server.setServerPublishState(IServer.PUBLISH_STATE_NONE);
          }

          final File warFileFin = warFile;
          final CloudFoundryApplicationModule appModuleFin = appModule;
          // Now push the application resources to the server

          new BehaviourRequest<Void>("Pushing the application " + deploymentName) { //$NON-NLS-1$
            @Override
            protected Void doRun(final CloudFoundryOperations client, SubMonitor progress)
                throws CoreException {

              pushApplication(client, appModuleFin, warFileFin, applicationArchive, progress);

              CloudFoundryPlugin.trace("Application " + deploymentName //$NON-NLS-1$
                  + " pushed to Cloud Foundry server."); //$NON-NLS-1$

              cloudServer.tagAsDeployed(module);

              return null;
            }

          }.run(monitor);
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

          // in further steps
        }
      }
      else {
        try {
          CloudFoundryServer cloudServer = getCloudFoundryServer();

          // prompt user for missing details
          return CloudFoundryPlugin.getCallback().prepareForDeployment(cloudServer, appModule, monitor);
        }
        catch (OperationCanceledException oce) {
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

      Server server = (Server) getServer();
      boolean succeeded = false;
      try {
        server.setModuleState(modules, IServer.STATE_STOPPING);

        CloudFoundryServer cloudServer = getCloudFoundryServer();
        final CloudFoundryApplicationModule cloudModule = cloudServer.getExistingCloudModule(modules[0]);

        if (cloudModule == null) {
          throw CloudErrorUtil.toCoreException("Unable to stop application as no cloud module found for: " //$NON-NLS-1$
              + modules[0].getName());
        }
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

    super(label);
  }

  @Override
  public T runAndWait(CloudFoundryOperations client, SubMonitor monitor) throws CoreException {
    CloudFoundryServer cloudServer = getCloudServer();
    if (cloudServer.getUsername() == null || cloudServer.getUsername().length() == 0
        || cloudServer.getPassword() == null || cloudServer.getPassword().length() == 0) {
      CloudFoundryPlugin.getCallback().getCredentials(cloudServer);
    }

    Server server = (Server) cloudServer.getServer();

    // Any Server request will require the server to be connected, so update
    // the server state
    if (server.getServerState() == IServer.STATE_STOPPED || server.getServerState() == IServer.STATE_STOPPING) {
      server.setServerState(IServer.STATE_STARTING);
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

  private boolean canUpdateUrl(CloudServerURL url, CloudServerURL newUrl) {
    IServer[] servers = ServerCore.getServers();
    Set<CloudFoundryServer> matchedServers = new HashSet<CloudFoundryServer>();
    for (IServer server : servers) {
      CloudFoundryServer cfServer = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, null);
      if (cfServer != null && cfServer.getUrl().equals(url.getUrl())) {
        matchedServers.add(cfServer);
      }
    }

    if (matchedServers.isEmpty()) {
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

            serverHandler.createServer(monitor, ServerHandler.NEVER_OVERWRITE, new ServerHandlerCallback() {

              @Override
              public void configureServer(IServerWorkingCopy wc) throws CoreException {
                CloudFoundryServer cloudServer = (CloudFoundryServer) wc.loadAdapter(
                    CloudFoundryServer.class, null);

                if (cloudServer != null) {
                  cloudServer.setPassword(password);
                  cloudServer.setUsername(userName);
                  cloudServer.setUrl(url);
                  cloudServer.setSpace(selectedSpace);
                  cloudServer.setSelfSignedCertificate(selfSignedCert);
                  cloudServer.saveConfiguration(monitor);
                }
              }
            });
          }
        }, this);
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

    super(IServer.class);
  }

  @Override
  protected List<IAction> getActionsFromSelection(IServer server) {
    CloudFoundryServer cloudFoundryServer = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, null);
    if (cloudFoundryServer == null || server.getServerState() != IServer.STATE_STARTED) {
      return Collections.emptyList();
    }
    List<IAction> actions = new ArrayList<IAction>();
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

      ModuleServer moduleServer = (ModuleServer) element;
      IServer s = moduleServer.getServer();
      if (s != null && CloudServerUtil.isCloudFoundryServer(s)) {
        IModule[] modules = moduleServer.getModule();
        if (modules != null && modules.length == 1) {
          CloudFoundryServer server = getCloudFoundryServer(moduleServer.getServer());
          if (server == null || !server.isConnected()) {
            return;

          }
          CloudFoundryApplicationModule module = server.getExistingCloudModule(modules[0]);

          // module may no longer exist
          if (module == null) {
            return;
          }

          if (module.getLocalModule() != null) {
            // show local information?
          }

          CloudApplication application = module.getApplication();
          // if (application != null) {
          // decoration.addSuffix(NLS.bind("  [{0}, {1}, {2}]",
          // new Object[]{application.getName(),
          // getAppStateString(application.getState()),
          // application.getUris()}));
          // } else if (module.getName() != null) {
          // decoration.addSuffix(NLS.bind("  [{0}]",
          // module.getName()));
          // }
          if (application != null) {
            decoration.addSuffix(NLS.bind(Messages.CloudFoundryDecorator_SUFFIX_DEPLOYED_AS, application.getName()));
          }
          else {
            decoration.addSuffix(Messages.CloudFoundryDecorator_SUFFIX_NOT_DEPLOYED);
          }

          if (module.getErrorMessage() != null) {
            decoration.addOverlay(CloudFoundryImages.OVERLAY_ERROR, IDecoration.BOTTOM_LEFT);
          }
        }
      }
    }
    else if (element instanceof Server) {
      Server server = (Server) element;
      if (CloudServerUtil.isCloudFoundryServer(server)) {
        CloudFoundryServer cfServer = getCloudFoundryServer(server);
        if (cfServer != null && cfServer.getUsername() != null) {
          // decoration.addSuffix(NLS.bind("  [{0}, {1}]",
          // cfServer.getUsername(), cfServer.getUrl()));
          if (cfServer.hasCloudSpace()) {
            CloudFoundrySpace clSpace = cfServer.getCloudFoundrySpace();
            if (clSpace != null) {
              decoration
                  .addSuffix(NLS.bind(" - {0} - {1}", clSpace.getOrgName(), clSpace.getSpaceName())); //$NON-NLS-1$

            }
          }
          List<CloudServerURL> cloudUrls = CloudUiUtil.getAllUrls(cfServer.getBehaviour().getServer()
              .getServerType().getId());
          String url = cfServer.getUrl();
          // decoration.addSuffix(NLS.bind("  {0}",
          // cfServer.getUsername()));
          for (CloudServerURL cloudUrl : cloudUrls) {
            if (cloudUrl.getUrl().equals(url)) {
              decoration.addSuffix(NLS.bind(" - {0}", cloudUrl.getUrl())); //$NON-NLS-1$
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

  }

  private void openApplicationPage(ModuleServer moduleServer) {
    final IModule[] modules = moduleServer.getModule();
    IServer server = moduleServer.getServer();
    CloudFoundryServer cloudServer = (CloudFoundryServer) server.loadAdapter(CloudFoundryServer.class, null);
    if (cloudServer != null && modules != null && modules.length == 1) {
      IWorkbenchWindow workbenchWindow = ServerUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow();
      IWorkbenchPage page = workbenchWindow.getActivePage();

      try {
View Full Code Here

Examples of org.cloudfoundry.ide.eclipse.server.core.internal.CloudFoundryServer

    // that any module being deleted will also have a corresponding
    // CloudApplication.
    // A case for this is if a user cancels an application deployment. The
    // IModule would have already been created
    // but there would be no corresponding CloudApplication.
    final CloudFoundryServer cloudServer = this.cloudFoundryServerBehaviour.getCloudFoundryServer();

    List<CloudApplication> updatedApplications = this.cloudFoundryServerBehaviour.getApplications(monitor);

    for (IModule module : modules) {
      final CloudFoundryApplicationModule appModule = cloudServer.getExistingCloudModule(module);

      if (appModule == null) {
        continue;
      }

      List<String> servicesToDelete = new ArrayList<String>();

      // Fetch an updated application so that it has the lastest
      // service list
      CloudApplication application = null;
      if (updatedApplications != null) {
        for (CloudApplication app : updatedApplications) {
          if (app.getName().equals(appModule.getDeployedApplicationName())) {
            application = app;
            break;
          }
        }
      }

      // ONLY delete a remote application if an application is found.
      if (application != null) {
        List<String> actualServices = application.getServices();
        if (actualServices != null) {
          // This has to be used instead of addAll(..), as
          // there is a chance the list is non-empty but
          // contains null entries
          for (String serviceName : actualServices) {
            if (serviceName != null) {
              servicesToDelete.add(serviceName);
            }
          }
        }

        this.cloudFoundryServerBehaviour.deleteApplication(application.getName(), monitor);

      }

      CloudFoundryPlugin.getCallback().stopApplicationConsole(appModule, cloudServer);

      // Delete the module locally
      cloudServer.removeApplication(appModule);

      // Be sure the cloud application mapping is removed
      // in case other components still have a reference to
      // the
      // module
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.