public String validate(String serverId, boolean editExisting) { if (StringUtils.isBlank(serverId)) { return "Connection name must be specified"; } if (!editExisting && serversById.containsKey(serverId)) { return "Connection name already exists"; } try { // Validate server ID format ConnectedGlobalConfiguration.builder() .setServerId(serverId) .build(); } catch (Exception e) { return e.getMessage(); } return null; }
private static SonarLint createConnected(SonarQubeServer server, String projectKey, boolean verbose) { LOGGER.info(String.format("Connected mode (%s)", projectKey)); ConnectedGlobalConfiguration config = ConnectedGlobalConfiguration.builder() .setLogOutput(new DefaultLogOutput(LOGGER, verbose)) .setServerId(server.id()) .build(); ConnectedSonarLintEngineImpl engine = new ConnectedSonarLintEngineImpl(config); return new ConnectedSonarLint(engine, server, projectKey); }
@Override public void start(ConnectedConfiguration requestConfig, StreamObserver<Void> response) { if (engine != null) { engine.stop(false); engine = null; } try { Builder builder = ConnectedGlobalConfiguration.builder(); if (requestConfig.getHomePath() != null) { builder.setSonarLintUserHome(Paths.get(requestConfig.getHomePath())); } builder.setLogOutput(logOutput) .setServerId(requestConfig.getStorageId()); engine = new ConnectedSonarLintEngineImpl(builder.build()); response.onNext(Void.newBuilder().build()); response.onCompleted(); } catch (Exception e) { LOGGER.error("Error registering", e); response.onError(e); } }
ConnectedSonarLintEngine createEngine(String serverId) { ConnectedGlobalConfiguration config = ConnectedGlobalConfiguration.builder() .setLogOutput(globalLogOutput) .setSonarLintUserHome(getSonarLintHome()) .addExcludedCodeAnalyzers(UNSUPPORTED_ANALYZERS) .setWorkDir(getWorkDir()) .setServerId(serverId) .build(); // it will also start it return new ConnectedSonarLintEngineImpl(config); }
Server(String id) { this.id = id; ConnectedGlobalConfiguration globalConfig = ConnectedGlobalConfiguration.builder() .setServerId(getId()) .setWorkDir(StoragePathManager.getServerWorkDir(getId())) .setStorageRoot(StoragePathManager.getServerStorageRoot()) .setLogOutput(new SonarLintAnalyzerLogOutput()) .build(); this.client = new ConnectedSonarLintEngineImpl(globalConfig); this.client.addStateListener(this); this.updateStatus = client.getGlobalStorageStatus(); if (client.getState().equals(State.UPDATED)) { reloadProjects(); } }