Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
Genesys Backend
Genesys Backend
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 45
    • Issues 45
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Operations
    • Operations
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
  • Genesys PGR
  • Genesys BackendGenesys Backend
  • Issues
  • #329

Closed
Open
Opened Sep 14, 2018 by Matija Obreza@mobrezaOwner
  • Report abuse
  • New issue
Report abuse New issue

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
2.4
Milestone
2.4 (Past due)
Assign milestone
Time tracking
None
Due date
None
Reference: genesys-pgr/genesys-server#329