APISonar


org.sonar.server.plugins.MimeTypes.XML

> org > sonar > server > plugins > MimeTypes > XML
org APIs sonar APIs server APIs plugins APIs MimeTypes APIs XML APIs

Example 1
public void handle(Request request, Response response) throws Exception {
    Stream stream = response.stream();
    stream.setMediaType(MimeTypes.XML);
    OutputStreamWriter writer = new OutputStreamWriter(stream.output(), StandardCharsets.UTF_8);
    DbSession session = dbClient.openSession(false);
    try {
      String profileKey = QProfileIdentificationParamUtils.getProfileKeyFromParameters(request, profileFactory, session);
      backuper.backup(profileKey, writer);
      response.setHeader("Content-Disposition", String.format("attachment; filename=%s.xml", profileKey));
    } finally {
      session.close();
      IOUtils.closeQuietly(writer);
    }
  }