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:business.GlobalExceptionHandlerController.java

@ExceptionHandler(ExcerptListUploadError.class)
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody//from  w  w w  .j  a va  2  s  .co  m
public ResponseEntity<String> handleExcerptListUploadError(ExcerptListUploadError e) {
    log.error("ExcerptListUploadError: " + e.getMessage());
    return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
}

From source file:io.fabric8.che.starter.exception.GlobalExceptionHandler.java

@ResponseStatus(value = HttpStatus.BAD_REQUEST, reason = "URL is not valid")
@ExceptionHandler({ URISyntaxException.class, MalformedURLException.class })
public String handleURLException(Exception e) {
    return e.getMessage();
}

From source file:org.oncoblocks.centromere.web.exceptions.ParameterMappingException.java

public ParameterMappingException(String developerMessage, String moreInfoUrl) {
    super(HttpStatus.BAD_REQUEST, 40002,
            "One of the query string parameters could not be mapped to the requested domain model.",
            developerMessage, moreInfoUrl);
}

From source file:org.cloudfoundry.identity.uaa.scim.exception.InvalidPasswordException.java

/**
 * @param message a message for the caller
 */
public InvalidPasswordException(String message) {
    super(message, HttpStatus.BAD_REQUEST);
}

From source file:com.tsguild.videogamewebapp.validation.RestValidationHandler.java

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody// w ww .ja  v a  2s  . c om
public ValidationErrorContainer processValidationErrors(MethodArgumentNotValidException e) {
    BindingResult result = e.getBindingResult();
    List<FieldError> fieldErrors = result.getFieldErrors();

    ValidationErrorContainer errors = new ValidationErrorContainer();
    fieldErrors.stream().forEach((currentError) -> {
        errors.addValidationError(currentError.getField(), currentError.getDefaultMessage());
    });
    return errors;
}

From source file:com.sg.addressbookmvc.validation.RestValidationHandler.java

@ExceptionHandler(MethodArgumentNotValidException.class)

@ResponseStatus(HttpStatus.BAD_REQUEST)

@ResponseBody/*  ww w . j av a2  s  . com*/
public ValidationErrorContainer processValidationErrors(MethodArgumentNotValidException e) {

    BindingResult result = e.getBindingResult();
    List<FieldError> fieldErrors = result.getFieldErrors();

    ValidationErrorContainer errors = new ValidationErrorContainer();
    for (FieldError currentError : fieldErrors) {
        errors.addValidationError(currentError.getField(), currentError.getDefaultMessage());
    }
    return errors;
}

From source file:com.swcguild.addressbookmvc.validation.RestValidationHandler.java

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody/*from   www .  j av a2s. c o m*/
public ValidationErrorContainer processValidationErrors(MethodArgumentNotValidException e) {

    BindingResult result = e.getBindingResult();
    List<FieldError> fieldErrors = result.getFieldErrors();

    ValidationErrorContainer errors = new ValidationErrorContainer();

    for (FieldError currentError : fieldErrors) {
        errors.addValidationError(currentError.getField(), currentError.getDefaultMessage());
    }
    return errors;
}

From source file:com.thesoftwareguild.addressbook.validation.RestValidationHandler.java

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody//from  w  w w.j a  va 2 s  . c  o m
public ValidationErrorContainer processValidationErrors(MethodArgumentNotValidException e) {

    BindingResult result = e.getBindingResult();
    List<FieldError> fieldErrors = result.getFieldErrors();
    ValidationErrorContainer errors = new ValidationErrorContainer();

    for (FieldError currentError : fieldErrors) {
        errors.addValidationError(currentError.getField(), currentError.getDefaultMessage());
    }
    return errors;
}

From source file:com.mycompany.capstone.validation.RestValidationHandler.java

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody//  w w w  .  j  a v  a  2  s  . com
public ValidationErrorContainer processValidationErrors(MethodArgumentNotValidException ex) {

    BindingResult bindResult = ex.getBindingResult();
    List<FieldError> fieldErrors = bindResult.getFieldErrors();
    ValidationErrorContainer container = new ValidationErrorContainer();

    for (FieldError error : fieldErrors) {
        ValidationError valError = new ValidationError();

        valError.setFieldName(error.getField());
        valError.setMessage(error.getDefaultMessage());

        container.addError(valError);
    }

    return container;
}

From source file:com.tsg.contactlistmvc.validation.RestValidationHandler.java

@ExceptionHandler(MethodArgumentNotValidException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody//w  ww. j  a  v a  2s.  c  om
public ValidationErrorContainer processValidationErrors(MethodArgumentNotValidException e) {
    BindingResult result = e.getBindingResult();
    List<FieldError> fieldErrors = result.getFieldErrors();

    ValidationErrorContainer errors = new ValidationErrorContainer();
    for (FieldError currentError : fieldErrors) {
        errors.addValidationError(currentError.getField(), currentError.getDefaultMessage());

    }
    return errors;
}