Skapat en servlet istället som heter OraMonREST som inte behöver
kompileras (jsp sidor kräver en jdk installerad). Tog även ner jetty 9.2.9 som funkar med jre7.
Showing
6 changed files
with
90 additions
and
0 deletions
JavaMonWeb/build/classes/.gitignore
0 → 100644
No preview for this file type
JavaMonWeb/jetty/JavaMonWeb_jre7.bat
0 → 100644
No preview for this file type
JavaMonWeb/src/OraMonREST.java
0 → 100644
1 | |||
2 | |||
3 | import java.io.IOException; | ||
4 | import java.io.PrintWriter; | ||
5 | |||
6 | import javax.servlet.ServletException; | ||
7 | import javax.servlet.annotation.WebServlet; | ||
8 | import javax.servlet.http.HttpServlet; | ||
9 | import javax.servlet.http.HttpServletRequest; | ||
10 | import javax.servlet.http.HttpServletResponse; | ||
11 | |||
12 | import se.lil.om.Registry; | ||
13 | |||
14 | /** | ||
15 | * Servlet implementation class OraMonREST | ||
16 | */ | ||
17 | @WebServlet(description = "REST API for OraMon", urlPatterns = { "/OraMonREST" }) | ||
18 | public class OraMonREST extends HttpServlet { | ||
19 | private static final long serialVersionUID = 1L; | ||
20 | |||
21 | /** | ||
22 | * @see HttpServlet#HttpServlet() | ||
23 | */ | ||
24 | public OraMonREST() { | ||
25 | super(); | ||
26 | // TODO Auto-generated constructor stub | ||
27 | } | ||
28 | |||
29 | /** | ||
30 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | ||
31 | */ | ||
32 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
33 | response.setContentType("application/json"); | ||
34 | StringBuffer sb = new StringBuffer(); | ||
35 | if(request.getParameterMap().containsKey("connectionString")) { | ||
36 | // We have a connection string, find the monitor or create it and call getData() on the monitor | ||
37 | // Check that we have a valid connection string | ||
38 | String[] conStrParamArray = request.getParameter("connectionString").split(":"); | ||
39 | if(conStrParamArray.length != 5) { | ||
40 | // Error, we need 3 parts in the con string | ||
41 | response.sendError(HttpServletResponse.SC_BAD_REQUEST, "connectionString needs to be in format host:port:sid:username:password"); | ||
42 | return; | ||
43 | } | ||
44 | String conStr = "jdbc:oracle:thin:@" + conStrParamArray[0] + ":" + conStrParamArray[1] + ":" + conStrParamArray[2]; | ||
45 | String userStr = conStrParamArray[3]; | ||
46 | String passStr = conStrParamArray[4]; | ||
47 | |||
48 | } else { | ||
49 | // No input, just return the list of monitors | ||
50 | sb.append("{\"count\":" + Registry.getList().size() + "}"); | ||
51 | } | ||
52 | |||
53 | PrintWriter out = response.getWriter(); | ||
54 | out.println(sb.toString()); | ||
55 | } | ||
56 | |||
57 | /** | ||
58 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) | ||
59 | */ | ||
60 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
61 | // TODO Auto-generated method stub | ||
62 | } | ||
63 | |||
64 | /** | ||
65 | * @see HttpServlet#doPut(HttpServletRequest, HttpServletResponse) | ||
66 | */ | ||
67 | protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
68 | // TODO Auto-generated method stub | ||
69 | } | ||
70 | |||
71 | /** | ||
72 | * @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse) | ||
73 | */ | ||
74 | protected void doDelete(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
75 | // TODO Auto-generated method stub | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * @see HttpServlet#doHead(HttpServletRequest, HttpServletResponse) | ||
80 | */ | ||
81 | protected void doHead(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | ||
82 | // TODO Auto-generated method stub | ||
83 | } | ||
84 | |||
85 | } |
-
Please register or sign in to post a comment