use of org.sonarsource.sonarlint.core.proto.Sonarlint.StorageStatus in project sonarlint-core by SonarSource.
the class GlobalStorageUpdateExecutorTest method testUpdate.
@Test
public void testUpdate() throws Exception {
globalUpdate.update(new ProgressWrapper(null));
StorageStatus updateStatus = ProtobufUtil.readFile(destDir.toPath().resolve(StoragePaths.STORAGE_STATUS_PB), StorageStatus.parser());
assertThat(updateStatus.getClientUserAgent()).isEqualTo("UT");
assertThat(updateStatus.getSonarlintCoreVersion()).isEqualTo(VersionUtils.getLibraryVersion());
assertThat(updateStatus.getUpdateTimestamp()).isNotEqualTo(0);
ServerInfos serverInfos = ProtobufUtil.readFile(destDir.toPath().resolve(StoragePaths.SERVER_INFO_PB), ServerInfos.parser());
assertThat(serverInfos.getId()).isEqualTo("20160308094653");
assertThat(serverInfos.getVersion()).isEqualTo("5.6-SNAPSHOT");
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.StorageStatus in project sonarlint-core by SonarSource.
the class GlobalStorageUpdateExecutor method update.
public List<SonarAnalyzer> update(ProgressWrapper progress) {
Path temp = tempFolder.newDir().toPath();
try {
progress.setProgressAndCheckCancel("Checking server version and status", 0.1f);
ServerInfos serverStatus = statusChecker.checkVersionAndStatus();
progress.setProgressAndCheckCancel("Fetching list of analyzers", 0.12f);
List<SonarAnalyzer> analyzers = pluginListDownloader.downloadPluginList(serverStatus.getVersion());
ProtobufUtil.writeToFile(serverStatus, temp.resolve(StoragePaths.SERVER_INFO_PB));
progress.setProgressAndCheckCancel("Fetching global properties", 0.15f);
globalSettingsDownloader.fetchGlobalSettingsTo(serverStatus.getVersion(), temp);
progress.setProgressAndCheckCancel("Fetching analyzers", 0.25f);
pluginReferenceDownloader.fetchPluginsTo(temp, analyzers);
progress.setProgressAndCheckCancel("Fetching rules", 0.4f);
rulesDownloader.fetchRulesTo(temp, progress.subProgress(0.4f, 0.6f, "Fetching rules"));
progress.setProgressAndCheckCancel("Fetching quality profiles", 0.6f);
qualityProfilesDownloader.fetchQualityProfilesTo(temp);
progress.setProgressAndCheckCancel("Fetching list of modules", 0.8f);
moduleListDownloader.fetchModulesListTo(temp, serverStatus.getVersion(), progress.subProgress(0.8f, 1.0f, "Fetching list of modules"));
progress.startNonCancelableSection();
progress.setProgressAndCheckCancel("Finalizing...", 1.0f);
StorageStatus storageStatus = StorageStatus.newBuilder().setStorageVersion(StoragePaths.STORAGE_VERSION).setClientUserAgent(wsClient.getUserAgent()).setSonarlintCoreVersion(VersionUtils.getLibraryVersion()).setUpdateTimestamp(new Date().getTime()).build();
ProtobufUtil.writeToFile(storageStatus, temp.resolve(StoragePaths.STORAGE_STATUS_PB));
Path dest = storageManager.getGlobalStorageRoot();
FileUtils.deleteRecursively(dest);
FileUtils.mkdirs(dest.getParent());
FileUtils.moveDir(temp, dest);
return analyzers;
} catch (RuntimeException e) {
try {
FileUtils.deleteRecursively(temp);
} catch (RuntimeException ignore) {
// ignore because we want to throw original exception
}
throw e;
}
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.StorageStatus in project sonarlint-core by SonarSource.
the class ModuleStorageUpdateExecutor method updateStatus.
private void updateStatus(Path temp) {
StorageStatus storageStatus = StorageStatus.newBuilder().setStorageVersion(StoragePaths.STORAGE_VERSION).setClientUserAgent(wsClient.getUserAgent()).setSonarlintCoreVersion(VersionUtils.getLibraryVersion()).setUpdateTimestamp(new Date().getTime()).build();
ProtobufUtil.writeToFile(storageStatus, temp.resolve(StoragePaths.STORAGE_STATUS_PB));
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.StorageStatus in project sonarlint-core by SonarSource.
the class ConnectedIssueExclusionsMediumTest method writeStatus.
private static void writeStatus(Path storage, String version) throws IOException {
Path module = storage.resolve("local").resolve("global");
StorageStatus storageStatus = StorageStatus.newBuilder().setStorageVersion(StoragePaths.STORAGE_VERSION).setClientUserAgent("agent").setSonarlintCoreVersion(version).setUpdateTimestamp(new Date().getTime()).build();
Files.createDirectories(module);
ProtobufUtil.writeToFile(storageStatus, module.resolve(StoragePaths.STORAGE_STATUS_PB));
}
use of org.sonarsource.sonarlint.core.proto.Sonarlint.StorageStatus in project sonarlint-core by SonarSource.
the class ConnectedIssueExclusionsMediumTest method writeModuleStatus.
private static void writeModuleStatus(Path storage, String name, String version) throws IOException {
Path module = storage.resolve("local").resolve("modules").resolve(name);
StorageStatus storageStatus = StorageStatus.newBuilder().setStorageVersion(StoragePaths.STORAGE_VERSION).setClientUserAgent("agent").setSonarlintCoreVersion(version).setUpdateTimestamp(new Date().getTime()).build();
Files.createDirectories(module);
ProtobufUtil.writeToFile(storageStatus, module.resolve(StoragePaths.STORAGE_STATUS_PB));
}
Aggregations