package jp.ac.osaka_u.sparql;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import jp.ac.osaka_u.sanken.sparql.EndpointSettings;

/**
 * Servlet implementation class Initialize
 */
public class Initialize extends ServletBase {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Initialize() {
        super();
    }

	@Override
	protected void process(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession(true);

		init(request, response, session);
	}

	private void init(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws ServletException, IOException {
		EndpointSettings es = new EndpointSettings();
		es.setEndpoint((String)request.getParameter("endpoint"));
		es.setNamespaces((String)request.getParameter("namespaces"));
		session.setAttribute("session", es);


		response(request, response, "{\"result\":\"OK\"}");
		
		return;

	}
	
}
