portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject cvs commit: jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container JetspeedContainerServlet.java
Date Tue, 02 Nov 2004 22:58:14 GMT
taylor      2004/11/02 14:58:14

  Modified:    commons/src/java/org/apache/jetspeed/container
                        JetspeedContainerServlet.java
  Log:
  Handle errors for Velocity portlets
  
  Revision  Changes    Path
  1.18      +27 -17    jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java
  
  Index: JetspeedContainerServlet.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/commons/src/java/org/apache/jetspeed/container/JetspeedContainerServlet.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JetspeedContainerServlet.java	20 Aug 2004 05:06:41 -0000	1.17
  +++ JetspeedContainerServlet.java	2 Nov 2004 22:58:13 -0000	1.18
  @@ -216,8 +216,8 @@
               }
               
               PortletDefinition portletDefinition = JetspeedPortletFactoryProxy.getCurrentPortletDefinition();
                       
  -            Portlet portlet = JetspeedPortletFactoryProxy.getPortlet(this.getServletConfig(),
portletDefinition);
               portletName = portletDefinition.getName();
  +            Portlet portlet = JetspeedPortletFactoryProxy.getPortlet(this.getServletConfig(),
portletDefinition);
   
               if (method == ContainerConstants.METHOD_ACTION)
               {
  @@ -236,7 +236,6 @@
   
               // if we get this far we are home free
               return;
  -
           }
           catch (Throwable t)
           {
  @@ -249,30 +248,41 @@
                   {
                       errorTemplate = "/WEB-INF/templates/generic/html/error.vm";
                   }
  -                RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(errorTemplate);
  -                request.setAttribute("e", t);
  -                StringWriter stackTrace = new StringWriter();
  -                t.printStackTrace(new PrintWriter(stackTrace));
  -                request.setAttribute("stacktrace", stackTrace.toString());
  -                dispatcher.include(request, response);
  -
  +                if (null != context.getResource(errorTemplate))
  +                {
  +                    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(errorTemplate);
               
  +                    request.setAttribute("e", t);
  +                    StringWriter stackTrace = new StringWriter();
  +                    t.printStackTrace(new PrintWriter(stackTrace));
  +                    request.setAttribute("stacktrace", stackTrace.toString());
  +                    dispatcher.include(request, response);
  +                }
  +                else
  +                {
  +                    displayPortletNotAvailableMessage(t, response, portletName);
  +                }
               }
  -            catch (Exception e)
  +            catch (Throwable e)
               {
  -                context.log(JCS + "Error rendering JetspeedContainerServlet error page:
" + e.toString(), e);                
  -                PrintWriter directError = new PrintWriter(response.getWriter());
  -                directError.write("Error Rendering portlet: " + portletName + ": " + t.toString()
+ "\n\n");
  -                t.printStackTrace(directError);
  -                directError.close();
  +                displayPortletNotAvailableMessage(t, response, portletName);          
     
               }
               finally
               {
                   t.printStackTrace();
               }
           }
  -
       }
   
  +    private void displayPortletNotAvailableMessage(Throwable t, HttpServletResponse response,
String portletName)
  +    throws IOException
  +    {
  +        getServletContext().log(JCS + "Error rendering JetspeedContainerServlet error page:
" + t.toString(), t);                
  +        PrintWriter directError = new PrintWriter(response.getWriter());
  +        directError.write("Portlet is Not Available: " + portletName + "<br/>Reason:
" + t.getMessage());
  +        //t.printStackTrace(directError); 
  +        directError.close();        
  +    }
  +    
       /**
        * In this application doGet and doPost are the same thing.
        *
  
  
  

---------------------------------------------------------------------
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