示例#1
0
 @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();
 }
示例#2
0
  @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();
  }
示例#3
0
  @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;
  }
示例#4
0
 @DELETE
 @Path("/{massageId}")
 public void deleteMessage(@PathParam("massageId") long id) {
   messageService.removeMessage(id);
 }
示例#5
0
 @PUT
 @Path("/{messageId}")
 public Message updateMessage(@PathParam("messageId") long id, Message message) {
   message.setId(id);
   return messageService.updateMessage(message);
 }