View Javadoc

1   package net.sourceforge.blogentis.modules.screens;
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: RSS.java,v 1.1 2004/10/22 17:34:10 tassos Exp $
23  //
24  
25  import net.sourceforge.blogentis.feed.Feed;
26  import net.sourceforge.blogentis.feed.FeedFactory;
27  import net.sourceforge.blogentis.rss.RSSVersion;
28  import net.sourceforge.blogentis.rss.RSSVersionFactory;
29  import net.sourceforge.blogentis.turbine.BaseBlogScreen;
30  import net.sourceforge.blogentis.turbine.BlogParameterParser;
31  import net.sourceforge.blogentis.utils.LinkFactoryService;
32  
33  import org.apache.turbine.util.RunData;
34  import org.apache.turbine.util.TurbineException;
35  import org.apache.velocity.context.Context;
36  
37  /***
38   * the screen that produces RSS per-post, per-section and per-blog.
39   * 
40   * @author abas
41   */
42  public class RSS
43          extends BaseBlogScreen {
44      protected void doBuildTemplate(RunData data, Context context)
45              throws Exception {
46          BlogParameterParser bpp = (BlogParameterParser)data.getParameters();
47          String version = data.getParameters().getString("ver", "rdf");
48          RSSVersion rssv = RSSVersionFactory.getVersionFor(version);
49  
50          if (rssv == null) {
51              data.setRedirectURI(LinkFactoryService.getLink().thisPage(data)
52                  .setPage(null).toString());
53              data.setStatusCode(302);
54              throw new TurbineException("No such RSS version");
55          }
56  
57          Feed f = FeedFactory.getFeed(data);
58          f.setContextProperties(context);
59          f.setVersion(rssv.getVersion());
60  
61          context.put("items", f.getItemsTranslated());
62          context.put("channel", f);
63  
64          super.doBuildTemplate(data, context);
65  
66          setTemplate(data, bpp.getBlog(), rssv.getTemplate());
67  
68          data.setContentType("text/xml");
69          data.getResponse().setContentType("text/xml");
70      }
71  
72      public String getLayoutTemplate(RunData data) {
73          return "RSS.vm";
74      }
75  
76      public String getLayout(RunData data) {
77          return "RSS";
78      }
79  }