package idc;

import idc.main.command.*;
import idc.model.IdcCmd;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class IdcClientFrontController
 */
@WebServlet("*.down")
public class IdcDownFrontController extends HttpServlet {
	private static final long serialVersionUID = 1L;
    /**
     * @see HttpServlet#HttpServlet()
     */
    public IdcDownFrontController() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		// TODO Auto-generated method stub
		doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		response.setHeader("Pragma", "No-cache");
		response.setDateHeader("Expires", 0);
		response.setHeader("Cache-Control","no-Cache");
		response.setHeader("Cache-Control","no-store");
		response.setContentType("charset='utf-8'");
		
		request.setCharacterEncoding("UTF-8");
		String requestURI = request.getRequestURI();
		String contextPath = request.getContextPath();
		String cmdURI = requestURI.substring(contextPath.length());
		IdcCmd cmd = null;
		
		//공동 자료실 다운로드
		if (cmdURI.equals("/IdcShareBoardDown.down"))
		{
			cmd = new IdcShareBoardDownCmd();
			cmd.execute(request, response);
		}
		if(cmdURI.equals("/IdcShareBoardIDCheck.json"))
		{
			cmd = new IdcShareBoardDownCmd();
			cmd.execute(request, response);
		}
	}

}
