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(MultiValueMap<String, String> headers, HttpStatus status) 

Source Link

Document

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

Usage

From source file:net.jkratz.igdb.controller.ESRBRatingController.java

/**
 * Returns all ESRB ratings in database/*from   www.j a v a 2 s. com*/
 * 
 * @return List of ESRBRating objects
 * @see ESRBRating
 */
@RequestMapping(value = { "", "/" }, method = RequestMethod.GET)
public ResponseEntity<List<ESRBRating>> getESRBRatings() {
    List<ESRBRating> esrbRatings = esrbRatingService.getESRBRatings();
    return new ResponseEntity<>(esrbRatings, HttpStatus.OK);
}

From source file:io.github.robwin.swagger2markup.petstore.controller.UserController.java

@RequestMapping(method = POST)
@ResponseBody//from   ww w  .  j  ava2  s.c  om
@ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.")
public ResponseEntity<User> createUser(
        @RequestBody @ApiParam(value = "Created user object", required = true) User user) {

    userRepository.add(user);
    return new ResponseEntity<User>(user, HttpStatus.OK);
}

From source file:net.kenblair.scheduler.mvc.ResponseBuilder.java

/**
 * Build a paginated response.//from  w  ww . j  av  a 2  s  . c o m
 * <p/>
 * The response will use a 200 OK.
 *
 * @param resource      The page to return.
 * @param pageAssembler An assembler to build the pagination links.
 * @return The response with paginated resources.
 */
public HttpEntity<PagedResources<Resource<E>>> ok(final Page<E> resource,
        final PagedResourcesAssembler<E> pageAssembler) {
    return new ResponseEntity<>(pageAssembler.toResource(resource, resourceAssembler), OK);
}

From source file:net.eusashead.hateoas.conditional.interceptor.AsyncTestController.java

@RequestMapping(method = RequestMethod.HEAD)
public Callable<ResponseEntity<Void>> head() {
    return new Callable<ResponseEntity<Void>>() {

        @Override/* w  ww . j  a  v a  2  s  .  c  om*/
        public ResponseEntity<Void> call() throws Exception {
            HttpHeaders headers = new HttpHeaders();
            headers.setETag("\"123456\"");
            return new ResponseEntity<Void>(headers, HttpStatus.OK);
        }
    };

}

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

@RequestMapping(value = "/add", method = RequestMethod.POST)
public ResponseEntity<?> add(OAuth2Authentication authentication, @RequestBody Factura factura) {
    Usuarios user = facadeService.getUsuariosDAO().findUsuarioByUsername(authentication.getName());
    factura.setUsuarioCreacion(user.getIdUsuario());
    factura.setFechaCreacion(new Date());
    factura.setEstado("RESERVADO");
    factura.setIdSucursal(user.getUsuarioSucursal().getIdSucursal());
    factura.setTotal(BigDecimal.ZERO);
    int idFactura = facadeService.getFacturaDAO().add(factura);
    JsonResponse msg = new JsonResponse("Success", String.valueOf(idFactura));
    return new ResponseEntity<>(msg, HttpStatus.OK);
}

From source file:org.cloudfoundry.identity.uaa.error.ConvertingExceptionViewTests.java

@Test
public void testRender() throws Exception {
    RuntimeException e = new RuntimeException("Unexpected error");
    view = new ConvertingExceptionView(
            new ResponseEntity<ExceptionReport>(new ExceptionReport(e), HttpStatus.INTERNAL_SERVER_ERROR),
            messageConverters);/*from  ww  w  . jav a2 s.c  o m*/
    view.render(new HashMap<String, Object>(), request, response);
    assertNotNull(response.getContentAsString());
}

From source file:fi.hsl.parkandride.front.UserController.java

@RequestMapping(method = GET, value = USERS, produces = APPLICATION_JSON_VALUE)
public ResponseEntity<SearchResults<User>> findUsers(User actor) {
    log.info("findUsers");
    UserSearch search = new UserSearch();
    search.setOperatorId(actor.operatorId);
    SearchResults<User> results = userService.findUsers(search, actor);
    return new ResponseEntity<>(results, OK);
}

From source file:org.lightadmin.core.web.RepositoryMetadataController.java

@RequestMapping(value = BASE_MAPPING + "/metadata", method = GET)
public HttpEntity<JsonConfigurationMetadata> schema(RootResourceInformation resourceInformation) {
    JsonConfigurationMetadata jsonConfigurationMetadata = domainTypeToJsonMetadataConverter
            .convert(resourceInformation.getPersistentEntity());

    return new ResponseEntity<JsonConfigurationMetadata>(jsonConfigurationMetadata, OK);
}

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

@RequestMapping(value = "/search/id", method = RequestMethod.GET)
public ResponseEntity<?> getById(@RequestParam("idNota") int idNota) {
    NotaCredito notaCredito = facadeService.getNotaCreditoDAO().getById(idNota);
    if (notaCredito != null) {
        return new ResponseEntity<>(notaCredito, HttpStatus.OK);
    } else {/*from   w  ww .  j  a  va2 s  .  com*/
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:org.farrukh.examples.rest.exception.GlobalExceptionHandler.java

/**
 * Handles an error belonging to the application.
 *
 * @param error the type of the error./*from w  ww.j  a  v a2 s.c o  m*/
 * @return the response error.
 */
@ExceptionHandler(AbstractError.class)
public ResponseEntity<ErrorResponse> handleApplicationException(final AbstractError error) {
    return new ResponseEntity<>(new ErrorResponse(error.getCode(), error.getMessage()), error.getHttpStatus());
}