summaryrefslogtreecommitdiff
path: root/Business Logic/trunk/src/org/cacert
diff options
context:
space:
mode:
authorMario Lipinski <Mario Lipinski@d4452222-2f33-11de-9270-010000000000>2009-05-14 01:37:37 +0000
committerMario Lipinski <Mario Lipinski@d4452222-2f33-11de-9270-010000000000>2009-05-14 01:37:37 +0000
commitc4d66f24bd1b85cf26df01cd484cfd68fdb6090f (patch)
tree8c386c83f1ba89092a6d8ea4fe7896f52f355a18 /Business Logic/trunk/src/org/cacert
parent939d8624c89b0bd02c0ba48c71150ed2f703ec3f (diff)
downloadcacert-birdshack-c4d66f24bd1b85cf26df01cd484cfd68fdb6090f.tar.gz
cacert-birdshack-c4d66f24bd1b85cf26df01cd484cfd68fdb6090f.tar.xz
cacert-birdshack-c4d66f24bd1b85cf26df01cd484cfd68fdb6090f.zip
getting started with the controller
git-svn-id: http://svn.cacert.cl/Software/BirdShack@32 d4452222-2f33-11de-9270-010000000000
Diffstat (limited to 'Business Logic/trunk/src/org/cacert')
-rw-r--r--Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java537
1 files changed, 528 insertions, 9 deletions
diff --git a/Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java b/Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java
index 87d0fe6..1ce69db 100644
--- a/Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java
+++ b/Business Logic/trunk/src/org/cacert/birdshack/bl/api/Controller.java
@@ -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);
+ }
+
+
}