use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class GeneratePluginIndexTest method newInstalledPlugin.
private ServerPlugin newInstalledPlugin(String key, boolean supportSonarLint) throws IOException {
FileAndMd5 jar = new FileAndMd5(temp.newFile());
PluginInfo pluginInfo = new PluginInfo(key).setJarFile(jar.getFile()).setSonarLintSupported(supportSonarLint);
return new ServerPlugin(pluginInfo, BUNDLED, null, jar, null, null);
}
use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class DetectPluginChangeTest method addPluginToFs.
private void addPluginToFs(String key, String hash, PluginType type) {
PluginInfo pluginInfo = new PluginInfo(key);
Plugin plugin = mock(Plugin.class);
FileAndMd5 fileAndMd5 = mock(FileAndMd5.class);
when(fileAndMd5.getMd5()).thenReturn(hash);
ServerPlugin serverPlugin = new ServerPlugin(pluginInfo, type, plugin, fileAndMd5, null);
pluginRepository.addPlugin(serverPlugin);
}
use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class ServerPluginManagerTest method newPluginFilesAndMd5.
private static PluginFilesAndMd5 newPluginFilesAndMd5(String name) {
FileAndMd5 jar = mock(FileAndMd5.class);
when(jar.getFile()).thenReturn(new File(name));
when(jar.getMd5()).thenReturn(name + "-md5");
FileAndMd5 compressed = mock(FileAndMd5.class);
when(compressed.getFile()).thenReturn(new File(name + "-compressed"));
when(compressed.getMd5()).thenReturn(name + "-compressed-md5");
return new PluginFilesAndMd5(jar, compressed);
}
use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class DownloadAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
String pluginKey = request.mandatoryParam(PLUGIN_PARAM);
Optional<ServerPlugin> file = pluginRepository.findPlugin(pluginKey);
if (!file.isPresent()) {
throw new NotFoundException("Plugin " + pluginKey + " not found");
}
FileAndMd5 downloadedFile;
FileAndMd5 compressedJar = file.get().getCompressed();
if (compressedJar != null && PACK200.equals(request.param(ACCEPT_COMPRESSIONS_PARAM))) {
response.stream().setMediaType("application/octet-stream");
response.setHeader("Sonar-Compression", PACK200);
response.setHeader("Sonar-UncompressedMD5", file.get().getJar().getMd5());
downloadedFile = compressedJar;
} else {
response.stream().setMediaType("application/java-archive");
downloadedFile = file.get().getJar();
}
response.setHeader("Sonar-MD5", downloadedFile.getMd5());
try (InputStream input = FileUtils.openInputStream(downloadedFile.getFile())) {
IOUtils.copyLarge(input, response.stream().output());
}
}
use of org.sonar.server.plugins.PluginFilesAndMd5.FileAndMd5 in project sonarqube by SonarSource.
the class InstalledActionTest method plugin.
private ServerPlugin plugin(String key, String name) throws IOException {
File file = temp.newFile();
PluginInfo info = new PluginInfo(key).setName(name).setVersion(Version.create("1.0"));
info.setJarFile(file);
return new ServerPlugin(info, PluginType.BUNDLED, null, new FileAndMd5(file), null, null);
}
Aggregations