Ejemplo n.º 1
0
 @RequestMapping(
     value = "/message/{id:\\d+}",
     method = PUT,
     produces = MediaType.APPLICATION_JSON_VALUE,
     consumes = MediaType.APPLICATION_JSON_VALUE)
 public ResponseEntity<Message> update(
     @PathVariable("id") String id, @RequestBody Map<String, Object> params) {
   Message message = repository.findOne(id);
   message.update(params);
   repository.save(message);
   return ResponseEntity.ok(message);
 }
Ejemplo n.º 2
0
  @RequestMapping(
      value = "/message/{projectId:\\d+}/{page:\\d+}/{size:\\d+}",
      method = GET,
      produces = MediaType.APPLICATION_JSON_VALUE)
  public ResponseEntity<List<Message>> fetch(
      @PathVariable("projectId") String projectId,
      @PathVariable("page") int page,
      @PathVariable("size") int size) {
    Pageable pageable = new PageRequest(page, size);
    List<Message> messages = Lists.newArrayList(repository.findAll(pageable).iterator());
    messages =
        Lists.newArrayList(
            messages
                .stream()
                .sorted(
                    new Comparator<Message>() {

                      @Override
                      public int compare(Message m1, Message m2) {
                        // TODO Auto-generated method stub
                        return m1.getDateTime() - m2.getDateTime() > 0 ? -1 : 1;
                      }
                    })
                .iterator());
    return ResponseEntity.ok(messages);
  }
Ejemplo n.º 3
0
 @RequestMapping(
     value = "/message/{publisher:\\w+}/{projectId:\\d+}/{page:\\d+}/{size:\\d+}",
     method = GET,
     produces = MediaType.APPLICATION_JSON_VALUE)
 public ResponseEntity<List<Message>> fetchByPublisher(
     @PathVariable("publisher") String publisher,
     @PathVariable("projectId") String projectId,
     @PathVariable("page") int page,
     @PathVariable("size") int size) {
   Pageable pageable = new PageRequest(page, size);
   List<Message> messages =
       Lists.newArrayList(repository.fetchByPublisher(projectId, publisher, pageable).iterator());
   return ResponseEntity.ok(messages);
 }