package jeus_jspwork._moniter._search;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.io.*;
import java.util.*;
import org.kldp.ebmsh.message.packaging.EbxmlMessage;
import org.kldp.ebmsh.message.util.Serializer;
import org.kldp.ebmsh.config.EbmsConstants;
import org.kldp.ebmsh.application.NonBlockingApplicationProcesser;
import org.kldp.ebmsh.tracker.Tracker;
import org.kldp.ebmsh.moniter.permission.PermissionManager;
import org.kldp.ebmsh.moniter.permission.PermissionManager;
import org.kldp.ebmsh.config.EbmsConstants;

public final class _500_applicationLayerProcess_5fjsp extends jeus.servlet.jsp2.runtime.HttpJspBase
    implements jeus.servlet.jsp2.runtime.JspSourceDependent {

  private static java.util.Vector _jspx_dependants;

  static {
    _jspx_dependants = new java.util.Vector(2);
    _jspx_dependants.add("/authorize/loginCheck.jsp");
    _jspx_dependants.add("/setup/setupCheck.jsp");
  }

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;


    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=euc-kr");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

	if( !PermissionManager.isAdminLogin(session) ) {

      out.write("\r\n");
      out.write("\t\t<script language=\"JavaScript\">\r\n");
      out.write("\t\t\tdocument.location.href = '");
      out.print( request.getContextPath() );
      out.write("/authorize/login.jsp';\r\n");
      out.write("\t\t</script>\r\n");
	
		return ;
	}

      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");
      out.write("\r\n");

	if( !EbmsConstants.configured ) {

      out.write("\r\n");
      out.write("\t\t<script language=\"JavaScript\">\r\n");
      out.write("\t\t\tdocument.location.href = '");
      out.print( request.getContextPath() );
      out.write("/setup/setup.jsp';\r\n");
      out.write("\t\t</script>\r\n");
	
		return ;
	}

      out.write("\r\n");
      out.write("\r\n");

	String messageId = request.getParameter("messageId");
	String messagePath = request.getParameter("messagePath");
	
	FileInputStream fin = new FileInputStream(EbmsConstants.messagePath + new File(messagePath));
	EbxmlMessage msg = Serializer.deserialize(fin);

	fin.close();

	Tracker.tracking(messageId, new Date(), "사용자가 재처리를 실행했습니다", "사용자가 재처리를 실행했습니다");

	new NonBlockingApplicationProcesser().process(msg);

      out.write("\r\n");
      out.write("\r\n");
      out.write("<script language=\"JavaScript\">\r\n");
      out.write("\talert('메시지 재처리를 요청했습니다');\r\n");
      out.write("\t\r\n");
      out.write("\thistory.go(-1);\r\n");
      out.write("</script>");
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }
}
