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:ch.wisv.areafiftylan.exception.GlobalControllerExceptionHandler.java

@ExceptionHandler(IllegalStateException.class)
public ResponseEntity<?> handleIllegalStateException(IllegalStateException ex) {
    return createResponseEntity(HttpStatus.BAD_REQUEST, ex.getMessage());
}

From source file:com.xyxy.platform.examples.showcase.demos.hystrix.service.GetUserCommand.java

/**
 * ?HystrixBadRequestException?//from w ww .j a  va2s  . c  o  m
 */
protected Exception handleException(HttpStatusCodeException e) {
    HttpStatus status = e.getStatusCode();
    if (status.equals(HttpStatus.BAD_REQUEST)) {
        throw new HystrixBadRequestException(e.getResponseBodyAsString(), e);
    }
    throw e;
}

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

@Test
public void report_withConflictingDates_resultsInBadRequest() {
    // No params given -> IllegalArgumentException from fi.hsl.parkandride.core.service.reporting.FacilityUsageReportService
    final ReportParameters params = baseParams();
    params.interval = 100;/*from  w ww  .j a va  2 s  .  c o m*/
    params.startDate = BASE_DATE;
    params.endDate = BASE_DATE.minusDays(1);
    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:au.id.hazelwood.sos.web.controller.framework.GlobalExceptionHandler.java

@ExceptionHandler(value = IllegalArgumentException.class)
public ResponseEntity<Object> handleIllegalArgument(Exception ex, WebRequest request) {
    return handleExceptionInternal(ex, null, new HttpHeaders(), HttpStatus.BAD_REQUEST, request);
}

From source file:com.epam.ta.reportportal.ws.exception.rest.ExceptionHandlingTest.java

@Parameterized.Parameters(name = "{index}:{0},{1},{2}")
public static List<Object[]> getParameters() {
    return Arrays.asList(new Object[][] {
            { new ReportPortalException(EXCEPTION_MESSAGE), ErrorType.UNCLASSIFIED_REPORT_PORTAL_ERROR,
                    HttpStatus.INTERNAL_SERVER_ERROR, EXCEPTION_MESSAGE },
            { new RuntimeException(EXCEPTION_MESSAGE), ErrorType.UNCLASSIFIED_ERROR,
                    HttpStatus.INTERNAL_SERVER_ERROR, EXCEPTION_MESSAGE },
            { new HttpMessageNotReadableException(EXCEPTION_MESSAGE), ErrorType.INCORRECT_REQUEST,
                    HttpStatus.BAD_REQUEST, EXCEPTION_MESSAGE },
            { new MissingServletRequestParameterException("test", "test"), ErrorType.INCORRECT_REQUEST,
                    HttpStatus.BAD_REQUEST, "Required test parameter 'test' is not present" } });
}

From source file:cn.edu.zjnu.acm.judge.util.ValueCheck.java

public static void checkEmail(String email) {
    if (!StringUtils.isEmptyOrWhitespace(email) && !email.matches(EMAIL_PATTERN)) {
        throw new MessageException("email format incorrect", HttpStatus.BAD_REQUEST);
    }// ww w  . j  a va 2 s  . c  o  m
}

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

@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAll() {
    List<Factura> list = facadeService.getFacturaDAO().getAll();
    if (!list.isEmpty()) {
        return new ResponseEntity<>(list, HttpStatus.OK);
    } else {/*from  w  w w.  ja v a 2s  .  c  o  m*/
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }
}

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

@Test
public void typical_json_mapping_violations_are_detected() {
    givenWithContent().body(resourceAsString("facility.create.JsonMappingException.json")).when()
            .post(UrlSchema.FACILITIES).then()
            .spec(assertResponse(HttpStatus.BAD_REQUEST, HttpMessageNotReadableException.class))
            .body("violations[0].path", is("builtCapacity.CAR"));
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.ws.controller.TaxonomyExceptionHandler.java

@ExceptionHandler(TaxonomyException.class)
public ResponseEntity<TaxonomyErrorResponse> handleTaxonomyException(TaxonomyException ex,
        WebRequest webRequest) {/* w  ww .j  a  v a  2 s . c o m*/
    TaxonomyErrorResponse errorResponse = new TaxonomyErrorResponse(ex.getTaxonomyErrorType(), ex.getMessage());
    logger.error("{} < {}", extractPathFromWebRequest(webRequest), errorResponse.toString());
    return new ResponseEntity<TaxonomyErrorResponse>(errorResponse, HttpStatus.BAD_REQUEST);
}