KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > velocity > PlanetPageModel


1
2 package org.roller.presentation.velocity;
3 import java.util.ArrayList JavaDoc;
4 import java.util.List JavaDoc;
5 import org.roller.model.PlanetManager;
6 import org.roller.model.Roller;
7 import org.roller.pojos.PlanetGroupData;
8 import org.roller.pojos.PlanetSubscriptionData;
9 import org.roller.presentation.RollerRequest;
10 import org.roller.presentation.velocity.PageModel;
11
12 /**
13  * Allow Roller page templates to get the main Planet aggregation (the 'all'
14  * and 'external' group), custom aggregations, specified by handle, and
15  * subscription entries (specified by feedUrl).
16  * @author Dave Johnson
17  */

18 public class PlanetPageModel extends PageModel
19 {
20     PlanetManager planetManager = null;
21     public void init(RollerRequest rreq)
22     {
23         super.init(rreq);
24         try
25         {
26             planetManager = rreq.getRoller().getPlanetManager();
27         }
28         catch (Exception JavaDoc e)
29         {
30             mLogger.error("ERROR initializing page model",e);
31         }
32     }
33     /**
34      * Get main aggregation (of 'all' and 'external' groups)
35      * @returns List of PlanetEntryData objects
36      */

37     public List JavaDoc getPlanetAggregation(int max) throws Exception JavaDoc
38     {
39         return planetManager.getAggregation(max);
40     }
41     /**
42      * Get aggregation by group handle
43      * @returns List of PlanetEntryData objects
44      */

45     public List JavaDoc getPlanetAggregation(String JavaDoc groupHandle, int max) throws Exception JavaDoc
46     {
47         List JavaDoc list = new ArrayList JavaDoc();
48         PlanetGroupData group = planetManager.getGroup(groupHandle);
49         if (group != null)
50         {
51             list = planetManager.getAggregation(group, max);
52         }
53         return list;
54     }
55     /**
56      * Get entries in a subscription specified by feedUrl.
57      * @returns List of PlanetEntryData objects
58      */

59     public List JavaDoc getPlanetSubscriptionEntries(String JavaDoc feedUrl, int max) throws Exception JavaDoc
60     {
61         List JavaDoc list = new ArrayList JavaDoc();
62         PlanetSubscriptionData sub = planetManager.getSubscription(feedUrl);
63         if (sub != null)
64         {
65             list = sub.getEntries();
66         }
67         return list;
68     }
69 }
70
Popular Tags