package geniusweb.runserver; import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import com.fasterxml.jackson.databind.ObjectMapper; import geniusweb.protocol.NegoSettings; /** * Contains incoming connection to run a Nego. runserver/runsession with the * JSON {@link NegoSettings} in the request header. After the session is * started, the new Nego ID is returned. This can be used to find back the log * files.. */ @SuppressWarnings("serial") public class Info extends HttpServlet { private final static ObjectMapper jackson = new ObjectMapper(); /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse * response). * * @return the ID of the new started run. Or SC_BAD_REQUEST if the request * can not be processed. */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); // HACK but should be generizable easy in the future. Map info = new HashMap<>(); info.put("version", getClass().getPackage().getImplementationVersion()); response.getWriter().append(jackson.writeValueAsString(info)); } }