Commit 5632c427 authored by Matija Obreza's avatar Matija Obreza
Browse files

Reduce log noise

parent f8668409
......@@ -37,9 +37,12 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.NoHandlerFoundException;
import com.fasterxml.jackson.core.JsonProcessingException;
@ControllerAdvice(basePackages = { "org.genesys2.server.mvc" })
public class UserControllerAdvice extends BaseController {
......@@ -76,9 +79,18 @@ public class UserControllerAdvice extends BaseController {
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = { MaxPageLimitException.class, RequestRejectedException.class })
public ModelAndView handleMaxPageLimitException(final MaxPageLimitException e) {
LOG.error(e.getMessage());
@ExceptionHandler(value = { MaxPageLimitException.class, RequestRejectedException.class, IllegalArgumentException.class })
public ModelAndView handleMaxPageLimitException(final Throwable e, final HttpServletRequest request) {
LOG.warn("Bad request {} {}: {}", request.getMethod(), request.getRequestURL(), e.getMessage());
final ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
}
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = { JsonProcessingException.class })
public ModelAndView handleJsonParseExceptions(final JsonProcessingException e, final HttpServletRequest request) {
LOG.warn("JSON processing error {} {}: {}", request.getMethod(), request.getRequestURL(), e.getMessage());
final ModelAndView mav = new ModelAndView("/errors/error");
mav.addObject("exception", e);
return mav;
......@@ -95,9 +107,10 @@ public class UserControllerAdvice extends BaseController {
// do not pass validation
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(value = { MethodArgumentNotValidException.class })
@ExceptionHandler(value = { MethodArgumentNotValidException.class, MethodArgumentTypeMismatchException.class })
@ResponseBody
public Object handleMethodArgumentNotValidException(final MethodArgumentNotValidException e) {
public Object handleMethodArgumentNotValidException(final MethodArgumentNotValidException e, final HttpServletRequest request) {
LOG.error("Argument not valid for {} {}: {}", request.getMethod(), request.getRequestURL(), e.getMessage());
return transformErrors(e.getBindingResult());
}
......
......@@ -1158,6 +1158,8 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
zos.closeEntry();
zos.finish();
zos.flush();
outputStream.flush();
}
private void writeREADME(AccessionFilter filter, ZipOutputStream zos) throws IOException {
......
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