Commit cfa10ffe cfa10ffe0301792a7cdebbabde178c05028db0b6 by Christian Gerdes

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. 
1 parent 58fad132
1 /readme.txt
2 /OraMonREST.class
1 java -jar jetty-runner-9.2.9.v20150224.jar --log access.log --out systemout.log JavaMonWeb.war
2 pause
...\ No newline at end of file ...\ No newline at end of file
1 java -jar jetty-runner-9.3.7.v20160115.jar --log access.log --out systemout.log JavaMonWeb.war 1 java -jar jetty-runner-9.3.7.v20160115.jar --log access.log --out systemout.log JavaMonWeb.war
2 pause
...\ No newline at end of file ...\ No newline at end of file
......
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 }