Source Code Cross Referenced for PlanetModel.java in  » Blogger-System » apache-roller-3.1 » org » apache » roller » ui » rendering » model » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Blogger System » apache roller 3.1 » org.apache.roller.ui.rendering.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  The ASF licenses this file to You
004:         * under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.  For additional information regarding
015:         * copyright in this work, please see the NOTICE file in the top level
016:         * directory of this distribution.
017:         */
018:
019:        package org.apache.roller.ui.rendering.model;
020:
021:        import java.util.ArrayList;
022:        import java.util.Iterator;
023:        import java.util.List;
024:        import java.util.Map;
025:        import org.apache.commons.logging.Log;
026:        import org.apache.commons.logging.LogFactory;
027:        import org.apache.roller.RollerException;
028:        import org.apache.roller.planet.business.PlanetManager;
029:        import org.apache.roller.business.Roller;
030:        import org.apache.roller.business.RollerFactory;
031:        import org.apache.roller.planet.pojos.PlanetSubscriptionData;
032:        import org.apache.roller.pojos.Template;
033:        import org.apache.roller.pojos.WebsiteData;
034:        import org.apache.roller.planet.pojos.wrapper.PlanetSubscriptionDataWrapper;
035:        import org.apache.roller.ui.rendering.pagers.Pager;
036:        import org.apache.roller.ui.rendering.pagers.PlanetEntriesPager;
037:        import org.apache.roller.ui.rendering.util.WeblogPageRequest;
038:        import org.apache.roller.ui.rendering.util.WeblogRequest;
039:        import org.apache.roller.util.URLUtilities;
040:
041:        /**
042:         * Model that provides access to planet aggregations, feeds and subscriptions.
043:         */
044:        public class PlanetModel implements  Model {
045:
046:            private static Log log = LogFactory.getLog(PlanetModel.class);
047:
048:            private WeblogRequest weblogRequest = null;
049:            private String pageLink = null;
050:            private int pageNum = 0;
051:            private WebsiteData weblog = null;
052:
053:            public String getModelName() {
054:                return "planet";
055:            }
056:
057:            public void init(Map initData) throws RollerException {
058:
059:                // we expect the init data to contain a weblogRequest object
060:                this .weblogRequest = (WeblogRequest) initData
061:                        .get("weblogRequest");
062:                if (this .weblogRequest == null) {
063:                    throw new RollerException(
064:                            "expected weblogRequest from init data");
065:                }
066:
067:                if (weblogRequest instanceof  WeblogPageRequest) {
068:                    Template weblogPage = ((WeblogPageRequest) weblogRequest)
069:                            .getWeblogPage();
070:                    pageLink = (weblogPage != null) ? weblogPage.getLink()
071:                            : null;
072:                    pageNum = ((WeblogPageRequest) weblogRequest).getPageNum();
073:                }
074:
075:                // extract weblog object
076:                weblog = weblogRequest.getWeblog();
077:            }
078:
079:            /**
080:             * Get pager for PlanetEntry objects from 'all' and
081:             * 'exernal' Planet groups. in reverse chrono order.
082:             * @param offset   Offset into results (for paging)
083:             * @param len      Max number of results to return
084:             */
085:            public Pager getAggregationPager(int sinceDays, int length) {
086:
087:                String pagerUrl = URLUtilities.getWeblogPageURL(weblog,
088:                        weblogRequest.getLocale(), pageLink, null, null, null,
089:                        null, 0, false);
090:
091:                return new PlanetEntriesPager(null, null, pagerUrl,
092:                        weblogRequest.getLocale(), sinceDays, pageNum, length);
093:            }
094:
095:            /**
096:             * Get pager for WeblogEntry objects from specified
097:             * Planet groups in reverse chrono order.
098:             * @param offset   Offset into results (for paging)
099:             * @param len      Max number of results to return
100:             */
101:            public Pager getAggregationPager(String groupHandle, int sinceDays,
102:                    int length) {
103:
104:                String pagerUrl = URLUtilities.getWeblogPageURL(weblog,
105:                        weblogRequest.getLocale(), pageLink, null, null, null,
106:                        null, 0, false);
107:
108:                return new PlanetEntriesPager(null, groupHandle, pagerUrl,
109:                        weblogRequest.getLocale(), sinceDays, pageNum, length);
110:            }
111:
112:            /**
113:             * Get pager for WeblogEntry objects from specified
114:             * Planet feed in reverse chrono order.
115:             * @param offset   Offset into results (for paging)
116:             * @param len      Max number of results to return
117:             */
118:            public Pager getFeedPager(String feedURL, int length) {
119:
120:                String pagerUrl = URLUtilities.getWeblogPageURL(weblog,
121:                        weblogRequest.getLocale(), pageLink, null, null, null,
122:                        null, 0, false);
123:
124:                return new PlanetEntriesPager(feedURL, null, pagerUrl,
125:                        weblogRequest.getLocale(), -1, pageNum, length);
126:            }
127:
128:            /**
129:             * Get PlanetSubscription objects in descending order by Planet ranking.
130:             * @param sinceDays Only consider weblogs updated in the last sinceDays
131:             * @param offset   Offset into results (for paging)
132:             * @param len      Max number of results to return
133:             */
134:            public List getRankedSubscriptions(int sinceDays, int length) {
135:                return getRankedSubscriptions(null, sinceDays, length);
136:            }
137:
138:            /**
139:             * Get PlanetSubscription objects in descending order by Planet ranking.
140:             * @param groupHandle Only consider weblogs updated in the last sinceDays
141:             * @param sinceDays   Only consider weblogs updated in the last sinceDays
142:             * @param offset      Offset into results (for paging)
143:             * @param len         Max number of results to return
144:             */
145:            public List getRankedSubscriptions(String groupHandle,
146:                    int sinceDays, int length) {
147:                List list = new ArrayList();
148:                try {
149:                    Roller roller = RollerFactory.getRoller();
150:                    PlanetManager planetManager = roller.getPlanetManager();
151:                    List subs = planetManager.getTopSubscriptions(groupHandle,
152:                            0, length);
153:                    for (Iterator it = subs.iterator(); it.hasNext();) {
154:                        PlanetSubscriptionData sub = (PlanetSubscriptionData) it
155:                                .next();
156:                        list.add(PlanetSubscriptionDataWrapper.wrap(sub));
157:                    }
158:                } catch (Exception e) {
159:                    log.error("ERROR: get ranked blogs", e);
160:                }
161:                return list;
162:            }
163:
164:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.