Commit 62e0194c authored by Matija Obreza's avatar Matija Obreza

Fix: Don't swallow Exceptions when producing DwC-A

parent c8d947bf
...@@ -522,7 +522,7 @@ public class AccessionController { ...@@ -522,7 +522,7 @@ public class AccessionController {
} }
@RequestMapping(value = "/download", method = RequestMethod.POST, params = { "dwca" }) @RequestMapping(value = "/download", method = RequestMethod.POST, params = { "dwca" })
public void downloadDwca(@RequestParam(value = "f", required = false, defaultValue = "") String filterCode, @RequestParam(value="filter", required = false) AccessionFilter filter, HttpServletResponse response) throws IOException { public void downloadDwca(@RequestParam(value = "f", required = false, defaultValue = "") String filterCode, @RequestParam(value="filter", required = false) AccessionFilter filter, HttpServletResponse response) throws Exception {
// get AccessionFilter from filterCode // get AccessionFilter from filterCode
FilterInfo<AccessionFilter> filterInfo = shortFilterService.processFilter(filterCode, filter, AccessionFilter.class); FilterInfo<AccessionFilter> filterInfo = shortFilterService.processFilter(filterCode, filter, AccessionFilter.class);
......
...@@ -150,7 +150,7 @@ public class InstituteController { ...@@ -150,7 +150,7 @@ public class InstituteController {
} }
@RequestMapping(value = "/{wiewsCode}/download", method = RequestMethod.POST, params = { "dwca" }) @RequestMapping(value = "/{wiewsCode}/download", method = RequestMethod.POST, params = { "dwca" })
public void downloadDwca(@PathVariable(value = "wiewsCode", required = true) String wiewsCode, HttpServletResponse response) throws IOException { public void downloadDwca(@PathVariable(value = "wiewsCode", required = true) String wiewsCode, HttpServletResponse response) throws Exception {
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode); final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) { if (faoInstitute == null) {
throw new NotFoundElement(); throw new NotFoundElement();
......
...@@ -684,7 +684,7 @@ public class ExplorerController extends BaseController implements InitializingBe ...@@ -684,7 +684,7 @@ public class ExplorerController extends BaseController implements InitializingBe
try { try {
genesysService.writeAccessions(AppliedFilters.convert(appliedFilters), outputStream); genesysService.writeAccessions(AppliedFilters.convert(appliedFilters), outputStream);
response.flushBuffer(); response.flushBuffer();
} catch (EOFException e) { } catch (Exception e) {
LOG.warn("Download was aborted"); LOG.warn("Download was aborted");
} }
} }
......
...@@ -244,7 +244,7 @@ public class ProjectController extends BaseController { ...@@ -244,7 +244,7 @@ public class ProjectController extends BaseController {
@RequestMapping(value = "/{code}/download", method = RequestMethod.POST, params = { "dwca" }) @RequestMapping(value = "/{code}/download", method = RequestMethod.POST, params = { "dwca" })
public void downloadDwca(ModelMap model, @PathVariable(value = "code") String code, HttpServletResponse response) throws IOException { public void downloadDwca(ModelMap model, @PathVariable(value = "code") String code, HttpServletResponse response) throws Exception {
final Project project = projectService.getProjectByCode(code); final Project project = projectService.getProjectByCode(code);
if (project == null || project.getAccessionLists().size() == 0) { if (project == null || project.getAccessionLists().size() == 0) {
throw new NotFoundElement(); throw new NotFoundElement();
......
...@@ -186,10 +186,10 @@ public class SelectionController extends BaseController { ...@@ -186,10 +186,10 @@ public class SelectionController extends BaseController {
* @param cropName * @param cropName
* @param jsonFilter * @param jsonFilter
* @param response * @param response
* @throws IOException * @throws Exception
*/ */
@RequestMapping(value = "/dwca", method = RequestMethod.POST) @RequestMapping(value = "/dwca", method = RequestMethod.POST)
public void dwca(ModelMap model, HttpServletResponse response) throws IOException { public void dwca(ModelMap model, HttpServletResponse response) throws Exception {
// Create JSON filter // Create JSON filter
AccessionFilter filter=new AccessionFilter(); AccessionFilter filter=new AccessionFilter();
filter.id = new HashSet<>(); filter.id = new HashSet<>();
......
...@@ -447,7 +447,7 @@ public class WiewsController extends BaseController { ...@@ -447,7 +447,7 @@ public class WiewsController extends BaseController {
} }
@RequestMapping(value = "/{wiewsCode}/download", method = RequestMethod.POST, params = { "dwca" }) @RequestMapping(value = "/{wiewsCode}/download", method = RequestMethod.POST, params = { "dwca" })
public void downloadDwca(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, HttpServletResponse response) throws IOException { public void downloadDwca(ModelMap model, @PathVariable(value = "wiewsCode") String wiewsCode, HttpServletResponse response) throws Exception {
final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode); final FaoInstitute faoInstitute = instituteService.getInstitute(wiewsCode);
if (faoInstitute == null) { if (faoInstitute == null) {
throw new NotFoundElement(); throw new NotFoundElement();
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
package org.genesys2.server.service; package org.genesys2.server.service;
import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
...@@ -153,7 +152,7 @@ public interface GenesysService { ...@@ -153,7 +152,7 @@ public interface GenesysService {
long countDatasets(FaoInstitute faoInstitute); long countDatasets(FaoInstitute faoInstitute);
void writeAccessions(AccessionFilter filter, OutputStream outputStream) throws IOException; void writeAccessions(AccessionFilter filter, OutputStream outputStream) throws Exception;
List<AccessionGeo> listAccessionsGeo(Set<Long> copy); List<AccessionGeo> listAccessionsGeo(Set<Long> copy);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment