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:gumga.framework.security.GumgaSecurityProxy.java

@ApiOperation(value = "create", notes = "Cria token atravs do usurio e senha informados.")
@RequestMapping(value = "/create/{user}/{password}", method = RequestMethod.GET)
public ResponseEntity create(@PathVariable String user, @PathVariable String password) {
    String url = gumgaValues.getGumgaSecurityUrl() + "/token/create/" + user + "/" + password;
    Map resposta = restTemplate.getForObject(url, Map.class);
    GumgaSecurityCode response = GumgaSecurityCode.OK; //TODO EST? PARA MANTER COMPAT?VEL COM A VERSO ANTERIOR DO SEGURANA, 
    if (resposta.containsKey("response")) {
        response = GumgaSecurityCode.valueOf("" + resposta.get("response"));
    }/*  ww  w .  j  av  a  2s .  c  o  m*/
    return new ResponseEntity(resposta, response.httpStatus);
}

From source file:aka.pirana.springsecurity.web.controllers.UserResource.java

@RequestMapping(value = "", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody/*from  ww w  . j a  v a 2 s. co  m*/
public ResponseEntity<User> createUser(@RequestBody User user) {
    System.out.println("aka.pirana.springsecurity.web.controllers.UserResource.createUser()");
    User savedUser = userService.create(user);
    return new ResponseEntity<User>(savedUser, HttpStatus.CREATED);
}

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

@RequestMapping(value = "/list", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAll() {
    List<Factura> list = facadeService.getFacturaDAO().getAll();
    if (!list.isEmpty()) {
        return new ResponseEntity<>(list, HttpStatus.OK);
    } else {//  w w  w  . j a v  a2 s  .com
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }
}

From source file:springfox.documentation.swagger.web.ApiResourceController.java

@RequestMapping(value = "/configuration/ui")
@ResponseBody/*from  w ww.j av a  2s .  c om*/
ResponseEntity<UiConfiguration> uiConfiguration() {
    return new ResponseEntity<UiConfiguration>(
            Optional.fromNullable(uiConfiguration).or(UiConfiguration.DEFAULT), HttpStatus.OK);
}

From source file:reconf.server.services.property.UpsertPropertyService.java

@RequestMapping(value = "/product/{prod}/component/{comp}/property/{prop}", method = RequestMethod.PUT)
@Transactional//from   www  . ja v  a 2  s  .com
public ResponseEntity<PropertyResult> global(@PathVariable("prod") String product,
        @PathVariable("comp") String component, @PathVariable("prop") String property,
        @RequestBody String value, @RequestParam(value = "desc", required = false) String description,
        HttpServletRequest request, Authentication auth) {

    PropertyKey key = new PropertyKey(product, component, property);
    Property reqProperty = new Property(key, value, description);

    List<String> errors = DomainValidator.checkForErrors(reqProperty);

    if (!errors.isEmpty()) {
        return new ResponseEntity<PropertyResult>(new PropertyResult(reqProperty, errors),
                HttpStatus.BAD_REQUEST);
    }
    if (!products.exists(key.getProduct())) {
        return new ResponseEntity<PropertyResult>(new PropertyResult(reqProperty, Product.NOT_FOUND),
                HttpStatus.NOT_FOUND);
    }
    if (!components.exists(new ComponentKey(key.getProduct(), key.getComponent()))) {
        return new ResponseEntity<PropertyResult>(new PropertyResult(reqProperty, Component.NOT_FOUND),
                HttpStatus.NOT_FOUND);
    }

    HttpStatus status = null;
    Property dbProperty = properties.findOne(key);
    if (dbProperty != null) {
        dbProperty.setValue(value);
        dbProperty.setDescription(description);
        status = HttpStatus.OK;

    } else {
        dbProperty = reqProperty;
        properties.save(dbProperty);
        status = HttpStatus.CREATED;
    }
    return new ResponseEntity<PropertyResult>(
            new PropertyResult(dbProperty, CrudServiceUtils.getBaseUrl(request)), status);
}

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

@RequestMapping(value = "/barcode", method = RequestMethod.GET)
public ResponseEntity<?> getByProductoOnFactura(@RequestParam("barcode") String barcode) {
    List<DetalleFactura> list = facadeService.getDetalleNotaCreditoDAO().getByBarcodeOnFactura(barcode);
    if (!list.isEmpty()) {
        return new ResponseEntity<>(list, HttpStatus.OK);
    } else {//from   w  ww  .jav  a 2  s.co m
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:gt.dakaik.rest.impl.LicenceImpl.java

@Override
public ResponseEntity<Licences> findBySchool(int idUsuario, String token, long idSchool)
        throws EntidadNoEncontradaException {
    School school = repoSchool.findOne(idSchool);

    if (school == null) {
        throw new EntidadNoEncontradaException("Entity School");
    }/*  w w  w  .  j  a  v a2s  .  c om*/
    return new ResponseEntity(repoLic.findBySchool(school), HttpStatus.OK);
}

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

@RequestMapping(value = "/medio/cantidad", method = RequestMethod.GET)
public ResponseEntity<?> getMedioCantidad(@RequestParam("idMedioPago") int idMedioPago) {
    List<Chart> chart = impl.getVentaMedioPago(idMedioPago);
    if (!chart.isEmpty()) {
        return new ResponseEntity<>(chart, HttpStatus.OK);
    } else {/*w ww.ja  v  a2s  .  c o  m*/
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

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

@RequestMapping(path = "/obtencion/{id}", method = RequestMethod.GET)
public ResponseEntity<?> manejadorGetRecursoSalaCreacion(@PathVariable Integer id) {
    try {/*from www.  j  ava 2s .com*/
        return new ResponseEntity<>(StubSala.getInstance().obtenerSala(id), HttpStatus.ACCEPTED);
    } catch (CreacionSalaException ex) {
        Logger.getLogger(SalasController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>(ex.getMessage(), HttpStatus.NOT_ACCEPTABLE);
    }
}

From source file:com.seguriboxltv.ws.AlgorithmAssymetricRest.java

@RequestMapping(value = "/sdassymetric", method = RequestMethod.GET, headers = "Accept=application/json")
@ResponseBody/*w  w  w.j  av  a  2s  .c om*/
public ResponseEntity<List<AssymetricAlgs>> getAllSDAssymetric() {

    List<AssymetricAlgs> list = null;
    try {
        list = algorithmCryptModuleService.GetSDAssymetricAlgs();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return new ResponseEntity<>(list, HttpStatus.OK);
}