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.eci.arsw.controllers.BlueprintController.java

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> addBlueprint(@RequestBody Blueprint p) {
    services.addNewBlueprint(p.getName(), p);
    return new ResponseEntity<>(HttpStatus.ACCEPTED);
}

From source file:com.baidu.terminator.manager.action.RecordAction.java

@RequestMapping(value = "/{linkId}/{version}", method = RequestMethod.DELETE)
public ResponseEntity<?> deleteRecord(@PathVariable int linkId, @PathVariable int version) {
    try {/* ww  w . j  av a 2  s  .  co  m*/
        recordService.deleteRecord(linkId, version);
        return new ResponseEntity<String>(HttpStatus.NO_CONTENT);
    } catch (LinkStatusException e) {
        return new ResponseEntity<String>(e.getMessage(), HttpStatus.METHOD_NOT_ALLOWED);
    }
}

From source file:com.sms.server.controller.JobController.java

@RequestMapping(value = "/active", method = RequestMethod.GET)
public ResponseEntity<List<Job>> getActiveJobs() {
    List<Job> jobs = jobDao.getActiveJobs();

    if (jobs == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*  w  w w.j a  va2 s.c o  m*/

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

From source file:application.controllers.RestController.java

@RequestMapping(value = "/signup", method = RequestMethod.PUT)
public ResponseEntity<?> newAccount(@RequestBody String account) {
    if (myBatisService.getByName(account) != null) {
        return new ResponseEntity<>(HttpStatus.CONFLICT);
    } else {/*  ww  w.j  av  a 2  s  .com*/
        Account newAccount = new Account();
        newAccount.setName(account);
        newAccount.setBalance(1000);
        myBatisService.insertAccount(newAccount);
    }
    return new ResponseEntity<>(HttpStatus.CREATED);
}

From source file:com._8x8.presentation.restfulController.GCMRestController.java

@RequestMapping(value = "/gcm/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<GCM>> getAllGCM() {
    List<GCM> GCMs = _gcmService.GetGCMs();

    if (GCMs.isEmpty()) {
        return new ResponseEntity<List<GCM>>(HttpStatus.NO_CONTENT);//You many decide to return HttpStatus.NOT_FOUND
    }/*from   w  w  w . j a v a2s.c  o m*/
    return new ResponseEntity<List<GCM>>(GCMs, HttpStatus.OK);
}

From source file:com.mycompany.gis2.resource.AdministratorzyResource.java

@RequestMapping(value = "/admin", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity isCorrect(@RequestBody Administratorzy admin) {
    Administratorzy adminRep = adminRepository.findOneByLogin(admin.getLogin());

    return (admin.getHaslo().equals(adminRep.getHaslo())) ? new ResponseEntity(HttpStatus.OK)
            : new ResponseEntity(HttpStatus.UNAUTHORIZED);
}

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

@RequestMapping(value = "/users", method = RequestMethod.POST)
ResponseEntity<User> createUser(@RequestBody User user) {
    if (userStore.userExists(user.getName())) {
        return new ResponseEntity<>(HttpStatus.CONFLICT);
    }/*from w w w. java  2  s.  c o  m*/
    setPassword(user);
    userStore.save(user);
    return new ResponseEntity<>(user, HttpStatus.CREATED);
}

From source file:org.moserp.common.rest.ExceptionHandlingController.java

public ResponseEntity<Void> handleError(HttpServletRequest req, Exception exception) {
    logger.error("Request: " + req.getRequestURL() + " raised " + exception);
    ResponseEntity<Void> responseEntity = new ResponseEntity<Void>(HttpStatus.INTERNAL_SERVER_ERROR);
    return responseEntity;
}

From source file:edu.eci.arsw.msgbroker.PuntosController.java

@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<?> manejadorPostRecursoXX(@RequestBody Point pt) {
    try {//from   www .j a  v  a2s.  co m
        msgt.convertAndSend("/topic/newpoint", pt);
        mp.adicionar(pt);
        if (mp.getSize() == 4) {
            msgt.convertAndSend("/topic/newpolygon", mp.Array());
            mp.reset();
        }
        return new ResponseEntity<>(HttpStatus.CREATED);
    } catch (Exception ex) {
        Logger.getLogger(STOMPMessagesHandler.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>("Error bla bla bla", HttpStatus.FORBIDDEN);
    }

}

From source file:rest.PartidaRestController.java

@RequestMapping(value = "/{id}", method = RequestMethod.PUT)
public ResponseEntity<?> modificarPartida(@PathVariable int id, @RequestBody InfoPartida ip) {
    logicaPartida.modificarPartida(ip, id);
    return new ResponseEntity<>(HttpStatus.CREATED);
}