roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r354269 - /incubator/roller/trunk/src/org/roller/presentation/search/SearchServlet.java
Date Tue, 06 Dec 2005 03:23:56 GMT
Author: snoopdave
Date: Mon Dec  5 19:23:53 2005
New Revision: 354269

URL: http://svn.apache.org/viewcvs?rev=354269&view=rev
Log:
handleRequest() can no longer throw an exception

Modified:
    incubator/roller/trunk/src/org/roller/presentation/search/SearchServlet.java

Modified: incubator/roller/trunk/src/org/roller/presentation/search/SearchServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/search/SearchServlet.java?rev=354269&r1=354268&r2=354269&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/search/SearchServlet.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/search/SearchServlet.java Mon Dec 
5 19:23:53 2005
@@ -55,51 +55,59 @@
     private boolean searchEnabled = true;
     
     public Template handleRequest(HttpServletRequest request,
-        HttpServletResponse response, Context ctx) throws Exception {
+        HttpServletResponse response, Context ctx) {
         
-        // Note: Removed request character encoding here; was too late; 
-        // it is now set uniformly in CharEncodingFilter. See ROL-760.
-        
-        String enabled = RollerConfig.getProperty("search.enabled");
-        if("false".equalsIgnoreCase(enabled))
-            this.searchEnabled = false;
-        
-        if(! this.searchEnabled) {
-            Template outty = null;
-            Exception pageException = null;
-            try {
-                ContextLoader.setupContext(
-                    ctx, RollerRequest.getRollerRequest(request), response );
-                outty = getTemplate( "searchdisabled.vm", "UTF-8" );
-            } catch (Exception e) {
-               pageException = e;
-               response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+        Template outty = null;
+        try {
+            // Note: Removed request character encoding here; was too late; 
+            // it is now set uniformly in CharEncodingFilter. See ROL-760.
+
+            String enabled = RollerConfig.getProperty("search.enabled");
+            if("false".equalsIgnoreCase(enabled))
+                this.searchEnabled = false;
+
+            if(! this.searchEnabled) {
+                Exception pageException = null;
+                try {
+                    ContextLoader.setupContext(
+                        ctx, RollerRequest.getRollerRequest(request), response );
+                    outty = getTemplate( "searchdisabled.vm", "UTF-8" );
+                } catch (Exception e) {
+                   pageException = e;
+                   response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+                }
+
+                if (pageException != null) {
+                    mLogger.error("EXCEPTION: in RollerServlet", pageException);
+                    request.setAttribute("DisplayException", pageException);
+                }
+                return outty;
             }
-            
-            if (pageException != null) {
-                mLogger.error("EXCEPTION: in RollerServlet", pageException);
-                request.setAttribute("DisplayException", pageException);
+
+            // do no work if query term is empty
+            if (StringUtils.isEmpty(request.getParameter("q"))) {
+                return generalSearchResults(request, response, ctx);
             }
-            return outty;
-        }
-        
-        // do no work if query term is empty
-        if (StringUtils.isEmpty(request.getParameter("q"))) {
-            return generalSearchResults(request, response, ctx);
-        }
-        
-        // search model executes search, makes results available to page
-        SearchResultsPageModel model = 
-                new SearchResultsPageModel("", request, response, null);
-        ctx.put("searchResults", model);
-        
-        // load standard Velocity stff
-        ContextLoader.setupContext(
-            ctx, RollerRequest.getRollerRequest(request), response );
-        
-        request.setAttribute("zzz_VelocityContext_zzz", ctx); // for testing
+
+            // search model executes search, makes results available to page
+            SearchResultsPageModel model = 
+                    new SearchResultsPageModel("", request, response, null);
+            ctx.put("searchResults", model);
+
+            // load standard Velocity stff
+            ContextLoader.setupContext(
+                ctx, RollerRequest.getRollerRequest(request), response );
+
+            request.setAttribute("zzz_VelocityContext_zzz", ctx); // for testing
+            
+            outty = getTemplate( "searchresults.vm", "UTF-8" );
         
-        return getTemplate( "searchresults.vm", "UTF-8" );
+        } catch (Exception e) {
+            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+            request.setAttribute("DisplayException", e);
+            mLogger.error("EXCEPTION: in SearchServlet", e);
+        }      
+        return outty;
     }
     
     /**



Mime
View raw message