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: PostFeed.java,v 1.1 2004/10/22 17:34:05 tassos Exp $
23  //
24  
25  import java.util.List;
26  import java.util.Map;
27  
28  import net.sourceforge.blogentis.om.PostPeer;
29  import net.sourceforge.blogentis.plugins.BlogPluginService;
30  import net.sourceforge.blogentis.plugins.base.IPostViewExtensionPoint;
31  import net.sourceforge.blogentis.utils.AbsoluteLinkURL;
32  import net.sourceforge.blogentis.utils.BlogPropertyCache;
33  import net.sourceforge.blogentis.utils.PresentationalProperties;
34  
35  import org.apache.torque.TorqueException;
36  import org.apache.torque.util.Criteria;
37  import org.apache.turbine.util.RunData;
38  
39  /***
40   * @author abas
41   */
42  public class PostFeed
43          extends Feed {
44  
45      private static final String[] searchableColumns = {PostPeer.TITLE,
46              PostPeer.SHORT_DESCRIPTION, PostPeer.FULL_TEXT};
47  
48      protected PostFeed(RunData data) {
49          super(data);
50          //TODO: add support for pending drafts feeds...
51      }
52  
53      public List getItems(Criteria c)
54              throws TorqueException {
55          c.add(PostPeer.POST_TYPE, PostPeer.PUBLISHED_TYPE);
56          return PostPeer.doSelectJoinBlog(c);
57      }
58  
59      protected PresentationalProperties getProperties() {
60          if (pp.getSection() != null && pp.getBlog() != null)
61              return BlogPropertyCache.getInstance()
62                  .getSectionProperties(pp.getBlog());
63          return BlogPropertyCache.getInstance().getBlogProperties(pp.getBlog());
64      }
65  
66      public String[] getSearchColumns() {
67          return searchableColumns;
68      }
69  
70      public String getTimeColumn() {
71          return PostPeer.POSTED_TIME;
72      }
73  
74      protected void fixFeedDescription(Map m) {
75          AbsoluteLinkURL link = (AbsoluteLinkURL)m.get(FeedModifier.FEED_LINK);
76          if (data.getParameters().getString("all", "-").equals("content")) {
77              link.setTemplate(link.getTemplate() + "/all/content");
78              m.put("blogentis:show-full-content", "1");
79          }
80          m.put(FeedModifier.FEED_LINK, link);
81          if (!m.containsKey(FeedModifier.FEED_TITLE))
82              m.put(FeedModifier.FEED_TITLE, "blogentis aggregate feed");
83          if (!m.containsKey(FeedModifier.FEED_DESCRIPTION))
84              m.put(FeedModifier.FEED_DESCRIPTION, "All posts at "
85                                                   + new AbsoluteLinkURL()
86                                                       .toString());
87      }
88  
89      public List getItemsTranslated()
90              throws TorqueException {
91          List l = getItems();
92          IPostViewExtensionPoint pExt = (IPostViewExtensionPoint)BlogPluginService
93              .locateExtensionPoint(data.getBlog(),
94                                    IPostViewExtensionPoint.class);
95          if (pExt != null)
96              l = pExt.doPostViewExtensions(data, l);
97          return l;
98      }
99  }