/** * 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: AsynchronousDataResponder.java,v 1.3 2006/08/30 14:02:35 wprinz Exp $ */ package at.knowcenter.wag.egov.egiz.web; import java.io.IOException; import java.util.Enumeration; import java.util.List; import java.util.Properties; 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 org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.log4j.Logger; import at.knowcenter.wag.egov.egiz.cfg.ConfigLogger; import at.knowcenter.wag.egov.egiz.cfg.SettingsReader; import at.knowcenter.wag.egov.egiz.sig.connectors.BKUPostConnection; /** * Servlet that responds to the data post requests of the local service (e.g. * BKU). * * @deprecated * * @author wprinz */ public class AsynchronousDataResponder extends HttpServlet { /** * SVUID. */ private static final long serialVersionUID = -4992297156381763174L; // /** // * The logger definition. // */ // private static final Logger logger_ = ConfigLogger.getLogger(AsynchronousDataResponder.class); // // protected void doGet(HttpServletRequest arg0, HttpServletResponse arg1) throws ServletException, IOException // { // logger_.debug("AsyncDataResp GET REQUEST."); // super.doGet(arg0, arg1); // } // // protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException // { // logger_.debug("AsyncDataResp !!!!!!!!!!!!!!!!!!!!!!"); // // HttpSession session = request.getSession(false); // if (session == null) // { // throw new ServletException("There is no session associated with this request."); // } // // // String session_id_string = request.getParameter("session"); // // if (session_id_string == null) // // { // // throw new ServletException("The session parameter is missing."); // // } // // SessionInformation si = (SessionInformation) session.getAttribute(SessionAttributes.ATTRIBUTE_SESSION_INFORMATION); // // long session_id = Long.parseLong(session_id_string); // // SessionInformation si = SessionTable.get(session_id); // if (si == null) // { // throw new ServletException("The session is not found or no longer valid."); // } // // // InputStream is = request.getInputStream(); // // byte [] data = new byte[request.getContentLength()]; // // is.read(data); // // is.close(); // // String enc = request.getCharacterEncoding(); // // String ct = request.getContentType(); // // Enumeration enum = request.getHeaderNames(); // // // // String dat = new String(data, "US-ASCII"); // // // dat looks like: XMLResponse=blablabla ... // // // so the actual XMLResponse begins after the = // // String resp = URLDecoder.decode(dat, "UTF-8"); // // logger_.debug("Answer from local service: content-type = '" + request.getContentType() + "', character encoding = '" + request.getCharacterEncoding() + "'"); // // // .getParameter will use the character encoding specified by the // // content-type header. // // Unfortunately BKU forgets to specify a chatacter encoding. // // Therefor, .getParameter will assume US-ASCII or something. // // ==> we explicitely set UTF-8 // if (request.getCharacterEncoding() == null) // { // request.setCharacterEncoding("UTF-8"); // logger_.debug(" no character encoding specified - set to UTF-8"); // } // // logger_.debug("AsyncDataResponder: si.current_operation = " + si.current_operation); // // String resp_string = request.getParameter("XMLResponse"); // if (resp_string == null) // { // logger_.debug("response String is null => trying multipart form"); // // DiskFileItemFactory fif = new DiskFileItemFactory(); // fif.setRepository(SettingsReader.getTemporaryDirectory()); // ServletFileUpload sfu = new ServletFileUpload(fif); // // try // { // List items = sfu.parseRequest(request); // // for (int i = 0; i < items.size(); i++) // { // FileItem item = (FileItem) items.get(i); // logger_.debug("item = " + item.getFieldName()); // // if (item.getFieldName().equals("XMLResponse")) // { // resp_string = item.getString("UTF-8"); // } // } // } // catch (FileUploadException e) // { // throw new ServletException("File Upload exception. cannot parse POST data"); // } // // } // // // TODO hotfix - already deprecated // if (logger_.isDebugEnabled()) // { // Enumeration header_names = request.getHeaderNames(); // while (header_names.hasMoreElements()) // { // String header_name = (String)header_names.nextElement(); // String header_value = request.getHeader(header_name); // logger_.debug("header: name = " + header_name + ", value = " +header_value); // } // } // String user_agent = request.getHeader("User-Agent"); // logger_.debug("User-Agent header = " + user_agent); // Properties response_properties = new Properties(); // BKUPostConnection.parseBKUVersion(user_agent, response_properties); // response_properties.setProperty("response_string", resp_string); // si.response_properties[si.current_operation] = response_properties; //request.getParameter("XMLResponse"); // //logger_.debug("AsyncDataResponder: si.response_string[si.current_operation] = " + si.response_string[si.current_operation]); // // si.current_operation++; // // si.finished = true; // // LocalRequestHelper.formatBKUOkResponse(response); // } }