@RequestMapping(value = MetaDataController.RESOURCE_PATH) public String export(@RequestParam Map<String, String> parameters, Model model) { WebOptions options = new WebOptions(parameters); MetaData metaData = exportService.getMetaData(options); model.addAttribute("model", metaData); model.addAttribute("viewClass", options.getViewClass("export")); return "export"; }
@RequestMapping(value = MetaDataController.RESOURCE_PATH + ".xml", produces = "*/*") public void exportXml(@RequestParam Map<String, String> parameters, HttpServletResponse response) throws IOException { WebOptions options = new WebOptions(parameters); MetaData metaData = exportService.getMetaData(options); contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_XML, CacheStrategy.NO_CACHE, "metadata.xml", true); Class<?> viewClass = JacksonUtils.getViewClass(options.getViewClass("export")); JacksonUtils.toXmlWithView(response.getOutputStream(), metaData, viewClass); }
@RequestMapping( value = {MetaDataController.RESOURCE_PATH + ".json.gz"}, produces = "*/*") public void exportGZippedJSON( @RequestParam Map<String, String> parameters, HttpServletResponse response) throws IOException { WebOptions options = new WebOptions(parameters); MetaData metaData = exportService.getMetaData(options); contextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_GZIP, CacheStrategy.NO_CACHE, "metadata.json.gz", true); response.addHeader(ContextUtils.HEADER_CONTENT_TRANSFER_ENCODING, "binary"); GZIPOutputStream gzip = new GZIPOutputStream(response.getOutputStream()); Class<?> viewClass = JacksonUtils.getViewClass(options.getViewClass("export")); JacksonUtils.toJsonWithView(gzip, metaData, viewClass); }