getting started with the controller
authorMario Lipinski <Mario Lipinski@d4452222-2f33-11de-9270-010000000000>
Thu, 14 May 2009 01:37:37 +0000 (01:37 +0000)
committerMario Lipinski <Mario Lipinski@d4452222-2f33-11de-9270-010000000000>
Thu, 14 May 2009 01:37:37 +0000 (01:37 +0000)
git-svn-id: http://svn.cacert.cl/Software/BirdShack@32 d4452222-2f33-11de-9270-010000000000

Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java

index 87d0fe6..1ce69db 100644 (file)
@@ -4,7 +4,6 @@
 package org.cacert.birdshack.bl.api;
 
 import java.io.IOException;
-import java.io.PrintWriter;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -13,21 +12,541 @@ import javax.servlet.http.HttpServletResponse;
 
 /**
  * @author law
- *
+ * 
  */
 public class Controller extends HttpServlet {
-
        /**
         * 
         */
-       private static final long serialVersionUID = 1L;
+       private static final long serialVersionUID = 2942637779582104096L;
+       
+       private void handleRequest(HttpServletRequest req, HttpServletResponse resp, String uri)
+                       throws IOException {
+               String resource = null;
+               String id = null;
+               String function = null;
+               String args = null;
+               
+               resp.getOutputStream().println(req.getMethod()+" "+req.getRequestURI()+"?"+req.getQueryString()+"\n\n");
 
-       protected void doGet(HttpServletRequest req, HttpServletResponse resp)
-                       throws ServletException, IOException {
-        resp.setContentType("text/plain");
-        PrintWriter out = resp.getWriter();
-        out.println("Test");
+               String splituri[] = req.getRequestURI().split("\\/", 5);
+               if(splituri.length > 1)
+                       resource = splituri[1];
+               if(splituri.length > 2)
+                       id = splituri[2];
+               if(splituri.length > 3)
+                       function = splituri[3];
+               if(splituri.length > 4)
+                       args = splituri[4];
+               
+               resp.getOutputStream().println(resource);
+               resp.getOutputStream().println(id);
+               resp.getOutputStream().println(function);
+               resp.getOutputStream().println(args);
+
+               if(resource.equals("member")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               if(function == null) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("DELETE")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(args == null) {
+                                       if(function.equals("privacy")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("PUT")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("emailaddress")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("PUT")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("assurance")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("profile")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("experience")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("role")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("credential")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("log")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("notification")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else if(function.equals("token")) {
+                                               if(req.getMethod().equals("GET")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else if(req.getMethod().equals("POST")) {
+                                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                               } else {
+                                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                               }
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                                       }
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                               }
+                       }
+               } else if(resource.equals("profile")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(args == null) {
+                               if(function == null) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("DELETE")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("permisssion")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("email")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("credential")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("delegation")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("dob")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("PUT")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("name")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("assurance")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("credential")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("notification")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("token")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("email")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("domain")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("delegation")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("name")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("application")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function.equals("member")) {
+                               if(args == null) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("POST")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else {
+                                       if(req.getMethod().equals("PUT")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else if(req.getMethod().equals("DELETE")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("event")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("role")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function != null && args == null) {
+                               if(function.equals("member")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else if(function.equals("permission")) {
+                                       if(req.getMethod().equals("GET")) {
+                                               resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                                       } else {
+                                               resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                                       }
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("permission")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else if(function == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("PUT")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("DELETE")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else if(resource.equals("authenticate")) {
+                       if(id == null) {
+                               if(req.getMethod().equals("GET")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else if(req.getMethod().equals("POST")) {
+                                       resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, "This function is not implemented yet");
+                               } else {
+                                       resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "The requested action is not available on the requested resource");
+                               }
+                       } else {
+                               resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "The requested is invalid");
+                       }
+               } else {
+                       resp.sendError(HttpServletResponse.SC_NOT_FOUND, "The requested resource does not exists");
+               }
        }
        
+       private void handleRequest(HttpServletRequest req, HttpServletResponse resp)
+                       throws IOException {
+               handleRequest(req, resp, req.getRequestURI());
+       }
        
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doDelete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doDelete(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+       /* (non-Javadoc)
+        * @see javax.servlet.http.HttpServlet#doPut(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
+        */
+       @Override
+       protected void doPut(HttpServletRequest req, HttpServletResponse resp)
+                       throws ServletException, IOException {
+               handleRequest(req, resp);
+       }
+
+
 }