From 723d2f2bfbb0a7f2e4c34cd9a22af471dbc2ba8f Mon Sep 17 00:00:00 2001 From: clemenso Date: Fri, 21 Aug 2009 16:01:36 +0000 Subject: PINManagementRequest, QuitRequest new help git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@463 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- .../bku/local/webapp/PINManagementServlet.java | 89 +++++----------------- 1 file changed, 18 insertions(+), 71 deletions(-) (limited to 'BKULocal/src/main/java/at/gv/egiz/bku/local') diff --git a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java index 89e526ac..0c35f1c9 100644 --- a/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java +++ b/BKULocal/src/main/java/at/gv/egiz/bku/local/webapp/PINManagementServlet.java @@ -17,30 +17,20 @@ package at.gv.egiz.bku.local.webapp; import at.gv.egiz.bku.local.stal.LocalSTALFactory; -import at.gv.egiz.marshal.MarshallerFactory; import at.gv.egiz.stal.QuitRequest; -import at.gv.egiz.stal.STALRequest; +import at.gv.egiz.stal.STAL; import at.gv.egiz.stal.STALResponse; import at.gv.egiz.stal.ext.PINManagementRequest; -import at.gv.egiz.stal.ext.PINManagementResponse; import java.io.IOException; -import java.io.PrintWriter; import java.net.URL; -import java.util.ArrayList; import java.util.Collections; -import java.util.Enumeration; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBElement; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Marshaller; -import org.apache.regexp.REUtil; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; /** * PINManagementBKUWorker for non-applet version @@ -48,8 +38,15 @@ import org.apache.regexp.REUtil; */ public class PINManagementServlet extends HttpServlet { -// static JAXBContext stalCtx; - + private static final Log log = LogFactory.getLog(PINManagementServlet.class); + + LocalSTALFactory stalFactory; + + public PINManagementServlet() { + stalFactory = new LocalSTALFactory(); + stalFactory.setHelpURL("http://localhost:3495/help/"); + } + /** * Processes requests for both HTTP GET and POST methods. * @param request servlet request @@ -60,13 +57,12 @@ public class PINManagementServlet extends HttpServlet { protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { - LocalSTALFactory sf = new LocalSTALFactory(); - - ArrayList stalReqs = new ArrayList(); - stalReqs.add(new PINManagementRequest()); - stalReqs.add(new QuitRequest()); - - List stalResps = sf.createSTAL().handleRequest(stalReqs); + STAL pinMgmtSTAL = stalFactory.createSTAL(); + List stalResps = pinMgmtSTAL.handleRequest(Collections.singletonList(new PINManagementRequest())); + if (log.isDebugEnabled()) { + log.debug("received STAL reponse " + stalResps.get(0).getClass()); + } + pinMgmtSTAL.handleRequest(Collections.singletonList(new QuitRequest())); String redirect = request.getParameter("redirect"); if (redirect != null) { @@ -77,56 +73,7 @@ public class PINManagementServlet extends HttpServlet { response.sendRedirect(redirect); } else { response.setStatus(HttpServletResponse.SC_OK); -// if (stalResps.get(0) != null) { -// PrintWriter out = response.getWriter(); -// try { -// response.setContentType("text/xml;charset=UTF-8"); -// // cannot directly marshal STALResponse, no ObjectFactory in at.gv.egiz.stal -// if (stalCtx == null) { -// stalCtx = JAXBContext.newInstance("at.gv.egiz.stal:at.gv.egiz.stal.ext"); -// } -// Marshaller m = MarshallerFactory.createMarshaller(stalCtx); -// m.marshal(stalResps.get(0), out); -// out.close(); -// } catch (JAXBException ex) { -// throw new ServletException("Failed to marshal STAL response", ex); -// } finally { -// out.close(); -// } -// } else { -// throw new ServletException("internal error"); -// } } - - -// try { -// out.println(""); -// out.println(""); -// out.println("Servlet PINManagementServlet"); -// out.println(""); -// out.println(""); -// out.println("

Servlet PINManagementServlet at " + request.getContextPath() + "

"); -// out.println("

" + stalResps.size() + " responses:

    "); -// for (STALResponse resp : stalResps) { -// out.println("
  • " + resp.getClass()); -// } -// Enumeration headers = request.getHeaderNames(); -// out.println("

headers:

    "); -// while (headers.hasMoreElements()) { -// String header = headers.nextElement(); -// out.println("
  • " + header + ": " + request.getHeader(header)); -// } -// Enumeration params = request.getParameterNames(); -// out.println("

params:

    "); -// while (params.hasMoreElements()) { -// String param = params.nextElement(); -// out.println("
  • " + param + ": " + request.getParameter(param)); -// } -// out.println("

"); -// out.println(""); -// } finally { -// out.close(); -// } } // -- cgit v1.2.3