use of org.sonar.api.profiles.ProfileExporter 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_PROFILE_NAME).setDescription("The name of the quality profile to export. If left empty, will export the default profile for the language.").setExampleValue("My Sonar way");
action.createParam(PARAM_LANGUAGE).setDescription("The language for the quality profile.").setExampleValue(LanguageParamUtils.getExampleValue(languages)).setPossibleValues(LanguageParamUtils.getLanguageKeys(languages)).setRequired(true);
Set<String> exporterKeys = Arrays.stream(languages.all()).map(language -> exporters.exportersForLanguage(language.getKey())).flatMap(Collection::stream).map(ProfileExporter::getKey).collect(Collectors.toSet());
if (!exporterKeys.isEmpty()) {
action.createParam(PARAM_FORMAT).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).setDeprecatedKey("format", "6.3");
}
}
use of org.sonar.api.profiles.ProfileExporter in project sonarqube by SonarSource.
the class QProfileExporters method export.
public void export(QualityProfileDto profile, String exporterKey, Writer writer) {
ProfileExporter exporter = findExporter(exporterKey);
exporter.exportProfile(wrap(profile), writer);
}
use of org.sonar.api.profiles.ProfileExporter in project sonarqube by SonarSource.
the class ExportersAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
JsonWriter json = response.newJsonWriter().beginObject().name("exporters").beginArray();
for (ProfileExporter exporter : exporters) {
json.beginObject().prop("key", exporter.getKey()).prop("name", exporter.getName());
json.name("languages").beginArray();
for (String language : exporter.getSupportedLanguages()) {
json.value(language);
}
json.endArray().endObject();
}
json.endArray().endObject().close();
}
Aggregations