private void checkStatus(@Nullable String projectKey) { GlobalStorageStatus updateStatus = globalUpdateStatusReader.get(); if (updateStatus == null) { throw new StorageException("Missing global data. Please update server.", false); } if (projectKey != null) { ProjectStorageStatus moduleUpdateStatus = moduleUpdateStatusReader.apply(projectKey); if (moduleUpdateStatus == null) { throw new StorageException(String.format("No data stored for project '%s'. Please update the binding.", projectKey), false); } else if (moduleUpdateStatus.isStale()) { throw new StorageException(String.format("Stored data for project '%s' is stale because " + "it was created with a different version of SonarLint. Please update the binding.", projectKey), false); } } }
public StorageUpdateCheckResult checkForUpdate(String projectKey, ProgressWrapper progress) { ProjectStorageStatus moduleUpdateStatus = getComponentByType(ProjectStorageStatusReader.class).apply(projectKey); if (moduleUpdateStatus == null || moduleUpdateStatus.isStale()) { throw new StorageException(String.format("No data stored for project '%s' or invalid format. Please update the binding.", projectKey), false); } try { return getComponentByType(ProjectStorageUpdateChecker.class).checkForUpdates(projectKey, progress); } catch (Exception e) { String msg = "Error when checking for configuration update of project '" + projectKey + "'"; LOG.debug(msg, e); // null as cause so that it doesn't get wrapped throw new DownloadException(msg + ": " + e.getMessage(), null); } }
private static void checkConnectedEngineStatus(ConnectedSonarLintEngine engine, SonarLintProjectNotifications notifications, String serverId, String projectKey) throws InvalidBindingException { // Check if engine's global storage is OK ConnectedSonarLintEngine.State state = engine.getState(); if (state != ConnectedSonarLintEngine.State.UPDATED) { if (state != ConnectedSonarLintEngine.State.NEED_UPDATE) { notifications.notifyServerNotUpdated(); } else if (state != ConnectedSonarLintEngine.State.NEVER_UPDATED) { notifications.notifyServerStorageNeedsUpdate(serverId); } throw new InvalidBindingException("Server is not updated: " + serverId); } // Check if project's storage is OK. Global storage was updated and all project's binding that were open too, // but we might have now opened a new project with a different binding. ProjectStorageStatus moduleStorageStatus = engine.getProjectStorageStatus(projectKey); if (moduleStorageStatus == null) { notifications.notifyModuleInvalid(); throw new InvalidBindingException("Project is bound to a module that doesn't exist: " + projectKey); } else if (moduleStorageStatus.isStale()) { notifications.notifyModuleStale(); throw new InvalidBindingException("Stale module's storage: " + projectKey); } }