Example usage for org.springframework.ide.eclipse.boot.dash.cloudfoundry DevtoolsUtil getSecret

List of usage examples for org.springframework.ide.eclipse.boot.dash.cloudfoundry DevtoolsUtil getSecret

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.cloudfoundry DevtoolsUtil getSecret.

Prototype

public static String getSecret(IProject project) throws CoreException 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudAppDashElement.java

protected void doRestartWithRemoteClient(RunState runningOrDebugging, UserInteractions ui,
        CancelationToken cancelationToken, IProgressMonitor monitor) throws Exception {

    CloudFoundryBootDashModel model = getCloudModel();
    Map<String, String> envVars = model.getRunTarget().getClient().getApplicationEnvironment(getName());

    if (getProject() == null) {
        ExceptionUtil.coreException(new Status(IStatus.ERROR, BootDashActivator.PLUGIN_ID,
                "Local project not associated to CF app '" + getName() + "'"));
    }//  w w w  .j av  a 2 s .  c  om

    new SetHealthCheckOperation(this, HealthChecks.HC_NONE, ui, /* confirmChange */true, cancelationToken)
            .run(monitor);

    if (!DevtoolsUtil.isEnvVarSetupForRemoteClient(envVars, DevtoolsUtil.getSecret(getProject()))) {
        // Let the push and debug operation resolve default properties
        CloudApplicationDeploymentProperties deploymentProperties = null;

        pushAndDebug(deploymentProperties, runningOrDebugging, ui, cancelationToken, monitor);
        /*
         * Restart and push op resets console anyway, no need to reset it
         * again
         */
    } else if (getRunState() == RunState.INACTIVE) {
        restartOnly(ui, cancelationToken, monitor);
    }

    new RemoteDevClientStartOperation(model, getName(), runningOrDebugging, cancelationToken).run(monitor);
}

From source file:org.springframework.ide.eclipse.boot.dash.cloudfoundry.CloudAppDashElement.java

public void push(CloudApplicationDeploymentProperties deploymentProperties, RunState runningOrDebugging,
        DebugSupport debugSupport, CancelationToken cancelationToken, UserInteractions ui,
        IProgressMonitor monitor) throws Exception {

    boolean isDebugging = runningOrDebugging == RunState.DEBUGGING;
    whileStarting(ui, cancelationToken, monitor, () -> {
        // Refresh app data and check that the application (still) exists in
        // Cloud Foundry
        // This also ensures that the 'diff change dialog' will pick up on
        // the latest changes.
        // TODO: should this refresh be moved closer to the where we
        // actually compute the diff?
        CloudAppDashElement updatedApp = this.refresh();
        if (updatedApp == null) {
            ExceptionUtil.coreException(new Status(IStatus.ERROR, BootDashActivator.PLUGIN_ID,
                    "No Cloud Application found for '" + getName() + "'"));
        }/*from  ww  w  .  ja v  a  2 s . c  o  m*/
        IProject project = getProject();
        if (project == null) {
            ExceptionUtil.coreException(new Status(IStatus.ERROR, BootDashActivator.PLUGIN_ID,
                    "Local project not associated to CF app '" + getName() + "'"));
        }

        checkTerminationRequested(cancelationToken, monitor);

        CloudApplicationDeploymentProperties properties = deploymentProperties == null
                ? getCloudModel().resolveDeploymentProperties(updatedApp, ui, monitor)
                : deploymentProperties;

        // Update JAVA_OPTS env variable with Remote DevTools Client secret
        DevtoolsUtil.setupEnvVarsForRemoteClient(properties.getEnvironmentVariables(),
                DevtoolsUtil.getSecret(project));
        if (debugSupport != null) {
            if (isDebugging) {
                debugSupport.setupEnvVars(properties.getEnvironmentVariables());
            } else {
                debugSupport.clearEnvVars(properties.getEnvironmentVariables());
            }
        }

        checkTerminationRequested(cancelationToken, monitor);

        CFPushArguments pushArgs = properties.toPushArguments(getCloudModel().getCloudDomains(monitor));

        getClient().push(pushArgs, CancelationTokens.merge(cancelationToken, monitor));

        log("Application pushed to Cloud Foundry: " + getName());
    });
}