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:org.mitre.openid.connect.view.ExceptionAsJSONView.java
@Override protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest requesr, HttpServletResponse response) {//from w ww .j a va 2 s .c om response.setContentType("application/json"); response.setStatus(HttpStatus.BAD_REQUEST.value()); final JsonObject jsonObject = new JsonObject(); Object ex = model.get("exception"); jsonObject.addProperty("error", ex.getClass().getName()); jsonObject.addProperty("error_description", ((Exception) ex).getMessage()); try { response.getWriter().write(jsonObject.toString()); } catch (IOException e) { logger.error("IOException in ExceptionAsJSONView.java: ", e); } }
From source file:com.blstream.patronage.ctf.common.web.controller.AbstractRestController.java
/** * Returns error message when BadRequestException or IllegalArgumentException * exception occured.// www . jav a 2s. c o m * * @see com.blstream.patronage.ctf.common.exception.BadRequestException * * @param e * @return */ @ExceptionHandler({ BadRequestException.class, IllegalArgumentException.class }) @ResponseStatus(HttpStatus.BAD_REQUEST) public MessageUI handleBadRequestException(Exception e) { MessageUI messageUI = new MessageUI(); messageUI.setErrorDescription(e.getMessage()); messageUI.setError(badRequestMessage); messageUI.setErrorCode(ErrorCodeType.BAD_REQUEST); return messageUI; }
From source file:eu.cloudwave.wp5.feedbackhandler.controller.AbstractBaseUiController.java
/** * Is called whenever an {@link RequestException} in a controller method is thrown. * // w ww. j a v a 2s . c o m * @param exception * the exception that arose * @param request * the request that caused the exception * @return an {@link RestRequestErrorDto} for the respective error */ @ExceptionHandler(RequestException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public final ModelAndView handleRestRequestException(final RequestException exception, final HttpServletRequest request) { return htmlErrorPage(exception.getMessage()); }
From source file:org.openmhealth.dsu.controller.GenericExceptionHandlingControllerAdvice.java
@ExceptionHandler(MissingServletRequestParameterException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public void handleMissingServletRequestParameterException(MissingServletRequestParameterException e, HttpServletRequest request) {//w w w .ja va 2 s .c o m log.debug("A {} request for '{}' failed because parameter '{}' is missing.", request.getMethod(), request.getPathInfo(), e.getParameterName(), e); }
From source file:com.auditbucket.helper.GlobalControllerExceptionHandler.java
@ExceptionHandler(DatagioException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) public ModelAndView handleAuditException(DatagioException ex) { logger.error("Datagio Exception", ex); return new JsonError(ex.getMessage()).asModelAndView(); }
From source file:io.getlime.push.errorhandling.DefaultExceptionHandler.java
@ResponseStatus(HttpStatus.BAD_REQUEST) // 400 @ExceptionHandler(PushServerException.class) @ResponseBody//from www. j a v a2s . com public ErrorResponse handlePushException(Exception e) { ErrorResponse response = new ErrorResponse(new Error(Error.Code.ERROR_GENERIC, e.getMessage())); Logger.getLogger(DefaultExceptionHandler.class.getName()).log(Level.SEVERE, null, e); return response; }
From source file:nu.yona.server.exceptions.ResourceBasedException.java
/** * Constructor./*from w w w.j a va 2 s. c o m*/ * * @param messageId The ID of the exception in the resource bundle * @param parameters The parameters for the message */ protected ResourceBasedException(String messageId, Serializable... parameters) { this(HttpStatus.BAD_REQUEST, messageId, parameters); }
From source file:eu.cloudwave.wp5.feedbackhandler.controller.AbstractBaseRestController.java
/** * Is called whenever an {@link RequestException} in a controller method is thrown. * /* www . j av a2 s . c o m*/ * @param exception * the exception that arose * @param request * the request that caused the exception * @return an {@link RestRequestErrorDto} for the respective error */ @ExceptionHandler(RequestException.class) @ResponseStatus(HttpStatus.BAD_REQUEST) @ResponseBody public final RestRequestErrorDto handleRestRequestException(final RequestException exception, final HttpServletRequest request) { return new RestRequestErrorDto(exception.getType(), exception.getMessage()); }
From source file:reconf.server.services.product.DeleteProductService.java
@RequestMapping(value = "/product/{prod}", method = RequestMethod.DELETE) @Transactional/*from ww w. ja va 2 s . c o m*/ public ResponseEntity<ProductResult> doIt(@PathVariable("prod") String product, Authentication auth) { if (!ApplicationSecurity.isRoot(auth)) { return new ResponseEntity<ProductResult>(HttpStatus.FORBIDDEN); } Product reqProduct = new Product(product, null); List<String> errors = DomainValidator.checkForErrors(reqProduct); if (!errors.isEmpty()) { return new ResponseEntity<ProductResult>(new ProductResult(reqProduct, errors), HttpStatus.BAD_REQUEST); } if (!products.exists(reqProduct.getName())) { return new ResponseEntity<ProductResult>(new ProductResult(reqProduct, Product.NOT_FOUND), HttpStatus.NOT_FOUND); } products.delete(reqProduct.getName()); components.deleteByKeyProduct(reqProduct.getName()); properties.deleteByKeyProduct(reqProduct.getName()); userProducts.deleteByKeyProduct(reqProduct.getName()); return new ResponseEntity<ProductResult>(HttpStatus.OK); }
From source file:io.onedecision.engine.OneDecisionExceptionHandler.java
@ResponseStatus(value = HttpStatus.BAD_REQUEST) @ExceptionHandler(InvalidDmnException.class) @ResponseBody/*from ww w . j a v a 2 s . c o m*/ public InvalidDmnException handleInvalidDmn(InvalidDmnException e) { LOGGER.error(e.getMessage(), e); return e; }