package com.translationdata.messenger.resources;

import java.util.List;
import javax.ws.rs.GET;
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();
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Message> getMessages() {
		return messageService.getAllMessages();
	}
	
	@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);
	}
}

@@ -66,16 +66,17 @@
 l.List;%0A
+%0A
 import j
@@ -91,16 +91,41 @@
 rs.GET;%0A
+import javax.ws.rs.POST;%0A
 import j
@@ -548,16 +548,138 @@
 vice();%0A
+%09// Uncomment the JSON support, %3CartifactId%3Ejersey-media-moxy%3C/artifactId%3E, in the pom.xml to get JSON support working...%0A
 %09@GET%0A%09@
@@ -800,16 +800,122 @@
 );%0A%09%7D%0A%09%0A
+%09@POST%0A%09@Produces(MediaType.APPLICATION_JSON)%0A%09public String postMessage() %7B%0A%09%09return %22Post works!%22;%0A%09%7D%0A%09%0A
 %09@Path(%22

Add POST function