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:br.com.porao.ui.ControllerPedido.java

@RequestMapping(value = "/pedido/add", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<?> addPedido(Pedido pedido) {
    try {/*from  w  w  w.j a  va 2  s.c  o m*/
        this.fachada.cadastrarPedido(pedido);
        return new ResponseEntity<String>(HttpStatus.OK);
    } catch (PedidoExistenteException pedidoexistente) {
        return new ResponseEntity<PedidoExistenteException>(pedidoexistente, HttpStatus.BAD_REQUEST);
    }
}

From source file:br.com.porao.ui.ControllerRodada.java

@RequestMapping(value = "/rodada/add", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<?> addRodada(Rodada rodada) {
    try {/*from  ww  w .ja  v  a  2 s .  c o  m*/
        this.fachada.cadastrarRodada(rodada);
        return new ResponseEntity<String>(HttpStatus.OK);
    } catch (RodadaExistenteException rodadaexistente) {
        return new ResponseEntity<RodadaExistenteException>(rodadaexistente, HttpStatus.BAD_REQUEST);
    }
}

From source file:org.trustedanalytics.examples.hbase.api.ExceptionHandlerAdvice.java

@ExceptionHandler(HttpMessageConversionException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody/*  w ww.  j  a  v  a 2 s.  c  om*/
public String handleBadRequest(Exception ex) {
    LOG.error("Handling request malformed exception", ex);
    return "Request message malformed";
}

From source file:com._8x8.presentation.restfulController.ZPayRestfulController.java

@RequestMapping(value = "/broadcastMsgByQRCode/{qrCode}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> broadcastMsgByQRCode(@PathVariable("qrCode") String qrCode) {

    try {/*from w w w.  j  ava 2 s .co m*/
        Boolean broadcast = _broadcastService.SendBroadcastMsg("SomeMessage", qrCode);
        return new ResponseEntity<String>(broadcast.toString(), HttpStatus.OK);
    } catch (Exception ex) {
        return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
    }

}

From source file:org.osiam.addons.selfadministration.exception.InvalidAttributeException.java

public InvalidAttributeException(String message, String key, Throwable cause) {
    super(message, key, HttpStatus.BAD_REQUEST.value(), cause);
}

From source file:br.com.porao.ui.ControllerCliente.java

@RequestMapping(value = "/cliente/add", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<?> addCliente(Cliente cliente) {
    try {/*w  ww  . j  av  a 2 s  .  co m*/
        this.fachada.cadastrarCliente(cliente);
        return new ResponseEntity<String>(HttpStatus.OK);
    } catch (ClienteExistenteException clienteexistente) {
        return new ResponseEntity<ClienteExistenteException>(clienteexistente, HttpStatus.BAD_REQUEST);
    }
}

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

public static void checkNick(String nick) {
    if (StringUtils.isEmpty(nick)) {
        throw new MessageException("nick can not be NULL", HttpStatus.BAD_REQUEST);
    }/*from   ww  w .  java2 s  . c  om*/
    if (nick.length() > 64) {
        throw new MessageException("nick is too long", HttpStatus.BAD_REQUEST);
    }
}

From source file:com.nebhale.buildmonitor.web.ControllerUtils.java

@ExceptionHandler(ConstraintViolationException.class)
ResponseEntity<Set<String>> handleConstraintViolation(ConstraintViolationException e) {
    Set<ConstraintViolation<?>> constraintViolations = e.getConstraintViolations();

    Set<String> messages = new HashSet<>(constraintViolations.size());
    messages.addAll(constraintViolations.stream()
            .map(constraintViolation -> String.format("%s value '%s' %s", constraintViolation.getPropertyPath(),
                    constraintViolation.getInvalidValue(), constraintViolation.getMessage()))
            .collect(Collectors.toList()));

    return new ResponseEntity<>(messages, HttpStatus.BAD_REQUEST);
}

From source file:br.com.porao.ui.ControllerProduto.java

@RequestMapping(value = "/produto/add", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<?> addProduto(Produto produto) {
    try {/*  w ww  .j a v  a 2  s.  c o m*/
        this.fachada.cadastrarProduto(produto);
        return new ResponseEntity<String>(HttpStatus.OK);
    } catch (ProdutoExistenteException produtoexistente) {
        return new ResponseEntity<ProdutoExistenteException>(produtoexistente, HttpStatus.BAD_REQUEST);
    }
}

From source file:edu.eci.arsw.pacm.controllers.PacmRESTController.java

@RequestMapping(path = "/{salanum}/atacantes", method = RequestMethod.PUT)
public ResponseEntity<?> agregarAtacante(@PathVariable(name = "salanum") String salanum,
        @RequestBody Player p) {//from www. j  a  va2  s.  c o m
    synchronized (services) {
        try {
            if (services.getAtacantes(Integer.parseInt(salanum)).size() < 4) {
                services.registrarJugadorAtacante(Integer.parseInt(salanum), p);
            }

        } catch (ServicesException ex) {
            Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
            return new ResponseEntity<>(ex.getLocalizedMessage(), HttpStatus.BAD_REQUEST);
        }
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
}