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:edu.sjsu.cmpe275.project.controller.ReservationController.java

/** Get all reservations
 * @return         void/*from w  w  w.j a  v a2 s . co  m*/
 */

@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseEntity<?> createReservation() {

    List<Reservation> reservations = reservationService.getAll();
    if (reservations == null) {
        return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
    } else {
        return new ResponseEntity<Object>(reservations, HttpStatus.OK);
    }
}

From source file:web.ClientsRESTController.java

/**
 * Lists all clients through a REST API/*from  ww  w  .j  a v  a 2 s. com*/
 * @return
 */
@RequestMapping(value = "/api/clients/", method = RequestMethod.GET)
public ResponseEntity<List<Clients>> listClients() {
    List<Clients> clients = dao.getClientsList();
    //returns NO_CONTENT error if no Clients are provided
    if (clients.isEmpty()) {
        return new ResponseEntity<List<Clients>>(HttpStatus.NO_CONTENT);
    }
    //otherwise returns list of all Clients
    return new ResponseEntity<List<Clients>>(clients, HttpStatus.OK);
}

From source file:io.pivotal.ecosystem.service.HelloController.java

@RequestMapping(value = "/users", method = RequestMethod.PUT)
ResponseEntity<User> updateUser(@RequestBody User user) {
    if (!userStore.userExists(user.getName())) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }//from   ww  w .  j a v  a 2  s.c  o m
    setPassword(user);
    userStore.save(user);
    return new ResponseEntity<>(user, HttpStatus.CREATED);
}

From source file:org.cloudfoundry.identity.uaa.coverage.CoverageController.java

@RequestMapping(value = "flush", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity saveGlobalProjectData() throws ClassNotFoundException, NoSuchMethodException,
        InvocationTargetException, IllegalAccessException {
    String className = "net.sourceforge.cobertura.coveragedata.ProjectData";
    String methodName = "saveGlobalProjectData";
    Class saveClass = Class.forName(className);
    java.lang.reflect.Method saveMethod = saveClass.getDeclaredMethod(methodName, new Class[0]);
    saveMethod.invoke(null, new Object[0]);
    return new ResponseEntity<>(HttpStatus.OK);
}

From source file:com.trafficfine.controller.TrafficFineController.java

/**
 * //from www. j  a va  2  s.co  m
 * @param initialDate
 * @param finalDate
 * @return
 */
@RequestMapping(value = "/api/infracao/busca", method = RequestMethod.GET)
public ResponseEntity<List<Infraction>> listAllTrafficFine(
        @RequestParam(value = "dataInicial") @DateTimeFormat(pattern = "dd/MM/yy") Date dataInicial,
        @RequestParam(value = "dataFinal") @DateTimeFormat(pattern = "dd/MM/yy") Date dataFinal) {
    List<Infraction> infractions = this.trafficFineService.findByRange(dataInicial, dataFinal);
    if (infractions.isEmpty()) {
        return new ResponseEntity<List<Infraction>>(HttpStatus.NO_CONTENT);
    }
    return new ResponseEntity<List<Infraction>>(infractions, HttpStatus.OK);
}

From source file:br.com.hyperclass.snackbar.restapi.StockController.java

@RequestMapping(value = "/stock/", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
public ResponseEntity<ProductWrapper> addItemStock(@RequestBody final ProductWrapper productWrapper) {
    final Product product = new Product(productWrapper.getName(), productWrapper.getPrice());
    stock.addItemStock(product);/*from   www  .  j av  a  2  s. co m*/
    return new ResponseEntity<>(HttpStatus.OK);
}

From source file:org.obp.web.DefaultsController.java

@RequestMapping("/secure/defaults/update")
public ResponseEntity updateDefaultValue(@RequestParam String name, @RequestParam String value) {
    try {/*from w w w.java2 s .c  om*/
        defaultDataInstrument.updateReadout(name, new Double(value));
    } catch (Exception e) {
        return new ResponseEntity(HttpStatus.BAD_REQUEST);
    }
    return new ResponseEntity(HttpStatus.OK);
}

From source file:br.upe.community.ui.ControllerDoacao.java

@RequestMapping(value = "/cadastrar", produces = MediaType.APPLICATION_JSON_VALUE)
public @ResponseBody ResponseEntity<?> cadastrarDoacao(Doacao doacao, Produto produto, String emailUsuario,
        String nomeCategoria) {/*  ww w. ja  v  a2 s.c  o m*/
    try {
        fachada.cadastrarDoacao(doacao, produto, emailUsuario, nomeCategoria);
        return new ResponseEntity<String>(HttpStatus.OK);
    } catch (UsuarioInexistenteException e) {
        return new ResponseEntity<UsuarioInexistenteException>(e, HttpStatus.BAD_REQUEST);
    } catch (CategoriaInexistenteException ex) {
        return new ResponseEntity<CategoriaInexistenteException>(ex, HttpStatus.BAD_REQUEST);

    }
}

From source file:com.tribuo.backend.controllers.VentasController.java

/**
 *
 * @param p/*  www .  j av a 2 s.co m*/
 * @return
 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public ResponseEntity<Void> insertUsuario(@RequestBody Ventas p) {
    se.registerVenta(p);
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:com.tribuo.backend.controllers.TiendasController.java

/**
 *
 * @param p// w w  w .j a  v  a 2  s  .c  o m
 * @return
 */
@RequestMapping(value = "/insert", method = RequestMethod.POST)
public ResponseEntity<Void> insertTienda(@RequestBody Tiendas p) {
    se.createTienda(p);
    return new ResponseEntity<>(HttpStatus.CREATED);
}