Search in sources :

Example 1 with PARAM_LANGUAGE

use of org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE in project sonarqube by SonarSource.

the class ExportAction method define.

@Override
public void define(WebService.NewController controller) {
    NewAction action = controller.createAction("export").setSince("5.2").setDescription("Export a quality profile.").setResponseExample(getClass().getResource("export-example.xml")).setHandler(this);
    action.createParam(PARAM_QUALITY_PROFILE).setDescription("Quality profile name to export. If left empty, the default profile for the language is exported.").setExampleValue("My Sonar way");
    action.createParam(PARAM_LANGUAGE).setDescription("Quality profile language").setRequired(true).setExampleValue(LanguageParamUtils.getExampleValue(languages)).setPossibleValues(LanguageParamUtils.getOrderedLanguageKeys(languages));
    Set<String> exporterKeys = Arrays.stream(languages.all()).map(language -> exporters.exportersForLanguage(language.getKey())).flatMap(Collection::stream).map(ProfileExporter::getKey).collect(MoreCollectors.toSet());
    if (!exporterKeys.isEmpty()) {
        action.createParam(PARAM_EXPORTER_KEY).setDescription("Output format. If left empty, the same format as api/qualityprofiles/backup is used. " + "Possible values are described by api/qualityprofiles/exporters.").setPossibleValues(exporterKeys);
    }
}
Also used : Arrays(java.util.Arrays) ByteArrayOutputStream(java.io.ByteArrayOutputStream) QProfileExporters(org.sonar.server.qualityprofile.QProfileExporters) DbSession(org.sonar.db.DbSession) Request(org.sonar.api.server.ws.Request) Languages(org.sonar.api.resources.Languages) WebService(org.sonar.api.server.ws.WebService) PARAM_LANGUAGE(org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE) Response(org.sonar.api.server.ws.Response) OutputStreamWriter(java.io.OutputStreamWriter) ProfileExporter(org.sonar.api.profiles.ProfileExporter) MediaTypes(org.sonarqube.ws.MediaTypes) MoreCollectors(org.sonar.core.util.stream.MoreCollectors) Nullable(javax.annotation.Nullable) PARAM_QUALITY_PROFILE(org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE) OutputStream(java.io.OutputStream) UTF_8(java.nio.charset.StandardCharsets.UTF_8) Collection(java.util.Collection) Stream(org.sonar.api.server.ws.Response.Stream) Set(java.util.Set) IOException(java.io.IOException) NewAction(org.sonar.api.server.ws.WebService.NewAction) NotFoundException.checkFound(org.sonar.server.exceptions.NotFoundException.checkFound) IOUtils(org.apache.commons.io.IOUtils) DbClient(org.sonar.db.DbClient) Writer(java.io.Writer) QProfileDto(org.sonar.db.qualityprofile.QProfileDto) LanguageParamUtils(org.sonar.server.language.LanguageParamUtils) QProfileBackuper(org.sonar.server.qualityprofile.QProfileBackuper) Collection(java.util.Collection) NewAction(org.sonar.api.server.ws.WebService.NewAction)

Aggregations

ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 Set (java.util.Set)1 Nullable (javax.annotation.Nullable)1 IOUtils (org.apache.commons.io.IOUtils)1 ProfileExporter (org.sonar.api.profiles.ProfileExporter)1 Languages (org.sonar.api.resources.Languages)1 Request (org.sonar.api.server.ws.Request)1 Response (org.sonar.api.server.ws.Response)1 Stream (org.sonar.api.server.ws.Response.Stream)1 WebService (org.sonar.api.server.ws.WebService)1 NewAction (org.sonar.api.server.ws.WebService.NewAction)1 MoreCollectors (org.sonar.core.util.stream.MoreCollectors)1 DbClient (org.sonar.db.DbClient)1