Search in sources :

Example 1 with CFParamsProviderMessages

use of org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFParamsProviderMessages in project sts4 by spring-projects.

the class ManifestYamlLanguageServer method applyCfLoginParameterSettings.

@SuppressWarnings("unchecked")
private void applyCfLoginParameterSettings(CfTargetsInfo info) {
    List<Target> cfTargets = info.getCfTargets();
    if (cfTargets != null) {
        CfTargetsInfoProvder cfClientParamsProvider = new CfTargetsInfoProvder(info);
        cfClientConfig.setClientParamsProvider(new ClientParamsProvider() {

            @Override
            public Collection<CFClientParams> getParams() throws NoTargetsException, ExecutionException {
                List<ClientParamsProvider> providers = ImmutableList.of(defaultClientParamsProvider, cfClientParamsProvider);
                List<CFClientParams> params = new ArrayList<>();
                for (ClientParamsProvider provider : providers) {
                    try {
                        params.addAll(provider.getParams());
                    } catch (Exception e) {
                    // ignore
                    }
                }
                if (params.isEmpty()) {
                    throw new NoTargetsException(getMessages().noTargetsFound());
                }
                return params;
            }

            @Override
            public CFParamsProviderMessages getMessages() {
                return cfTargets.isEmpty() ? defaultClientParamsProvider.getMessages() : cfClientParamsProvider.getMessages();
            }
        });
    }
}
Also used : Target(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfTargetsInfo.Target) NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) CFParamsProviderMessages(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFParamsProviderMessages) CfTargetsInfoProvder(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfTargetsInfoProvder) Collection(java.util.Collection) List(java.util.List) ArrayList(java.util.ArrayList) ImmutableList(com.google.common.collect.ImmutableList) ClientParamsProvider(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider) ExecutionException(java.util.concurrent.ExecutionException) NoTargetsException(org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException) JsonSyntaxException(com.google.gson.JsonSyntaxException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)1 JsonSyntaxException (com.google.gson.JsonSyntaxException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 CFParamsProviderMessages (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFParamsProviderMessages)1 Target (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfTargetsInfo.Target)1 CfTargetsInfoProvder (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CfTargetsInfoProvder)1 ClientParamsProvider (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.ClientParamsProvider)1 NoTargetsException (org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.NoTargetsException)1