Ejemplo n.º 1
0
  @RequestMapping(value = "/howmanymessages", method = RequestMethod.GET)
  @ResponseBody
  public Integer howManyMessages(@ModelAttribute("currentUser") CurrentUser currentUser) {
    LOGGER.debug("Checking how many messages user have");

    Collection<Message> messages = messageService.getAllMessages(currentUser.getUser());
    return messages.size();
  }
Ejemplo n.º 2
0
  @RequestMapping(value = "/hasnewmessage", method = RequestMethod.GET)
  @ResponseBody
  public Boolean hasNewMessage(@ModelAttribute("currentUser") CurrentUser currentUser) {
    LOGGER.debug("Checking if there is a any new message");

    messagesCounter = messageService.getMessagesQuantity(currentUser);
    Collection<Message> messages = messageService.getAllMessages(currentUser.getUser());

    if (messages.size() > messagesCounter) {
      messageService.saveMessageQuantity(messages.size(), currentUser);
      messagesCounter = messages.size();
      return true;
    }
    return false;
  }
Ejemplo n.º 3
0
 @RequestMapping(value = "/messages", method = RequestMethod.GET)
 public ModelAndView getMessagesPage(@ModelAttribute("currentUser") CurrentUser currentUser) {
   LOGGER.debug("Getting messages page");
   return new ModelAndView(
       "messages", "messages", messageService.getAllMessages(currentUser.getUser()));
 }