package com.translationdata.messenger.resources;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import com.translationdata.messenger.model.Message;
import com.translationdata.messenger.service.MessageService;

// Maps to http://localhost:8080/Messenger/webapi/messages, case sensitive application name.
@Path("/messages")
public class MessageResource {
	MessageService messageService = new MessageService();
	// Uncomment the JSON support, <artifactId>jersey-media-moxy</artifactId>, in the pom.xml to get JSON support working...
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Message> getMessages() {
		return messageService.getAllMessages();
	}
	
	@POST
	@Produces(MediaType.APPLICATION_JSON)
	public String postMessage() {
		return "Post works!";
	}
	
	@Path("/{messageId}")
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	// Jersey will cast the String to long...
	public Message getMessage(@PathParam("messageId") long id) {
		return messageService.getMessage(id);
	}
}

@@ -67,16 +67,45 @@
 .List;%0A%0A
+import javax.ws.rs.Consumes;%0A
 import j
@@ -836,16 +836,55 @@
 %0A%09@POST%0A
+%09@Consumes(MediaType.APPLICATION_JSON)%0A
 %09@Produc
@@ -922,22 +922,23 @@
 %09public 
-String
+Message
  postMes
@@ -946,34 +946,70 @@
 age(
-) %7B%0A%09%09return %22Post works!%22
+Message message) %7B%0A%09%09return messageService.addMessage(message)
 ;%0A%09%7D

Implement POST