View Javadoc

1   package net.sourceforge.blogentis.feed;
2   
3   //-----------------------------------------------------------------------
4   //Blogentis - a blog publishing platform.
5   //Copyright (C) 2004 Tassos Bassoukos <abassouk@gmail.com>
6   //
7   //This library is free software; you can redistribute it and/or
8   //modify it under the terms of the GNU Lesser General Public
9   //License as published by the Free Software Foundation; either
10  //version 2.1 of the License, or (at your option) any later version.
11  //
12  //This library is distributed in the hope that it will be useful,
13  //but WITHOUT ANY WARRANTY; without even the implied warranty of
14  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  //Lesser General Public License for more details.
16  //
17  //You should have received a copy of the GNU Lesser General Public
18  //License along with this library; if not, write to the Free Software
19  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  //-----------------------------------------------------------------------
21  //
22  //$Id: FeedFactory.java,v 1.2 2004/10/28 10:45:52 tassos Exp $
23  //
24  
25  import net.sourceforge.blogentis.turbine.BlogParameterParser;
26  import net.sourceforge.blogentis.utils.BlogPropertyCache;
27  import net.sourceforge.blogentis.utils.PresentationalProperties;
28  
29  import org.apache.turbine.util.RunData;
30  
31  /***
32   * @author abas
33   */
34  public class FeedFactory {
35      private static final String PARAMETER_NAME = "all";
36  
37      public static final String ALL_COMMENTS = "comments";
38  
39      public static Feed getFeed(RunData data) {
40          BlogParameterParser bpp = (BlogParameterParser)data.getParameters();
41  
42          Feed feed;
43          PresentationalProperties pp = null;
44  
45          if (ALL_COMMENTS.equals(bpp.getString(PARAMETER_NAME, "-"))
46              || bpp.getPost() != null)
47              feed = new CommentFeed(data);
48          else
49              feed = new PostFeed(data);
50  
51          if (bpp.getBlog() != null & bpp.getBlog().getBlogId()!=-1) {
52              feed.addCriteriaModifier(new BlogModifier(bpp.getBlog()));
53              pp = BlogPropertyCache.getInstance().getBlogProperties(
54                      bpp.getBlog());
55          }
56          if (bpp.getSection() != null) {
57              feed.addCriteriaModifier(new SectionModifier(bpp.getSection()));
58              pp = BlogPropertyCache.getInstance().getSectionProperties(
59                      bpp.getBlog());
60          }
61          if (bpp.getPost() != null) {
62              feed.addCriteriaModifier(new PostModifier(bpp.getPost()));
63              pp = BlogPropertyCache.getInstance().getPostProperties(
64                      bpp.getBlog());
65          }
66          if (bpp.getDate() != null)
67              feed.addCriteriaModifier(new DateModifier(bpp.getDate(),
68                  feed.getTimeColumn()));
69          if (bpp.getString(PostSearchModifier.SEARCH_PARAMETER_NAME, null) != null)
70              feed.addCriteriaModifier(new PostSearchModifier(data,
71                  feed.getSearchColumns()));
72          if (pp != null)
73              feed.setLimit(pp.getFeedSize());
74          return feed;
75      }
76  }