package restservices.cloudstorage;

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 javax.ws.rs.core.Response;

@Path("/")
public class Application {

		private HashTable hash;
		private String str;
		
		/**
		 * Constructor for ScorersServices
		 */
		public Application() {
			// TODO: Read data from .txt
			this.str = "alooo ";
		}
		
		@GET
		@Produces(MediaType.TEXT_HTML)
		@Path("/listAll")
		public String listAll() {
			return "<html> " + "<title>" + "Hello Jersey" + "</title>"
					+ "<body><h1>" + this.str + "</h1></body>" + "</html> ";
		}
		
		@POST
		@Path("/addElement/{id}")
		// TODO: Receive element data by param
		public Response addElement(@PathParam("id") int id) {
			return null;
		}
		
		@POST
		@Produces(MediaType.TEXT_HTML)
		@Path("/storeElement")
		// TODO: Receive element data by param
		public Response storeElement() {
			// TODO: read request
			this.str += "pegou!!!";
			Response resp = Response.ok("<html> " + "<title>" + "Hello Jersey" + "</title>" + "<body><h1>" + this.str + "</h1></body>" + "</html> ", MediaType.TEXT_HTML).build();
			return resp;
		}
}

@@ -29,16 +29,62 @@
 orage;%0A%0A
+import javax.servlet.http.HttpServletRequest;%0A
 import j
@@ -276,16 +276,49 @@
 esponse;
+%0Aimport javax.ws.rs.core.Request;
 %0A%0A@Path(
@@ -380,30 +380,8 @@
 sh;%0A
-%09%09private String str;%0A
 %09%09%0A%09
@@ -491,76 +491,20 @@
 t%0A%09%09
-%09this.str = %22alooo %22;%0A%09%09%7D%0A%09%09%0A%09%09@GET%0A%09%09@Produces(MediaType.TEXT_HTML)
+%7D%0A%09%09%0A%09%09@POST
 %0A%09%09@
@@ -510,23 +510,25 @@
 @Path(%22/
-listAll
+storeFile
 %22)%0A%09%09pub
@@ -535,149 +535,150 @@
 lic 
-String listAll() %7B%0A%09%09%09return %22%3Chtml%3E %22 + %22%3Ctitle%3E%22 + %22Hello Jersey%22 + %22%3C/title%3E%22%0A%09%09%09%09%09+ %22%3Cbody%3E%3Ch1%3E%22 + this.str + %22%3C/h1%3E%3C/body%3E%22 + %22%3C/html%3E %22
+Response storeFile(String xml) %7B%0A%09%09%09// TODO: Read data from xml and create Element, then send the Element to HashTable store it%0A%09%09%09return null
 ;%0A%09%09
@@ -677,35 +677,34 @@
 null;%0A%09%09%7D%0A%09%09%0A%09%09@
-POS
+GE
 T%0A%09%09@Path(%22/addE
@@ -703,66 +703,177 @@
 h(%22/
-addElement/%7Bid%7D%22)%0A%09%09// TODO: Receive element data by param
+getFile/%7Bkey%7D%22)%0A%09%09public Response getFile(@PathParam(%22key%22) String key) %7B%0A%09%09%09// TODO: Search for key in HashTable%0A%09%09%09return null;%0A%09%09%7D%0A%09%09%0A%09%09@POST%0A%09%09@Path(%22/delete/%7Bkey%7D%22)
 %0A%09%09p
@@ -891,18 +891,14 @@
 nse 
-addElement
+delete
 (@Pa
@@ -910,22 +910,89 @@
 am(%22
-id%22) int id) %7B
+key%22) String key) %7B%0A%09%09%09// TODO: Delete file with corresponding key from HashTable
 %0A%09%09%09
@@ -1010,27 +1010,26 @@
 ;%0A%09%09%7D%0A%09%09%0A%09%09@
-POS
+GE
 T%0A%09%09@Produce
@@ -1045,18 +1045,17 @@
 pe.TEXT_
-HT
+X
 ML)%0A%09%09@P
@@ -1064,63 +1064,24 @@
 h(%22/
-storeElement%22)%0A%09%09// TODO: Receive element data by param
+exportDatabase%22)
 %0A%09%09p
@@ -1099,20 +1099,22 @@
 nse 
-storeElement
+exportDatabase
 () %7B
@@ -1130,217 +1130,257 @@
 DO: 
-read request%0A%09%09%09this.str += %22pegou!!!%22;%0A%09%09%09Response resp = Response.ok(%22%3Chtml%3E %22 + %22%3Ctitle%3E%22 + %22Hello Jersey%22 + %22%3C/title%3E%22 + %22%3Cbody%3E%3Ch1%3E%22 + this.str + %22%3C/h1%3E%3C/body%3E%22 + %22%3C/html%3E %22, MediaType.TEXT_HTML).build();
+Return all buckets files in one single xml %0A//%09%09%09Response resp = Response.ok(xml, MediaType.TEXT_XML).build();%0A%09%09%09return null;%0A%09%09%7D%0A%09%09%0A%09%09@POST%0A%09%09@Path(%22/importDatabase%22)%0A%09%09public Response importDatabase(String xml) %7B%0A%09%09%09// TODO: Load xml on HashTable
 %0A%09%09%09
@@ -1386,20 +1386,20 @@
 %09return 
-resp
+null
 ;%0A%09%09%7D%0A%7D%0A

Set application to receive XML data from client applications + set methods structures