Example usage for org.springframework.http ResponseEntity ResponseEntity

List of usage examples for org.springframework.http ResponseEntity ResponseEntity

Introduction

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

Prototype

public ResponseEntity(HttpStatus status) 

Source Link

Document

Create a new ResponseEntity with the given status code, and no body nor headers.

Usage

From source file:cherry.foundation.springmvc.ExceptionController.java

@ExceptionHandler(NotFoundException.class)
public ResponseEntity<String> handleNotFoundException(NotFoundException ex) {
    return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
}

From source file:rest.PartidaRestController.java

@RequestMapping(value = "/", method = RequestMethod.POST)
public ResponseEntity<?> guardarPartida(@RequestBody InfoPartida ip) {
    logicaPartida.registrarPartida(ip);//  w  ww  . jav  a 2s  .  c  o m
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:io.github.jhipster.web.util.ResponseUtil.java

/**
 * Wrap the optional into a {@link ResponseEntity} with an {@link HttpStatus#OK} status with the headers,
 * or if it's empty, it returns a {@link ResponseEntity} with {@link HttpStatus#NOT_FOUND}.
 *
 * @param <X>           type of the response
 * @param maybeResponse response to return if present
 * @param header        headers to be added to the response
 * @return response containing {@code maybeResponse} if present or {@link HttpStatus#NOT_FOUND}
 *///ww w .j a  va2  s  .c  om
public static <X> ResponseEntity<X> wrapOrNotFound(Optional<X> maybeResponse, HttpHeaders header) {
    return maybeResponse.map(response -> ResponseEntity.ok().headers(header).body(response))
            .orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
}

From source file:edu.eci.cosw.controllers.ProductsController.java

@RequestMapping(value = "/jefe", method = RequestMethod.POST)
public ResponseEntity<?> adicionarFamilia(@RequestBody InscripcionJefes jefe) {
    services.addJefe(jefe);//  w  ww  .  j a  v  a2  s .  c  o m
    return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

From source file:net.eusashead.hateoas.springhalbuilder.controller.ExceptionHandlingControllerAdvice.java

@ExceptionHandler(ObjectRetrievalFailureException.class)
public ResponseEntity<Void> handleNotFound() {
    return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
}

From source file:rest.JugadorRestController.java

@RequestMapping(value = "/", method = RequestMethod.POST)
public ResponseEntity<?> guardarJugador(@RequestBody Jugador j) {
    logicaJugador.registrarJugador(j);/*from   ww  w  .  j a v a 2  s. c o  m*/
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:springfox.documentation.spring.web.dummy.controllers.GenericPetController.java

@PostMapping("test")
public ResponseEntity<Pet> test() {
    return new ResponseEntity(HttpStatus.OK);
}

From source file:cz.jirutka.spring.exhandler.handlers.ResponseStatusRestExceptionHandler.java

public ResponseEntity<Void> handleException(Exception ex, HttpServletRequest request) {
    return new ResponseEntity<>(status);
}

From source file:edu.eci.cosw.restcontrollers.ManejadorCotizaciones.java

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> addNewCotizacion(@RequestBody Cotizacion c) {

    return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

From source file:rest.TorneoRestController.java

@RequestMapping(value = "/", method = RequestMethod.POST)
public ResponseEntity<?> guardarTorneo(@RequestBody Torneo t) {
    logicaTorneo.registrarTorneo(t);//from   www .j ava2s.c  o  m
    return new ResponseEntity<>(HttpStatus.CREATED);
}