1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.rest; |
22 |
|
|
23 |
|
import jalview.httpserver.AbstractRequestHandler; |
24 |
|
|
25 |
|
import java.io.IOException; |
26 |
|
import java.io.PrintWriter; |
27 |
|
import java.net.BindException; |
28 |
|
|
29 |
|
import javax.servlet.http.HttpServletRequest; |
30 |
|
import javax.servlet.http.HttpServletResponse; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
|
|
| 0% |
Uncovered Elements: 22 (22) |
Complexity: 6 |
Complexity Density: 0.43 |
|
35 |
|
public class RestHandler extends AbstractRequestHandler |
36 |
|
{ |
37 |
|
private static final String MY_PATH = "rest"; |
38 |
|
|
39 |
|
private static final String MY_NAME = "Rest"; |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
private static RestHandler instance = null; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
@return |
50 |
|
@throws |
51 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
52 |
0 |
public static RestHandler getInstance() throws BindException... |
53 |
|
{ |
54 |
0 |
synchronized (RestHandler.class) |
55 |
|
{ |
56 |
0 |
if (instance == null) |
57 |
|
{ |
58 |
0 |
instance = new RestHandler(); |
59 |
|
} |
60 |
|
} |
61 |
0 |
return instance; |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
@throws |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
private RestHandler() throws BindException... |
70 |
|
{ |
71 |
0 |
setPath(MY_PATH); |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
} |
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
@throws |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
85 |
0 |
@Override... |
86 |
|
protected void processRequest(HttpServletRequest request, |
87 |
|
HttpServletResponse response) throws IOException |
88 |
|
{ |
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
|
93 |
0 |
final String queryString = request.getQueryString(); |
94 |
0 |
final String reply = "REST not yet implemented; received " |
95 |
|
+ request.getMethod() + ": " + request.getRequestURL() |
96 |
0 |
+ (queryString == null ? "" : "?" + queryString); |
97 |
0 |
jalview.bin.Console.outPrintln(reply); |
98 |
|
|
99 |
0 |
response.setHeader("Cache-Control", "no-cache/no-store"); |
100 |
0 |
response.setHeader("Content-type", "text/plain"); |
101 |
0 |
final PrintWriter writer = response.getWriter(); |
102 |
0 |
writer.write(reply); |
103 |
0 |
writer.close(); |
104 |
|
} |
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
109 |
0 |
@Override... |
110 |
|
public String getName() |
111 |
|
{ |
112 |
0 |
return MY_NAME; |
113 |
|
} |
114 |
|
|
115 |
|
} |