roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r422087 - in /incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering: model/ModelLoader.java model/SearchResultsModel.java servlets/SearchServlet.java velocity/deprecated/ContextLoader.java
Date Fri, 14 Jul 2006 23:01:28 GMT
Author: agilliland
Date: Fri Jul 14 16:01:28 2006
New Revision: 422087

URL: http://svn.apache.org/viewvc?rev=422087&view=rev
Log:
a little more reconciliation between old models stuff and new search requests.  the search
servlet now fills out a valid page request from it's info to be used by the rest of the rendering
system since search requests are technically thought of as pages.


Modified:
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SearchResultsModel.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
    incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java?rev=422087&r1=422086&r2=422087&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/ModelLoader.java
Fri Jul 14 16:01:28 2006
@@ -27,7 +27,7 @@
 import org.apache.roller.RollerException;
 import org.apache.roller.config.RollerConfig;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.ui.rendering.util.WeblogRequest;
+import org.apache.roller.ui.rendering.util.WeblogPageRequest;
 import org.apache.roller.ui.rendering.velocity.deprecated.ContextLoader;
 import org.apache.roller.util.Utilities;
 
@@ -77,13 +77,13 @@
             HttpServletRequest  request,
             HttpServletResponse response,
             PageContext pageContext,
-            WeblogRequest weblogRequest) throws RollerException {
+            WeblogPageRequest pageRequest) throws RollerException {
         
         // Only load old model if it's specified
         String useOldModel = 
             RollerConfig.getProperty("velocity.pagemodel.classname");        
         if (useOldModel != null && useOldModel.trim().length() > 0) { 
-            ContextLoader.setupContext(model, request, response, pageContext, weblogRequest);
           
+            ContextLoader.setupContext(model, request, response, pageContext, pageRequest);
           
         }
     }
     

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SearchResultsModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SearchResultsModel.java?rev=422087&r1=422086&r2=422087&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SearchResultsModel.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/model/SearchResultsModel.java
Fri Jul 14 16:01:28 2006
@@ -83,12 +83,6 @@
             throw new RollerException("expected searchRequest from init data");
         }
         
-        // we need to add a simple page request to make our parent happy
-        WeblogPageRequest pageRequest = new WeblogPageRequest();
-        pageRequest.setWeblogHandle(searchRequest.getWeblogHandle());
-        pageRequest.setWeblogCategoryName(searchRequest.getWeblogCategoryName());
-        initData.put("pageRequest", pageRequest);
-        
         // let parent initialize
         super.init(initData);
         

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java?rev=422087&r1=422086&r2=422087&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/servlets/SearchServlet.java
Fri Jul 14 16:01:28 2006
@@ -41,7 +41,7 @@
 import org.apache.roller.ui.rendering.model.Model;
 import org.apache.roller.ui.rendering.model.ModelLoader;
 import org.apache.roller.ui.rendering.model.SearchResultsModel;
-import org.apache.roller.ui.rendering.util.InvalidRequestException;
+import org.apache.roller.ui.rendering.util.WeblogPageRequest;
 import org.apache.roller.ui.rendering.util.WeblogSearchRequest;
 import org.apache.roller.util.cache.CachedContent;
 
@@ -122,6 +122,13 @@
             initData.put("searchRequest", searchRequest);
             initData.put("pageContext", pageContext);
             
+            // we need to add a simple page request because the search
+            // results are rendered like a weblog page
+            WeblogPageRequest pageRequest = new WeblogPageRequest();
+            pageRequest.setWeblogHandle(searchRequest.getWeblogHandle());
+            pageRequest.setWeblogCategoryName(searchRequest.getWeblogCategoryName());
+            initData.put("pageRequest", pageRequest);
+        
             // default weblog models
             ModelLoader.loadSearchModels(model, initData);
             
@@ -138,7 +145,7 @@
             ModelLoader.loadCustomModels(weblog, model, initData);
             
             // ick, gotta load pre-3.0 model stuff as well :(
-            ModelLoader.loadOldModels(model, request, response, pageContext, searchRequest);
+            ModelLoader.loadOldModels(model, request, response, pageContext, pageRequest);
             
             // manually add search model again to support pre-3.0 weblogs
             Model searchModel = new SearchResultsModel();

Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java?rev=422087&r1=422086&r2=422087&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
(original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/deprecated/ContextLoader.java
Fri Jul 14 16:01:28 2006
@@ -123,7 +123,7 @@
             HttpServletRequest  request,
             HttpServletResponse response,
             PageContext pageContext,
-            WeblogRequest weblogRequest) throws RollerException {
+            WeblogPageRequest pageRequest) throws RollerException {
         
         mLogger.debug("setupContext( ctx = "+ctx+")");
         
@@ -139,93 +139,43 @@
         boolean isMonth = false;
         String locale = null;
         
-        // if this is a weblog page request then parse it out
-        WeblogPageRequest pageRequest = null;
-        try {
-            pageRequest = (WeblogPageRequest) weblogRequest;
-            
-            // lookup weblog
-            weblog = pageRequest.getWeblog();
-            
-            // lookup entry if specified
-            entry = pageRequest.getWeblogEntry();
-            
-            // lookup category if specified
-            category = pageRequest.getWeblogCategory();
-            
-            // lookup page if specified, otherwise lookup default
-            page = pageRequest.getWeblogPage();
-            if(page == null) {
-                page = weblog.getDefaultPage();
-            }
+        // get data from page request
+        locale = pageRequest.getLocale();
+        weblog = pageRequest.getWeblog();
+        entry = pageRequest.getWeblogEntry();
+        category = pageRequest.getWeblogCategory();
+        page = pageRequest.getWeblogPage();
+        if(page == null) {
+            page = weblog.getDefaultPage();
+        }
+        
+        // setup date, isDay, and isMonth
+        if(pageRequest.getWeblogDate() != null) {
             
-            // setup date, isDay, and isMonth
-            if(pageRequest.getWeblogDate() != null) {
-                
-                Date now = new Date();
-                if(pageRequest.getWeblogDate().length() == 8) {
-                    isDay = true;
-                    try {
-                        date = DateUtil.get8charDateFormat().parse(pageRequest.getWeblogDate());
-                        if(date.after(now)) {
-                            date = now;
-                        }
-                    } catch(Exception e) {
-                        // bleh
+            Date now = new Date();
+            if(pageRequest.getWeblogDate().length() == 8) {
+                isDay = true;
+                try {
+                    date = DateUtil.get8charDateFormat().parse(pageRequest.getWeblogDate());
+                    if(date.after(now)) {
+                        date = now;
                     }
-                } else if(pageRequest.getWeblogDate().length() == 6) {
-                    isMonth = true;
-                    try {
-                        date = DateUtil.get6charDateFormat().parse(pageRequest.getWeblogDate());
-                        if(date.after(now)) {
-                            date = now;
-                        }
-                    } catch(Exception e) {
-                        // bleh
+                } catch(Exception e) {
+                    // bleh
+                }
+            } else if(pageRequest.getWeblogDate().length() == 6) {
+                isMonth = true;
+                try {
+                    date = DateUtil.get6charDateFormat().parse(pageRequest.getWeblogDate());
+                    if(date.after(now)) {
+                        date = now;
                     }
-                } else {
-                    isMonth = true;
+                } catch(Exception e) {
+                    // bleh
                 }
+            } else {
+                isMonth = true;
             }
-            
-            // setup locale
-            locale = pageRequest.getLocale();
-            
-        } catch(ClassCastException cce) {
-            // ignore, just means this isn't a page request
-        } catch(InvalidRequestException ire) {
-            // ignore, must not be a page request
-        } catch(RollerException re) {
-            throw re;
-        } catch(Exception e) {
-            throw new RollerException(e);
-        }
-        
-        // if not a page request then try search request
-        WeblogSearchRequest searchRequest = null;
-        if(pageRequest == null) try {
-            searchRequest = (WeblogSearchRequest) weblogRequest;
-            
-            // lookup weblog
-            weblog = searchRequest.getWeblog();
-            
-            // lookup category if specified
-            category = searchRequest.getWeblogCategory();
-            
-            // lookup page if specified, otherwise lookup default
-            page = weblog.getDefaultPage();
-            
-            // setup locale
-            locale = searchRequest.getLocale();
-            
-        } catch(ClassCastException cce) {
-            // ignore, just means this isn't a search request
-        } catch(InvalidRequestException ire) {
-            // ignore, must not be a search request
-        } catch(RollerException re) {
-            throw re;
-        } catch(Exception e) {
-            throw new RollerException(e);
         }
         
         try {



Mime
View raw message