Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Genesys Backend Genesys Backend
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 28
    • Issues 28
    • List
    • Boards
    • Service Desk
    • Milestones
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Genesys PGRGenesys PGR
  • Genesys BackendGenesys Backend
  • Issues
  • #329
Closed
Open
Issue created Sep 14, 2018 by Matija Obreza@mobrezaOwner

Accession API v1: Download KML

Add API endpoint /api/v1/acn/downloadKml to AccessionController v1:

@RequestMapping(value = "/downloadKml", produces = "application/vnd.google-earth.kml+xml", method = RequestMethod.POST)
@ResponseBody
public void kml(@RequestParam(value="f") String filterCode, HttpServletResponse response) throws IOException {

    // get AccessionFilter from filterCode
    AccessionFilter filter = ...

    final int countFiltered = accessionService.countAccessions(filter);
    LOG.info("Attempting to download KML for {} accessions", countFiltered);
    if (countFiltered > DOWNLOAD_LIMIT) {
        throw new RuntimeException("Refusing to export more than " + DOWNLOAD_LIMIT + " entries");
    }

    response.setContentType("application/vnd.google-earth.kml+xml");
    response.addHeader("Content-Disposition", String.format("attachment; filename=\"genesys-kml-" + filterCode + ".kml\""));

    // Write KML to the stream.
    final OutputStream outputStream = response.getOutputStream();

    try {
        mappingService.filteredKml(filter, outputStream);
        response.flushBuffer();
    } catch (EOFException e) {
        LOG.warn("Download was aborted", e);
    }
}
Edited Sep 14, 2018 by Matija Obreza
Assignee
Assign to
Time tracking