List of usage examples for org.springframework.http HttpStatus BAD_REQUEST
HttpStatus BAD_REQUEST
To view the source code for org.springframework.http HttpStatus BAD_REQUEST.
Click Source Link
From source file:com.ar.dev.tierra.api.controller.ProductoController.java
@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<?> getAll() { List<Producto> list = facadeService.getProductoDAO().getAll(); if (!list.isEmpty()) { return new ResponseEntity<>(list, HttpStatus.OK); } else {/* w w w. jav a 2s . c om*/ return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } }
From source file:com.graphaware.module.algo.path.NumberOfShortestPathsFinderApi.java
@ExceptionHandler(IllegalArgumentException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public void handleIllegalArguments() { }
From source file:com.github.iexel.fontus.web.rest.GlobalControllerAdviceRest.java
@ResponseBody @ResponseStatus(HttpStatus.BAD_REQUEST) @ExceptionHandler(ServiceException.class) public AjaxError handle(ServiceException ex, Locale locale) { logger.error(null, ex);//from w ww . j ava 2 s . c o m ex.printStackTrace(); AjaxError ajaxError = new AjaxError(); ajaxError.setLocalErrorMessage(fetchErrorMessage(ex.getErrorCode().toString(), locale)); return ajaxError; }
From source file:org.watterssoft.appsupport.ticket.ui.TicketController.java
@ExceptionHandler @ResponseStatus(HttpStatus.BAD_REQUEST) public void handle(HttpMessageNotReadableException e) { throw new RuntimeException("400 error in TicketController", e); }
From source file:org.energyos.espi.datacustodian.web.api.ApplicationInformationRESTController.java
@ExceptionHandler(Exception.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public void handleGenericException() { }
From source file:io.curly.gathering.mention.MentionController.java
@RequestMapping(value = "", method = { RequestMethod.PUT, RequestMethod.POST }) public Callable<HttpEntity<?>> mention(@Valid @RequestBody MentionBody body, @PathVariable String listId, @GitHubAuthentication User user, BindingResult bindingResult) { if (bindingResult.hasErrors()) { return () -> new ResponseEntity<Object>(new ModelErrors(bindingResult), HttpStatus.BAD_REQUEST); } else {// ww w. j a va 2s . co m return () -> { interaction.mention(new Mention(body.getParticipant(), listId), user); return new ResponseEntity<>(HttpStatus.CREATED); }; } }
From source file:net.jkratz.igdb.controller.advice.ErrorController.java
@RequestMapping(produces = "application/json") @ExceptionHandler({ MissingServletRequestParameterException.class, UnsatisfiedServletRequestParameterException.class, ServletRequestBindingException.class }) @ResponseStatus(value = HttpStatus.BAD_REQUEST) public @ResponseBody Map<String, Object> handleRequestException(Exception ex) { logger.warn(ex.getMessage());//from w ww .j ava 2 s .c o m Map<String, Object> map = Maps.newHashMap(); map.put("error", "Request Error"); map.put("message", ex.getMessage()); return map; }
From source file:com.xyxy.platform.examples.showcase.demos.hystrix.dependency.DependencyResourceController.java
/** * ????30?// w w w.j av a 2 s. c om */ @RequestMapping(value = "/hystrix/resource/{id}", method = RequestMethod.GET) @ResponseBody public UserDTO getUser(@PathVariable("id") Long id) { // . if ("normal".equals(status)) { return handleRequest(id); } // 30?. if ("timeout".equals(status)) { Threads.sleep(TIMEOUT); return handleRequest(id); } // ?. if ("server-error".equals(status)) { throw new RestException(HttpStatus.INTERNAL_SERVER_ERROR, "Server Exception"); } // if ("bad-request".equals(status)) { throw new RestException(HttpStatus.BAD_REQUEST, "Client send a bad request"); } return null; }
From source file:de.thm.arsnova.controller.SocketController.java
@RequestMapping(method = RequestMethod.POST, value = "/assign") public void authorize(@RequestBody final Map<String, String> sessionMap, final HttpServletResponse response) { String socketid = sessionMap.get("session"); if (null == socketid) { LOGGER.debug("Expected property 'session' missing", socketid); response.setStatus(HttpStatus.BAD_REQUEST.value()); return;/*from w w w .j a va 2s .c om*/ } User u = userService.getCurrentUser(); if (null == u) { LOGGER.debug("Client {} requested to assign Websocket session but has not authenticated", socketid); response.setStatus(HttpStatus.FORBIDDEN.value()); return; } userService.putUser2SocketId(UUID.fromString(socketid), u); userSessionService.setSocketId(UUID.fromString(socketid)); response.setStatus(HttpStatus.NO_CONTENT.value()); }
From source file:org.trustedanalytics.h2oscoringengine.rest.H2oScoringEngineController.java
@ExceptionHandler(IllegalArgumentException.class) void handleIllegalArgumentException(IllegalArgumentException e, HttpServletResponse response) throws IOException { LOGGER.error("Invalid input data size:", e); response.sendError(HttpStatus.BAD_REQUEST.value(), e.getMessage()); }