Source Code Cross Referenced for HibernateRollerPlanetManagerImpl.java in  » Blogger-System » apache-roller-3.1 » org » apache » roller » business » hibernate » 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.business.hibernate 
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.business.hibernate;
020:
021:        import com.sun.syndication.fetcher.FeedFetcher;
022:        import com.sun.syndication.fetcher.impl.FeedFetcherCache;
023:        import java.text.MessageFormat;
024:        import java.util.ArrayList;
025:        import java.util.Date;
026:        import java.util.HashMap;
027:        import java.util.Iterator;
028:        import java.util.List;
029:        import java.util.Map;
030:        import java.util.Set;
031:        import java.util.TreeSet;
032:        import org.apache.commons.logging.Log;
033:        import org.apache.commons.logging.LogFactory;
034:        import org.apache.roller.RollerException;
035:        import org.apache.roller.config.RollerRuntimeConfig;
036:        import org.apache.roller.business.PluginManager;
037:        import org.apache.roller.business.RollerFactory;
038:        import org.apache.roller.business.UserManager;
039:        import org.apache.roller.business.WeblogManager;
040:        import org.apache.roller.planet.business.hibernate.HibernatePlanetManagerImpl;
041:        import org.apache.roller.planet.pojos.PlanetEntryData;
042:        import org.apache.roller.planet.pojos.PlanetSubscriptionData;
043:        import org.apache.roller.pojos.WeblogEntryData;
044:        import org.apache.roller.pojos.WebsiteData;
045:        import org.apache.commons.lang.StringUtils;
046:
047:        /**
048:         * An extended version of the base PlanetManager implementation.
049:         *
050:         * This is meant for use by Roller installations that are running the planet
051:         * aggregator in the same application instance and want to fetch feeds from
052:         * their local Roller blogs in a more efficient manner.
053:         */
054:        public class HibernateRollerPlanetManagerImpl extends
055:                HibernatePlanetManagerImpl {
056:
057:            private static Log log = LogFactory
058:                    .getLog(HibernateRollerPlanetManagerImpl.class);
059:
060:            public HibernateRollerPlanetManagerImpl(
061:                    HibernatePersistenceStrategy strat) {
062:
063:                super (strat);
064:
065:                log.info("Instantiating Hibernate Roller Planet Manager");
066:            }
067:
068:            protected Set getNewEntries(PlanetSubscriptionData sub,
069:                    FeedFetcher feedFetcher, FeedFetcherCache feedInfoCache)
070:                    throws RollerException {
071:
072:                String localURL = RollerRuntimeConfig
073:                        .getProperty("site.absoluteurl");
074:
075:                // if this is not a local url then let parent deal with it
076:                if (StringUtils.isEmpty(localURL)
077:                        || !sub.getFeedURL().startsWith(localURL)) {
078:
079:                    log.debug("Feed is remote, letting parent handle it "
080:                            + sub.getFeedURL());
081:
082:                    return super .getNewEntries(sub, feedFetcher, feedInfoCache);
083:                }
084:
085:                try {
086:                    // for local feeds, sub.author = website.handle
087:                    // feed is from our domain and we have a handle, lets deal with it
088:                    if (sub.getAuthor() != null) {
089:
090:                        log.debug("Getting LOCAL feed " + sub.getFeedURL());
091:
092:                        Set newEntries = new TreeSet();
093:
094:                        // get corresponding website object
095:                        UserManager usermgr = RollerFactory.getRoller()
096:                                .getUserManager();
097:                        WebsiteData website = usermgr.getWebsiteByHandle(sub
098:                                .getAuthor());
099:                        if (website == null)
100:                            return newEntries;
101:
102:                        // figure website last update time
103:                        WeblogManager blogmgr = RollerFactory.getRoller()
104:                                .getWeblogManager();
105:
106:                        Date siteUpdated = website.getLastModified();
107:                        if (siteUpdated == null) { // Site never updated, skip it
108:                            log
109:                                    .warn("Last-publish time null, skipping local feed ["
110:                                            + website.getHandle() + "]");
111:                            return newEntries;
112:                        }
113:
114:                        // if website last update time > subsciption last update time
115:                        List entries = new ArrayList();
116:                        if (sub.getLastUpdated() == null
117:                                || siteUpdated.after(sub.getLastUpdated())) {
118:                            int entryCount = RollerRuntimeConfig
119:                                    .getIntProperty("site.newsfeeds.defaultEntries");
120:                            entries = blogmgr.getWeblogEntries(website, null,
121:                                    null, // startDate
122:                                    new Date(), // endDate
123:                                    null, // catName
124:                                    null, // tags
125:                                    WeblogEntryData.PUBLISHED, // status
126:                                    null, // sortby (null means pubTime)
127:                                    null, // locale
128:                                    0, // offset
129:                                    entryCount);
130:
131:                            sub.setLastUpdated(siteUpdated);
132:                            saveSubscription(sub);
133:
134:                        } else {
135:                            if (log.isDebugEnabled()) {
136:                                String msg = MessageFormat.format(
137:                                        "   Skipping ({0} / {1})",
138:                                        new Object[] { siteUpdated,
139:                                                sub.getLastUpdated() });
140:                                log.debug(msg);
141:                            }
142:                        }
143:
144:                        // Populate subscription object with new entries
145:                        PluginManager ppmgr = RollerFactory.getRoller()
146:                                .getPagePluginManager();
147:                        Map pagePlugins = ppmgr.getWeblogEntryPlugins(website);
148:                        Iterator entryIter = entries.iterator();
149:                        while (entryIter.hasNext()) {
150:                            try {
151:                                WeblogEntryData rollerEntry = (WeblogEntryData) entryIter
152:                                        .next();
153:                                PlanetEntryData entry = new PlanetEntryData(
154:                                        rollerEntry, sub, pagePlugins);
155:                                saveEntry(entry);
156:                                newEntries.add(entry);
157:                            } catch (Exception e) {
158:                                log.error(
159:                                        "ERROR processing subscription entry",
160:                                        e);
161:                            }
162:                        }
163:
164:                        return newEntries;
165:                    }
166:                } catch (Exception e) {
167:                    log.warn("Problem reading local feed", e);
168:                }
169:
170:                log.debug("Failed to fetch locally, trying remote "
171:                        + sub.getFeedURL());
172:
173:                // if there was an error then try normal planet method
174:                return super.getNewEntries(sub, feedFetcher, feedInfoCache);
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.