use of org.sonarsource.sonarlint.core.container.connected.exceptions.NotFoundException in project sonarlint-core by SonarSource.
the class ModuleQualityProfilesDownloader method fetchModuleQualityProfiles.
public List<QualityProfile> fetchModuleQualityProfiles(String moduleKey, String serverVersion) {
SearchWsResponse qpResponse;
String param;
if (Version.create(serverVersion).compareToIgnoreQualifier(Version.create("6.5")) >= 0) {
param = "project";
} else {
param = "projectKey";
}
String baseUrl = "/api/qualityprofiles/search.protobuf?" + param + "=" + StringUtils.urlEncode(moduleKey);
String organizationKey = wsClient.getOrganizationKey();
if (organizationKey != null) {
baseUrl += "&organization=" + StringUtils.urlEncode(organizationKey);
}
try (InputStream contentStream = wsClient.get(baseUrl).contentStream()) {
qpResponse = QualityProfiles.SearchWsResponse.parseFrom(contentStream);
} catch (NotFoundException e) {
throw new ProjectNotFoundException(moduleKey, organizationKey);
} catch (IOException e) {
throw new IllegalStateException("Failed to load module quality profiles", e);
}
return qpResponse.getProfilesList();
}
Aggregations