@GET
 public List<Message> getMessages(@BeanParam MessageFilterBean filterBean) {
   if (filterBean.getYear() > 0) {
     return messageService.getAllMessagesForYear(filterBean.getYear());
   }
   if (filterBean.getStart() >= 0 && filterBean.getSize() > 0) {
     return messageService.getMessagesPagitated(filterBean.getStart(), filterBean.getSize());
   }
   return messageService.getAllMessages();
 }
  @POST
  public Response addMessage(Message message, @Context UriInfo uriInfo) {
    Message newMessage = messageService.addMessage(message);
    String newId = String.valueOf(newMessage.getId());
    URI uri = uriInfo.getAbsolutePathBuilder().path(newId).build();

    return Response.created(uri).entity(newMessage).build();
  }
  @GET
  @Path("/{messageId}")
  public Message getMessage(@PathParam("messageId") long id, @Context UriInfo uriInfo) {
    Message message = messageService.getMessage(id);

    message.addLinks(getAbsolutePath(uriInfo), "self");
    message.addLinks(getProfileUri(uriInfo, message), "profile");
    message.addLinks(getCommntUri(uriInfo, message), "comments");

    return message;
  }
 @DELETE
 @Path("/{massageId}")
 public void deleteMessage(@PathParam("massageId") long id) {
   messageService.removeMessage(id);
 }
 @PUT
 @Path("/{messageId}")
 public Message updateMessage(@PathParam("messageId") long id, Message message) {
   message.setId(id);
   return messageService.updateMessage(message);
 }