roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r553632 - in /roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering: model/ servlets/
Date Thu, 05 Jul 2007 20:56:34 GMT
Author: agilliland
Date: Thu Jul  5 13:56:33 2007
New Revision: 553632

URL: http://svn.apache.org/viewvc?view=rev&rev=553632
Log:
modify rendering Model classes so that they look for their url strategy to be part of their
initialization data, making it easy to reuse a Model class with differing url strategies.


Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/FeedModel.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PreviewURLModel.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/FeedModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/FeedModel.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/FeedModel.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/FeedModel.java
Thu Jul  5 13:56:33 2007
@@ -24,6 +24,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.URLStrategy;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.Weblog;
@@ -46,6 +47,7 @@
     private static int DEFAULT_ENTRIES = WebloggerRuntimeConfig.getIntProperty("site.newsfeeds.defaultEntries");
     
     private WeblogFeedRequest feedRequest = null;
+    private URLStrategy urlStrategy = null;
     private Weblog weblog = null;
     
     
@@ -66,6 +68,12 @@
                     "  FeedModel only supports feed requests.");
         }
         
+        // look for url strategy
+        urlStrategy = (URLStrategy) initData.get("urlStrategy");
+        if(urlStrategy == null) {
+            urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        }
+        
         // extract weblog object
         weblog = feedRequest.getWeblog();
     }
@@ -133,12 +141,12 @@
         return feedRequest.getTags();
     }    
 
-    public static class FeedEntriesPager extends WeblogEntriesListPager {
+    public class FeedEntriesPager extends WeblogEntriesListPager {
         
         private WeblogFeedRequest feedRequest;
         
         public FeedEntriesPager(WeblogFeedRequest feedRequest) {
-            super(WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogFeedURL(feedRequest.getWeblog(),

+            super(urlStrategy.getWeblogFeedURL(feedRequest.getWeblog(), 
                     feedRequest.getLocale(), feedRequest.getType(),
                     feedRequest.getFormat(), null, null, null, false, true), 
                     feedRequest.getWeblog(), null, feedRequest.getWeblogCategoryName(), feedRequest.getTags(),
@@ -166,12 +174,12 @@
         }
     }
     
-    public static class FeedCommentsPager extends CommentsPager {
+    public class FeedCommentsPager extends CommentsPager {
         
         private WeblogFeedRequest feedRequest;
         
         public FeedCommentsPager(WeblogFeedRequest feedRequest) {            
-            super(WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogFeedURL(feedRequest.getWeblog(),

+            super(urlStrategy.getWeblogFeedURL(feedRequest.getWeblog(), 
                     feedRequest.getLocale(), feedRequest.getType(),
                     feedRequest.getFormat(), null, null,
                     null, false, true), feedRequest.getWeblog(), feedRequest.getLocale(),
-1, feedRequest.getPage(), DEFAULT_ENTRIES);

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PageModel.java
Thu Jul  5 13:56:33 2007
@@ -25,9 +25,8 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.business.Weblogger;
+import org.apache.roller.weblogger.business.URLStrategy;
 import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.wrapper.ThemeTemplateWrapper;
 import org.apache.roller.weblogger.pojos.wrapper.WeblogCategoryWrapper;
@@ -51,6 +50,7 @@
     private static Log log = LogFactory.getLog(PageModel.class);
     
     private WeblogPageRequest pageRequest = null;
+    private URLStrategy urlStrategy = null;
     private WeblogEntryCommentForm commentForm = null;
     private Map requestParameters = null;
     private Weblog weblog = null;
@@ -97,6 +97,12 @@
         
         // custom request parameters
         this.requestParameters = (Map)initData.get("requestParameters");
+        
+        // look for url strategy
+        urlStrategy = (URLStrategy) initData.get("urlStrategy");
+        if(urlStrategy == null) {
+            urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        }
         
         // extract weblog object
         weblog = pageRequest.getWeblog();

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PlanetModel.java
Thu Jul  5 13:56:33 2007
@@ -30,6 +30,7 @@
 import org.apache.roller.planet.pojos.Planet;
 import org.apache.roller.planet.pojos.PlanetGroup;
 import org.apache.roller.planet.pojos.Subscription;
+import org.apache.roller.weblogger.business.URLStrategy;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.ThemeTemplate;
 import org.apache.roller.weblogger.pojos.Weblog;
@@ -46,6 +47,7 @@
     private static Log log = LogFactory.getLog(PlanetModel.class);
     
     private WeblogRequest  weblogRequest = null;
+    private URLStrategy urlStrategy = null;
     private String pageLink = null;
     private int            pageNum = 0;
     private Weblog    weblog = null;
@@ -69,6 +71,12 @@
             pageNum = ((WeblogPageRequest)weblogRequest).getPageNum();
         }  
         
+        // look for url strategy
+        urlStrategy = (URLStrategy) initData.get("urlStrategy");
+        if(urlStrategy == null) {
+            urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        }
+        
         // extract weblog object
         weblog = weblogRequest.getWeblog();
     } 
@@ -82,7 +90,7 @@
      */
     public Pager getAggregationPager(int sinceDays, int length) {
         
-        String pagerUrl = WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogPageURL(weblog,

+        String pagerUrl = urlStrategy.getWeblogPageURL(weblog, 
                 weblogRequest.getLocale(), pageLink, 
                 null, null, null, null, 0, false);
         
@@ -105,7 +113,7 @@
      */
     public Pager getAggregationPager(String groupHandle, int sinceDays, int length) {
         
-        String pagerUrl = WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogPageURL(weblog,

+        String pagerUrl = urlStrategy.getWeblogPageURL(weblog, 
                 weblogRequest.getLocale(), pageLink, 
                 null, null, null, null, 0, false);
         
@@ -128,7 +136,7 @@
      */
     public Pager getFeedPager(String feedURL, int length) {
         
-        String pagerUrl = WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogPageURL(weblog,

+        String pagerUrl = urlStrategy.getWeblogPageURL(weblog, 
                 weblogRequest.getLocale(), pageLink, 
                 null, null, null, null, 0, false);
         

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PreviewURLModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PreviewURLModel.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PreviewURLModel.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/PreviewURLModel.java
Thu Jul  5 13:56:33 2007
@@ -59,7 +59,11 @@
         this.weblog = weblogRequest.getWeblog();
         this.locale = weblogRequest.getLocale();
         
-        urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy().getPreviewURLStrategy(previewRequest.getThemeName());
+        // look for url strategy
+        urlStrategy = (URLStrategy) initData.get("urlStrategy");
+        if(urlStrategy == null) {
+            urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        }
         
         super.init(initData);
     }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
Thu Jul  5 13:56:33 2007
@@ -33,6 +33,7 @@
 import org.apache.lucene.document.Document;
 import org.apache.lucene.search.Hits;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.URLStrategy;
 import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.business.WeblogManager;
@@ -61,7 +62,7 @@
     private static Log log = LogFactory.getLog(SearchResultsFeedModel.class);
     
     private WeblogFeedRequest feedRequest = null;
-
+    private URLStrategy urlStrategy = null;
     private Weblog weblog = null;
         
     // the pager used by the 3.0+ rendering system
@@ -99,11 +100,17 @@
             throw new WebloggerException("weblogRequest is not a WeblogFeedRequest."+
                     "  FeedModel only supports feed requests.");
         }
-                
+        
+        // look for url strategy
+        urlStrategy = (URLStrategy) initData.get("urlStrategy");
+        if(urlStrategy == null) {
+            urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        }
+        
         // extract weblog object
         weblog = feedRequest.getWeblog();
         
-        String  pagerUrl = WebloggerFactory.getWeblogger().getUrlStrategy().getWeblogFeedURL(weblog,

+        String  pagerUrl = urlStrategy.getWeblogFeedURL(weblog, 
                 feedRequest.getLocale(), feedRequest.getType(),
                 feedRequest.getFormat(), null, null, /* cat and term are null but added to
the url in the pager */
                 null, false, true);

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
Thu Jul  5 13:56:33 2007
@@ -94,10 +94,14 @@
             pageNum = feedRequest.getPage();
         }
         
+        // look for url strategy
+        urlStrategy = (URLStrategy) initData.get("urlStrategy");
+        if(urlStrategy == null) {
+            urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        }
+        
         // extract weblog object
         weblog = weblogRequest.getWeblog();
-        
-        urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
     }
     
     //----------------------------------------------------------------- Pagers

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/model/URLModel.java
Thu Jul  5 13:56:33 2007
@@ -77,8 +77,11 @@
         this.weblog = weblogRequest.getWeblog();
         this.locale = weblogRequest.getLocale();
         
-        // url strategy 
-        urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        // look for url strategy
+        urlStrategy = (URLStrategy) initData.get("urlStrategy");
+        if(urlStrategy == null) {
+            urlStrategy = WebloggerFactory.getWeblogger().getUrlStrategy();
+        }
         
         // need page context as well :(
         pageContext = (PageContext) initData.get("pageContext");

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java
Thu Jul  5 13:56:33 2007
@@ -227,6 +227,9 @@
             initData.put("request", request);
             initData.put("weblogRequest", feedRequest);
 
+            // define url strategy
+            initData.put("urlStrategy", WebloggerFactory.getWeblogger().getUrlStrategy());
+            
             // Load models for feeds
             String feedModels = WebloggerConfig.getProperty("rendering.feedModels");
             ModelLoader.loadModels(feedModels, model, initData, true);

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
Thu Jul  5 13:56:33 2007
@@ -387,6 +387,9 @@
             initData.put("weblogRequest", pageRequest);
             initData.put("pageContext", pageContext);
             
+            // define url strategy
+            initData.put("urlStrategy", WebloggerFactory.getWeblogger().getUrlStrategy());
+            
             // if this was a comment posting, check for comment form
             WeblogEntryCommentForm commentForm = 
                     (WeblogEntryCommentForm) request.getAttribute("commentForm");

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/PreviewServlet.java
Thu Jul  5 13:56:33 2007
@@ -31,6 +31,7 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.Template;
@@ -168,6 +169,9 @@
             initData.put("request", request);
             initData.put("weblogRequest", previewRequest);
             initData.put("pageContext", pageContext);
+            
+            // define url strategy
+            initData.put("urlStrategy", WebloggerFactory.getWeblogger().getUrlStrategy().getPreviewURLStrategy(previewRequest.getThemeName()));
             
             // Load models for page previewing
             String pageModels = WebloggerConfig.getProperty("rendering.previewModels");

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java?view=diff&rev=553632&r1=553631&r2=553632
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/SearchServlet.java
Thu Jul  5 13:56:33 2007
@@ -143,6 +143,9 @@
             initData.put("weblogRequest", pageRequest);
             initData.put("searchRequest", searchRequest);
             
+            // define url strategy
+            initData.put("urlStrategy", WebloggerFactory.getWeblogger().getUrlStrategy());
+            
             // Load models for pages
             String searchModels = WebloggerConfig.getProperty("rendering.searchModels");
             ModelLoader.loadModels(searchModels, model, initData, true);



Mime
View raw message