1 | package geniusweb.runserver;
|
---|
2 |
|
---|
3 | import java.io.IOException;
|
---|
4 | import java.util.HashMap;
|
---|
5 | import java.util.Map;
|
---|
6 |
|
---|
7 | import javax.servlet.ServletException;
|
---|
8 | import javax.servlet.http.HttpServlet;
|
---|
9 | import javax.servlet.http.HttpServletRequest;
|
---|
10 | import javax.servlet.http.HttpServletResponse;
|
---|
11 |
|
---|
12 | import com.fasterxml.jackson.databind.ObjectMapper;
|
---|
13 |
|
---|
14 | import geniusweb.protocol.NegoSettings;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Contains incoming connection to run a Nego. runserver/runsession with the
|
---|
18 | * JSON {@link NegoSettings} in the request header. After the session is
|
---|
19 | * started, the new Nego ID is returned. This can be used to find back the log
|
---|
20 | * files..
|
---|
21 | */
|
---|
22 | @SuppressWarnings("serial")
|
---|
23 | public class Info extends HttpServlet {
|
---|
24 | private final static ObjectMapper jackson = new ObjectMapper();
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
|
---|
28 | * response).
|
---|
29 | *
|
---|
30 | * @return the ID of the new started run. Or SC_BAD_REQUEST if the request
|
---|
31 | * can not be processed.
|
---|
32 | */
|
---|
33 | @Override
|
---|
34 | protected void doGet(HttpServletRequest request,
|
---|
35 | HttpServletResponse response) throws ServletException, IOException {
|
---|
36 | response.setContentType("text/plain");
|
---|
37 | // HACK but should be generizable easy in the future.
|
---|
38 | Map<String, Object> info = new HashMap<>();
|
---|
39 | info.put("version", getClass().getPackage().getImplementationVersion());
|
---|
40 | response.getWriter().append(jackson.writeValueAsString(info));
|
---|
41 | }
|
---|
42 |
|
---|
43 | }
|
---|