[jboss-svn-commits] JBoss Portal SVN: r5364 - trunk/server/src/main/org/jboss/portal/server/servlet

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Oct 8 19:39:48 EDT 2006


Author: julien at jboss.com
Date: 2006-10-08 19:39:46 -0400 (Sun, 08 Oct 2006)
New Revision: 5364

Modified:
   trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
Log:
minor simplification

Modified: trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java	2006-10-08 23:31:19 UTC (rev 5363)
+++ trunk/server/src/main/org/jboss/portal/server/servlet/PortalServlet.java	2006-10-08 23:39:46 UTC (rev 5364)
@@ -65,6 +65,12 @@
 public class PortalServlet extends HttpServlet
 {
 
+   /** . */
+   private static final int GET_METHOD = 0;
+
+   /** . */
+   private static final int POST_METHOD = 1;
+
    /** The serialVersionUID */
    private static final long serialVersionUID = -4311718750030972662L;
 
@@ -134,16 +140,6 @@
       return interceptorStack;
    }
 
-   protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
-   {
-      process(req, resp, false);
-   }
-
-   protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
-   {
-      process(req, resp, true);
-   }
-
    private String retrieveMediaType(String contentType)
    {
       String mediaType = contentType;
@@ -167,13 +163,27 @@
       return mediaType;
    }
 
-   protected void process(final HttpServletRequest req, final HttpServletResponse resp, boolean isGet) throws ServletException, IOException
+   protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
+      int method;
+      if ("GET".equals(req.getMethod()))
+      {
+         method = GET_METHOD;
+      }
+      else if ("POST".equals(req.getMethod()))
+      {
+         method = POST_METHOD;
+      }
+      else
+      {
+         throw new ServletException();
+      }
+
       // Compute the media type in the content type
       String mediaType = retrieveMediaType(req.getContentType());
 
       // Only affect the charset encoding if the servlet container will decode the request
-      if (isGet == false && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
+      if (method == POST_METHOD && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
       {
          // Now we must ensure that we have either an equals or a trailing space after the media-type
          String characterEncoding = req.getCharacterEncoding();
@@ -253,10 +263,8 @@
 
       //
       Map bodyParameterMap = null;
-      if (isGet == false && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
+      if (method == POST_METHOD && PortalConstants.APPLICATION_X_WWW_FORM_URLENCODED.equals(mediaType))
       {
-
-         //
          bodyParameterMap = new HashMap();
          for (Iterator i = req.getParameterMap().entrySet().iterator(); i.hasNext();)
          {




More information about the jboss-svn-commits mailing list