Example #1
0
  @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
  public Developer updateOne(@RequestBody Developer newDeveloper, @PathVariable Long id) {
    Developer developer = developerRespository.findOne(id);
    if (developer == null) throw new DeveloperException(id);

    newDeveloper = developerRespository.save(newDeveloper);
    return newDeveloper;
  }
Example #2
0
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public Developer getById(@PathVariable Long id) {
    Developer developer = developerRespository.findOne(id);

    if (developer == null)
      throw new DeveloperException(id); // lanzar una exception cuando el developer es null.

    return developer;
  }
Example #3
0
  @RequestMapping(method = RequestMethod.GET)
  public List<Developer> findAll() {
    List<Developer> developers = new ArrayList<Developer>();
    Iterator<Developer> iterator = developerRespository.findAll().iterator();

    while (iterator.hasNext()) {
      developers.add(iterator.next());
    }
    return developers;
  }
Example #4
0
 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
 public void deleteOne(@PathVariable Long id) {
   Developer developer = developerRespository.findOne(id);
   if (developer == null) throw new DeveloperException(id);
   developerRespository.delete(id);
 }
Example #5
0
 @RequestMapping(method = RequestMethod.POST)
 @ResponseStatus(HttpStatus.CREATED)
 public Developer save(@RequestBody Developer developer) {
   return developerRespository.save(developer);
 }