1 package net.sourceforge.blogentis.feed;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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 }