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:com._8x8.presentation.restfulController.GCMRestController.java

@RequestMapping(value = "/gcm/{id}/update", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<String> updateGCMById(@PathVariable("id") String id, @RequestBody GCM gcm,
        UriComponentsBuilder ucBuilder) {

    try {/*from   w  w  w . j  ava  2s . co  m*/
        _gcmService.UpdateGCMById(gcm);
        return new ResponseEntity<String>("{'status': 'success'}", HttpStatus.OK);
    } catch (Exception ex) {
        return new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
    }

}

From source file:org.khmeracademy.btb.auc.pojo.controller.Top_Bidder_controller.java

@RequestMapping(value = "/get-top-bidder", method = RequestMethod.GET, produces = "application/json")
@ResponseBody/*from   www.j  a v a2  s .c o  m*/
public ResponseEntity<Map<String, Object>> getTopBidder() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Top_Bidder> top_bidder = top_bidder_service.getTop_Bidder();

        if (!top_bidder.isEmpty()) {
            map.put("DATA", top_bidder);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}

From source file:io.fourfinanceit.homework.controller.LoanControler.java

@RequestMapping(value = "/loan", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Iterable<LoanApplication>> getLoanApplications() {

    Iterable<LoanApplication> loanApplications = loanApplicationRepository.findAll();

    return new ResponseEntity<Iterable<LoanApplication>>(loanApplications, HttpStatus.OK);
}

From source file:com.srinathavan.mwbng.rest.mvc.BlogController.java

/**
 * Test for simple get request to fetch all blogs
 * //  w  w w .ja  va2s. co m
 * @return
 */
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody ResponseEntity<Object> findAllBlogs() {
    BlogList responseData = blogService.findAllBlogs();
    return new ResponseEntity<Object>(responseData, HttpStatus.OK);
}

From source file:com.opensearchserver.hadse.record.RecordController.java

@RequestMapping(method = RequestMethod.GET, value = "/{index_name}/{id}")
@ResponseBody/*ww  w  .j  a v a2s. co m*/
public HttpEntity<String> getData() {
    return new ResponseEntity<String>("Not yet implemented", HttpStatus.NOT_IMPLEMENTED);
}

From source file:org.ameba.exception.BehaviorAwareException.java

/**
 * Transform exception into an {@code ResponseEntity} and return it.
 *
 * @return The ResponseEntity/*  ww w. j  ava  2s. co m*/
 */
public ResponseEntity<Response<Serializable>> toResponse() {
    return new ResponseEntity<>(new Response<>(getMessage(), getMsgKey(), getStatus().toString(), getData()),
            getStatus());
}

From source file:edu.eci.arsw.blindway.controller.GameController.java

@RequestMapping(path = "/maze/{id}/{x}/{y}", method = RequestMethod.GET)
public ResponseEntity<?> setMaze(@PathVariable Integer id, @PathVariable Integer x, @PathVariable Integer y)
        throws BlindWayException {
    try {//from  www. ja  v  a 2 s .  c om
        game.createGame(id, x, y);
    } catch (BlindWayException e) {
    }
    Game g = game.getGame(id);
    return new ResponseEntity<>(g.getLabyrinth(), HttpStatus.ACCEPTED);
}

From source file:fi.helsinki.opintoni.web.rest.privateapi.LocalDevFileResource.java

@RequestMapping(value = "/{filename:.+}", method = RequestMethod.GET)
public ResponseEntity<byte[]> serve(@PathVariable String filename) throws IOException {
    return new ResponseEntity<>(filesMemory.getBytes(filename), HttpStatus.OK);
}

From source file:nu.yona.server.rest.ControllerBase.java

protected <T, U extends ResourceSupport> ResponseEntity<U> createResponse(T dto, HttpStatus status,
        ResourceAssemblerSupport<T, U> resourceAssembler) {
    return new ResponseEntity<>(resourceAssembler.toResource(dto), status);
}

From source file:org.khmeracademy.btb.auc.pojo.controller.Bid_log_controller.java

@RequestMapping(value = "/get", method = RequestMethod.GET, produces = "application/json")
@ResponseBody/*from w w  w  .  j av a 2s.  co m*/
public ResponseEntity<Map<String, Object>> getNumberOfBid() {
    Map<String, Object> map = new HashMap<String, Object>();
    try {
        ArrayList<Bid_log> bids = bid_log_service.getNumberOfBid();
        if (!bids.isEmpty()) {
            map.put("DATA", bids);
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA FOUND!");
        } else {
            map.put("STATUS", true);
            map.put("MESSAGE", "DATA NOT FOUND");
        }
    } catch (Exception e) {
        map.put("STATUS", false);
        map.put("MESSAGE", "Error!");
        e.printStackTrace();
    }
    return new ResponseEntity<Map<String, Object>>(map, HttpStatus.OK);
}