package restservices.cloudstorage;

import javax.servlet.http.HttpServletRequest;
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;
import javax.ws.rs.core.Request;

@Path("/")
public class Application {

		private HashTable hash;
		
		/**
		 * Constructor for ScorersServices
		 */
		public Application() {
			// TODO: Read data from .txt
		}
		
		@POST
		@Path("/storeFile")
		public Response storeFile(String xml) {
			// TODO: Read data from xml and create Element, then send the Element to HashTable store it
			return null;
		}
		
		@GET
		@Path("/getFile/{key}")
		public Response getFile(@PathParam("key") String key) {
			// TODO: Search for key in HashTable
			return null;
		}
		
		@POST
		@Path("/delete/{key}")
		public Response delete(@PathParam("key") String key) {
			// TODO: Delete file with corresponding key from HashTable
			return null;
		}
		
		@GET
		@Produces(MediaType.TEXT_XML)
		@Path("/exportDatabase")
		public Response exportDatabase() {
			// TODO: Return all buckets files in one single xml 
//			Response resp = Response.ok(xml, MediaType.TEXT_XML).build();
			return null;
		}
		
		@POST
		@Path("/importDatabase")
		public Response importDatabase(String xml) {
			// TODO: Load xml on HashTable
			return null;
		}
}

@@ -44,43 +44,52 @@
 java
-x.servlet.http.HttpServletRequest
+.io.File;%0Aimport java.io.FileOutputStream
 ;%0A
+%0A
 impo
@@ -289,41 +289,8 @@
 nse;
-%0Aimport javax.ws.rs.core.Request;
 %0A%0A@P
@@ -634,35 +634,1289 @@
 store it%0A%09%09%09
-return null
+%0A%09%09%09%0A//%09%09%09%7B%22key%22:%22sample.txt%22,%22buf%22:%7B%22type%22:%22Buffer%22,%22data%22:%5B116,101,115,116,101%5D%7D%7D%0A%09%09%09String response = xml;%0A%09%09%09%0A%09%09%09String%5B%5D json = response.substring(1, response.length() - 1).split(%22%5C%22%22);%0A%09%09%09%0A%09%09%09int x = json.length - 1;%0A%09%09%09response = json%5Bx%5D;%0A%09%09%09%0A%09%09%09return Response.ok(response, MediaType.TEXT_PLAIN).build();%0A%09%09%7D%0A%09%09%0A%09%09@POST%0A//%09%09@Produces(MediaType.TEXT_XML)%0A%09%09@Path(%22/test%22)%0A%09%09public Response test(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%09%0A%09%09%09String response = %22%5B116,101,115,116,101%5D%22;%0A%0A%09%09%09String%5B%5D byteValues = response.substring(1, response.length() - 1).split(%22,%22);%0A%09%09%09byte%5B%5D bytes = new byte%5BbyteValues.length%5D;%0A%0A%09%09%09for (int i=0, len=bytes.length; i%3Clen; i++) %7B%0A%09%09%09   bytes%5Bi%5D = Byte.parseByte(byteValues%5Bi%5D.trim());     %0A%09%09%09%7D%0A%09%09%09%0A%09%09 %09File outputFile = new File(%22C:%5C%5CUsers%5C%5CLeonardo%5C%5CDesktop%5C%5CLeonardo%5C%5CUniWien%5C%5CCloudComputing%5C%5CCloudStorageClient%5C%5Coutput.txt%22);%0A%0A%09%09%09try %7B%0A%09%09%09%09FileOutputStream fileOuputStream = new FileOutputStream(outputFile);%0A%09%09%09%09    fileOuputStream.write(bytes);%0A%09%09%09%09    fileOuputStream.close();%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09// TODO Auto-generated catch block%0A//%09%09%09%09e.printStackTrace();%0A%09%09%09%7D finally %7B%7D %0A%09%09%09%0A%09%09%09return Response.ok(xml, MediaType.TEXT_PLAIN).build()
 ;%0A%09%09%7D%0A%09%09%0A%09%09@

Set application to receive xml file (no unmarshller)