/** * Copyright (c) 2006 by Know-Center, Graz, Austria * * This software is the confidential and proprietary information of Know-Center, * Graz, Austria. You shall not disclose such Confidential Information and shall * use it only in accordance with the terms of the license agreement you entered * into with Know-Center. * * KNOW-CENTER MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR * NON-INFRINGEMENT. KNOW-CENTER SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY * LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. * * $Id: SignPreview.java,v 1.2 2006/10/11 07:39:13 wprinz Exp $ */ package at.knowcenter.wag.egov.egiz.web; import java.io.IOException; import javax.servlet.RequestDispatcher; 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 at.knowcenter.wag.egov.egiz.exceptions.ErrorCodeException; import at.knowcenter.wag.egov.egiz.exceptions.PresentableException; /** * @author wprinz */ public class SignPreview extends HttpServlet { /** * SVUID. */ private static final long serialVersionUID = -8818532511322299998L; protected void dispatch(HttpServletRequest request, HttpServletResponse response, String resource) throws ServletException, IOException { response.setContentType("text/html"); response.setCharacterEncoding("UTF-8"); RequestDispatcher disp = getServletContext().getRequestDispatcher(resource); disp.forward(request, response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { SessionInformation si = null; HttpSession session = null; try { session = request.getSession(false); // String session_id_string = request.getParameter("session"); if (session == null) { throw new ErrorCodeException(600, "The session is missing."); } si = (SessionInformation) session.getAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION); // long session_id = Long.parseLong(session_id_string); // si = SessionTable.get(session_id); if (si == null) { throw new ErrorCodeException(600, "The session is not found or is no longer valid."); } } catch (PresentableException e) { e.printStackTrace(); Sign.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); return; } try { String preview = request.getParameter(FormFields.FIELD_PREVIEW); if (preview != null && preview.equals(FormFields.VALUE_TRUE)) { response.setContentType("application/pdf"); response.getOutputStream().write(si.iui.signed_pdf); return; } else { Sign.finishSign(si, request, response, getServletContext()); } } catch (PresentableException e) { e.printStackTrace(); Sign.prepareDispatchToErrorPage(e, request); dispatch(request, response, "/jsp/error.jsp"); } } }