Пример #1
0
  @RequestMapping(method = RequestMethod.POST)
  @ResponseStatus(HttpStatus.CREATED)
  @ResponseBody
  public Foo create(@RequestBody final Foo resource, final HttpServletResponse response) {
    Preconditions.checkNotNull(resource);
    Foo foo = service.create(resource);
    final Long idOfCreatedResource = foo.getId();

    eventPublisher.publishEvent(new ResourceCreatedEvent(this, response, idOfCreatedResource));

    return foo;
  }
Пример #2
0
 @RequestMapping(value = "/{id}", method = RequestMethod.PUT)
 @ResponseStatus(HttpStatus.OK)
 public void update(@PathVariable("id") final Long id, @RequestBody final Foo resource) {
   Preconditions.checkNotNull(resource);
   RestPreconditions.checkFound(service.findOne(resource.getId()));
   service.update(resource);
 }