portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts StrutsPortlet.java PortletServletRequestWrapper.java PortletServletRequestDispatcher.java
Date Fri, 28 Jan 2005 00:09:23 GMT
ate         2005/01/27 16:09:23

  Modified:    portals-bridges/struts/src/java/org/apache/portals/bridges/struts
                        StrutsPortlet.java
                        PortletServletRequestWrapper.java
                        PortletServletRequestDispatcher.java
  Removed:     portals-bridges/struts/src/java/org/apache/portals/bridges/struts/util
                        HttpRequestDispatcherImpl.java
                        DispatchedHttpServletRequestWrapper.java
  Log:
  Clean up of Struts Bridge now that http://issues.apache.org/jira/browse/JS2-9 is fixed.
  
  Revision  Changes    Path
  1.11      +5 -12     jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/StrutsPortlet.java
  
  Index: StrutsPortlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/StrutsPortlet.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StrutsPortlet.java	27 Jan 2005 13:52:41 -0000	1.10
  +++ StrutsPortlet.java	28 Jan 2005 00:09:23 -0000	1.11
  @@ -311,23 +311,17 @@
               }
                                   
               String path = null;
  -            String query_string = null;
               String pageURL = request.getParameter(StrutsPortletURL.PAGE);
               if (pageURL == null)
                   path = defaultPage;
               else
               {
  -                int index;
                   path = pageURL;
  -                if ((index = path.indexOf('?')) != -1)
  -                {
  -                    query_string = path.substring(index + 1);
  -                    path = path.substring(0, index);
  -                }
               }
  +
               if (log.isDebugEnabled())
  -                log.debug("process path: " + path + ", query string: "
  -                        + query_string + ", requestType: " + requestType);
  +                log.debug("process path: " + path + ", requestType: " + requestType);
  +
               RequestDispatcher rd = servletContext.getRequestDispatcher(path);
               if (rd != null)
               {
  @@ -338,8 +332,7 @@
                   req.setAttribute(StrutsPortlet.REQUEST_TYPE, requestType);
                   try
                   {
  -                    rd.include(new PortletServletRequestWrapper(servletContext,
  -                            req, query_string), res);
  +                    rd.include(new PortletServletRequestWrapper(servletContext, req), res);
                   } catch (ServletException e)
                   {
                       if (log.isErrorEnabled())
  
  
  
  1.2       +12 -11    jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServletRequestWrapper.java
  
  Index: PortletServletRequestWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServletRequestWrapper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PortletServletRequestWrapper.java	29 Jul 2004 22:16:40 -0000	1.1
  +++ PortletServletRequestWrapper.java	28 Jan 2005 00:09:23 -0000	1.2
  @@ -18,51 +18,52 @@
   import javax.servlet.RequestDispatcher;
   import javax.servlet.ServletContext;
   import javax.servlet.http.HttpServletRequest;
  +import javax.servlet.http.HttpServletRequestWrapper;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  -import org.apache.portals.bridges.struts.util.DispatchedHttpServletRequestWrapper;
  -
   /**
    * PortletServletRequestWrapper
    * 
    * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
    * @version $Id$
    */
  -public class PortletServletRequestWrapper
  -        extends
  -            DispatchedHttpServletRequestWrapper
  +public class PortletServletRequestWrapper extends HttpServletRequestWrapper
   {
  -    private static final Log log = LogFactory
  -            .getLog(PortletServletRequestWrapper.class);
  +    private static final Log log = LogFactory.getLog(PortletServletRequestWrapper.class);
       private ServletContext context;
  -    public PortletServletRequestWrapper(ServletContext context,
  -            HttpServletRequest request, String queryString)
  +    public PortletServletRequestWrapper(ServletContext context, HttpServletRequest request)
       {
  -        super(request, queryString);
  +        super(request);
           this.context = context;
       }
  +
       public String getPathInfo()
       {
           return (String) getAttribute("javax.servlet.include.path_info");
       }
  +
       public String getContextPath()
       {
           return (String) getAttribute("javax.servlet.include.context_path");
       }
  +
       public String getRequestURI()
       {
           return (String) getAttribute("javax.servlet.include.request_uri");
       }
  +
       public String getServletPath()
       {
           return (String) getAttribute("javax.servlet.include.servlet_path");
       }
  +
       public String getQueryString()
       {
           return (String) getAttribute("javax.servlet.include.query_string");
       }
  +
       public RequestDispatcher getRequestDispatcher(String relativePath)
       {
           // Below comment and workaround taken from
  
  
  
  1.4       +40 -13    jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServletRequestDispatcher.java
  
  Index: PortletServletRequestDispatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portals-bridges/struts/src/java/org/apache/portals/bridges/struts/PortletServletRequestDispatcher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PortletServletRequestDispatcher.java	20 Jan 2005 01:41:15 -0000	1.3
  +++ PortletServletRequestDispatcher.java	28 Jan 2005 00:09:23 -0000	1.4
  @@ -26,7 +26,6 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.portals.bridges.struts.util.HttpRequestDispatcherImpl;
   import org.apache.struts.Globals;
   import org.apache.struts.action.ActionForm;
   import org.apache.struts.action.ActionMessages;
  @@ -38,20 +37,22 @@
    * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
    * @version $Id$
    */
  -public class PortletServletRequestDispatcher extends HttpRequestDispatcherImpl
  +public class PortletServletRequestDispatcher implements RequestDispatcher
   {
  -    private static final Log log = LogFactory
  -            .getLog(PortletServletRequestDispatcher.class);
  +    private static final Log log = LogFactory.getLog(PortletServletRequestDispatcher.class);
  +    private RequestDispatcher dispatcher;
  +    private String path;
       private boolean named;
       
       public PortletServletRequestDispatcher(RequestDispatcher dispatcher,
               String path, boolean named)
       {
  -        super(dispatcher, path);
  +        this.dispatcher = dispatcher;
  +        this.path = path;
           this.named = named;
       }
       
  -    protected void invoke(ServletRequest request, ServletResponse response,
  +    private void invoke(ServletRequest request, ServletResponse response,
               boolean include) throws ServletException, IOException
       {
           String request_type = (String) request
  @@ -62,13 +63,13 @@
               if (log.isDebugEnabled())
               {
                   log.debug("saving " + (named ? "named " : " ")
  -                        + "dispatch to :" + getPath() + ", from "
  +                        + "dispatch to :" + path + ", from "
                           + request_type + " "
                           + StrutsPortletURL.getPageURL(request));
               }
               HttpServletRequest req = (HttpServletRequest) request;
               StrutsPortletRenderContext context = new StrutsPortletRenderContext();
  -            context.setPath(getPath());
  +            context.setPath(path);
               context.setDispatchNamed(named);
               ActionConfig actionConfig = (ActionConfig) request
                       .getAttribute(Globals.MAPPING_KEY);
  @@ -110,9 +111,9 @@
                   // catch Session already invalidated Exception
                   if (log.isDebugEnabled())
                   {
  -                    log.debug("Session invalidated: redirecting to: "+getPath()+" instead.");
  +                    log.debug("Session invalidated: redirecting to: "+path+" instead.");
                   }
  -                ((HttpServletResponse)response).sendRedirect(getPath());
  +                ((HttpServletResponse)response).sendRedirect(path);
               }
           } 
           else
  @@ -120,11 +121,37 @@
               if (log.isDebugEnabled())
               {
                   log.debug("invoking " + (named ? "named " : " ")
  -                        + " dispatch to :" + getPath() + ", from "
  +                        + " dispatch to :" + path + ", from "
                           + request_type + " "
                           + StrutsPortletURL.getPageURL(request));
               }
  -            super.invoke(request, response, true);
  +            dispatcher.include(request, response);
           }
       }
  +
  +    public void forward(ServletRequest request, ServletResponse response) throws ServletException,
IOException {
  +        if ( PortletServlet.isPortletRequest(request) )
  +        {
  +            invoke(request, response, false);
  +        }
  +        else
  +        {
  +            dispatcher.forward(request,response);
  +        }
  +    }
  +
  +    public void include(ServletRequest request, ServletResponse response) throws ServletException,
IOException {
  +        if ( PortletServlet.isPortletRequest(request) )
  +        {
  +            invoke(request, response, true);
  +        }
  +        else
  +        {
  +            dispatcher.include(request,response);
  +        }
  +    }
  +
  +    public String toString() {
  +        return dispatcher.toString();
  +    }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message