use of org.sonarsource.sonarlint.core.client.api.exceptions.StorageException in project sonarlint-core by SonarSource.
the class ConnectedSonarLintEngineImpl method updateProject.
@Override
public void updateProject(EndpointParams endpoint, HttpClient client, String projectKey, boolean fetchTaintVulnerabilities, @Nullable String branchName, @Nullable ClientProgressMonitor monitor) {
requireNonNull(endpoint);
requireNonNull(projectKey);
setLogging(null);
var globalStorageStatus = globalStatusReader.read();
if (globalStorageStatus == null || globalStorageStatus.isStale()) {
throw new StorageException("Missing or outdated storage for connection '" + globalConfig.getConnectionId() + "'");
}
projectStorageUpdateExecutor.update(new ServerApiHelper(endpoint, client), projectKey, fetchTaintVulnerabilities, branchName, new ProgressMonitor(monitor));
}
use of org.sonarsource.sonarlint.core.client.api.exceptions.StorageException in project sonarlint-core by SonarSource.
the class StandalonePluginIndexTest method testCacheStorageError.
@Test
public void testCacheStorageError() {
when(cache.get(eq("filename"), eq("b45cffe084dd3d20d928bee85e7b0f21"), any(PluginCache.Copier.class))).thenThrow(new StorageException("msg", true));
exception.expect(StorageException.class);
exception.expectMessage("msg");
index.references();
}
use of org.sonarsource.sonarlint.core.client.api.exceptions.StorageException in project sonarlint-core by SonarSource.
the class StandalonePluginIndex method getFromCacheOrCopy.
private PluginReference getFromCacheOrCopy(final URL pluginUrl) {
try (InputStream is = pluginUrl.openStream()) {
String hash = org.sonarsource.sonarlint.core.util.StringUtils.md5(is);
String filename = StringUtils.substringAfterLast(pluginUrl.getFile(), "/");
fileCache.get(filename, hash, new FileCopier(pluginUrl));
return new PluginReference(hash, filename);
} catch (StorageException e) {
throw e;
} catch (Exception e) {
throw new IllegalStateException("Fail to copy plugin from URL: " + pluginUrl, e);
}
}
use of org.sonarsource.sonarlint.core.client.api.exceptions.StorageException in project sonarlint-core by SonarSource.
the class PluginsStorage method store.
public void store(ServerPlugin plugin, InputStream pluginBinary) {
try {
FileUtils.copyInputStreamToFile(pluginBinary, rootPath.resolve(plugin.getFilename()).toFile());
var reference = adapt(plugin);
rwLock.write(() -> {
var pluginsFilePath = getPluginsFilePath();
var references = Files.exists(pluginsFilePath) ? ProtobufUtil.readFile(pluginsFilePath, Sonarlint.PluginReferences.parser()) : Sonarlint.PluginReferences.newBuilder().build();
var currentReferences = Sonarlint.PluginReferences.newBuilder(references);
currentReferences.putPluginsByKey(plugin.getKey(), reference);
ProtobufUtil.writeToFile(currentReferences.build(), pluginsFilePath);
});
} catch (IOException e) {
// XXX should we stop the whole sync ? just continue and log ?
throw new StorageException("Cannot save plugin " + plugin.getFilename() + " in " + rootPath, e);
}
}
Aggregations