APISonar


org.sonarqube.ws.MediaTypes.XML

> org > sonarqube > ws > MediaTypes > XML
org APIs sonarqube APIs ws APIs MediaTypes APIs XML APIs

Example 1
public void handle(Request request, Response response) throws Exception {
    // Allowed to users without admin permission: http://jira.sonarsource.com/browse/SONAR-2039
    Stream stream = response.stream();
    stream.setMediaType(MediaTypes.XML);
    try (OutputStreamWriter writer = new OutputStreamWriter(stream.output(), UTF_8);
      DbSession dbSession = dbClient.openSession(false)) {

      QualityProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
      response.setHeader("Content-Disposition", String.format("attachment; filename=%s.xml", profile.getKee()));
      backuper.backup(dbSession, profile, writer);
    }
  }
Example 2
private void writeResponse(DbSession dbSession, QualityProfileDto profile, @Nullable String exporterKey, Response response) throws IOException {
    Stream stream = response.stream();
    try (
      OutputStream output = response.stream().output();
      Writer writer = new OutputStreamWriter(output, UTF_8)) {
      if (exporterKey == null) {
        stream.setMediaType(MediaTypes.XML);
        backuper.backup(dbSession, profile, writer);
      } else {
        stream.setMediaType(exporters.mimeType(exporterKey));
        exporters.export(profile, exporterKey, writer);
      }
    }
  }
Example 3
public void restoreProfile(RestoreWsRequest request) {
    PostRequest httpRequest = new PostRequest(path(ACTION_RESTORE));
    httpRequest.setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null));
    httpRequest.setPart(PARAM_BACKUP, new PostRequest.Part(MediaTypes.XML, request.getBackup()));
    call(httpRequest);
  }