Example usage for org.springframework.http HttpStatus BAD_REQUEST

List of usage examples for org.springframework.http HttpStatus BAD_REQUEST

Introduction

In this page you can find the example usage for org.springframework.http HttpStatus BAD_REQUEST.

Prototype

HttpStatus BAD_REQUEST

To view the source code for org.springframework.http HttpStatus BAD_REQUEST.

Click Source Link

Document

400 Bad Request .

Usage

From source file:com.hp.autonomy.frontend.find.core.web.GlobalExceptionHandler.java

@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody/*from   w w  w .  j ava2 s  .  c  o  m*/
public ErrorResponse messageNotReadableHandler(final HttpMessageNotReadableException exception)
        throws HttpMessageNotReadableException {
    return handler(exception);
}

From source file:com.ar.dev.tierra.api.controller.TemporadaController.java

@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAll() {
    List<Temporada> temporadas = facadeService.getTemporadaDAO().getAll();
    if (!temporadas.isEmpty()) {
        return new ResponseEntity<>(temporadas, HttpStatus.OK);
    } else {//w w w  .  j ava2s.  com
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }
}

From source file:org.zalando.riptide.PassThroughResponseErrorHandlerTest.java

@Test
public void isNoErrorForClientError() throws IOException {
    assertThat(unit.hasError(new MockClientHttpResponse(new byte[] {}, HttpStatus.BAD_REQUEST)), is(false));
}

From source file:fr.olympicinsa.riocognized.exception.MyExceptionHandler.java

@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseBody//from   w w  w .j  a  va2 s.  c  o  m
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ErrorMessage handleHttpMessageNotReadableException(HttpMessageNotReadableException e,
        HttpServletRequest req) {
    return new ErrorMessage(e);
}

From source file:fi.hsl.parkandride.itest.GenericReportITest.java

@Test
public void report_withException_resultsInBadRequest() {
    // Negative interval should throw exception
    final ReportParameters params = baseParams();
    params.interval = -1;/*w  w w .j  av  a  2 s. c  om*/
    given().contentType(ContentType.JSON).accept(MEDIA_TYPE_EXCEL)
            .header(authorization(devHelper.login(adminUser.username).token)).body(params).when()
            .post(UrlSchema.REPORT, "FacilityUsage").then().assertThat()
            .statusCode(HttpStatus.BAD_REQUEST.value());
}

From source file:uk.gov.hscic.common.config.DefaultControllerExceptionHandler.java

@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(InvalidDataException.class)
public String handleInvalidDataException(final InvalidDataException ex) {
    return ex.getMessage();
}

From source file:com.create.controller.BeanValidatorErrorHandler.java

@ExceptionHandler
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody/*from  w w  w. j a  va 2 s. c  om*/
public ValidationResult<?> processValidationErrors(MethodArgumentNotValidException exception) {
    final BindingResult result = exception.getBindingResult();
    final List<ObjectError> fieldErrors = result.getAllErrors();
    final List<?> targets = getTargets(result);
    return processValidationErrors(targets, fieldErrors);
}

From source file:org.sharetask.controller.handler.UserAlreadyExistsExceptionHandler.java

@ExceptionHandler
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody//from  w  w w. j a  v a  2  s .co m
public ResponseError handlException(final UserAlreadyExistsException error) {
    return new ResponseError(ErrorType.USER_ALREADY_EXISTS);
}

From source file:edu.sjsu.cmpe275.project.controller.UserController.java

/** get all users
 * @return         void/* w  ww . j av  a  2 s.  c o  m*/
 */

@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseEntity<?> getUsers() {

    List<User> users = userDao.getAllUsers();

    if (users == null) {
        return new ResponseEntity<Object>(HttpStatus.BAD_REQUEST);
    } else {
        return new ResponseEntity<Object>(users, HttpStatus.OK);
    }
}

From source file:com.cultureofcode.diceware.NumberController.java

@ExceptionHandler(IllegalArgumentException.class)
public ClientError handleIllegalArgs(IllegalArgumentException iae, HttpServletResponse resp) {

    resp.setStatus(HttpStatus.BAD_REQUEST.value());
    return new ClientError(iae.getMessage());

}