View Javadoc

1   /*
2    * Copyright 2000-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.portals.bridges.struts;
17  
18  import java.io.IOException;
19  
20  import javax.servlet.ServletException;
21  import javax.servlet.http.HttpServletRequest;
22  import javax.servlet.http.HttpServletResponse;
23  
24  import org.apache.struts.action.ActionMapping;
25  import org.apache.struts.tiles.TilesRequestProcessor;
26  
27  /***
28   * PortletTilesRequestProcessor
29   * 
30   * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
31   * @version $Id: PortletTilesRequestProcessor.java 188271 2005-01-27 14:38:43 +0100 (Thu, 27 Jan 2005) ate $
32   */
33  public class PortletTilesRequestProcessor extends TilesRequestProcessor 
34  {
35      public PortletTilesRequestProcessor()
36      {
37          super();
38      }
39  
40      public void process(HttpServletRequest request, HttpServletResponse response)
41              throws IOException, ServletException
42      {
43          if (PortletServlet.isPortletRequest(request))
44          {
45              if (!(response instanceof PortletServletResponseWrapper))
46              {
47                  response = new PortletServletResponseWrapper(request, response);
48              }
49          }
50          super.process(request, response);
51      }
52      protected boolean processRoles(HttpServletRequest request,
53              HttpServletResponse response, ActionMapping mapping)
54              throws IOException, ServletException
55      {
56          boolean proceed = super.processRoles(request, response, mapping);
57          if (proceed &&
58                  PortletServlet.isPortletRequest(request) &&
59                  ((PortletServlet) super.servlet).performActionRenderRequest(request, response, mapping))
60          {
61              return false;
62          } else
63              return proceed;
64      }
65  }