You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/05/31 12:34:03 UTC
svn commit: r410494 [1/2] - in /incubator/roller/branches/roller_3.0: ./
src/org/apache/roller/business/hibernate/
src/org/apache/roller/business/search/operations/
src/org/apache/roller/model/ src/org/apache/roller/pojos/
src/org/apache/roller/ui/admi...
Author: snoopdave
Date: Wed May 31 03:34:01 2006
New Revision: 410494
URL: http://svn.apache.org/viewvc?rev=410494&view=rev
Log:
More work on Atlas frontpage queries and new page models
Modified:
incubator/roller/branches/roller_3.0/build.xml
incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernatePlanetManagerImpl.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRefererManagerImpl.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRollerPlanetManagerImpl.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetSubscriptionData.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/ajax/UserDataServlet.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/ExportEntriesAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryManagementAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/BigWeblogCalendarModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/WeblogCalendarModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/ContextLoader.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/SitePageModel.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/util/cache/FuturePostingsInvalidationJob.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/atomprotocol/RollerAtomHandler.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/xmlrpc/BloggerAPIHandler.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/webservices/xmlrpc/MetaWeblogAPIHandler.java
incubator/roller/branches/roller_3.0/tests/org/apache/roller/business/WeblogEntryTest.java
incubator/roller/branches/roller_3.0/tests/org/apache/roller/ui/rendering/velocity/ExportRssTest.java
incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties
Modified: incubator/roller/branches/roller_3.0/build.xml
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/build.xml?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/build.xml (original)
+++ incubator/roller/branches/roller_3.0/build.xml Wed May 31 03:34:01 2006
@@ -260,6 +260,8 @@
<include name="org/apache/roller/pojos/WeblogEntryData.java"/>
<include name="org/apache/roller/pojos/WeblogCategoryData.java"/>
<include name="org/apache/roller/pojos/WebsiteData.java"/>
+ <include name="org/apache/roller/pojos/PlanetEntryData.java"/>
+ <include name="org/apache/roller/pojos/PlanetSubscriptionData.java"/>
</fileset>
<template
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernatePlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernatePlanetManagerImpl.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernatePlanetManagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernatePlanetManagerImpl.java Wed May 31 03:34:01 2006
@@ -191,43 +191,38 @@
"ERROR fetching subscription count", e);
}
}
-
+
public synchronized List getTopSubscriptions(int offset, int length)
throws RollerException {
- // TODO: ATLAS getTopSubscriptions DONE
- String groupHandle = NO_GROUP;
- List ret = null;
- try {
- Session session = ((HibernatePersistenceStrategy)strategy).getSession();
- Criteria criteria =
- session.createCriteria(PlanetSubscriptionData.class);
- criteria.addOrder(Order.desc("inboundblogs"));
- criteria.setFirstResult(offset);
- criteria.setMaxResults(length);
- ret = criteria.list();
- } catch (HibernateException e) {
- throw new RollerException(e);
- }
- return ret;
+ return getTopSubscriptions(null, offset, length);
}
public synchronized List getTopSubscriptions(
- PlanetGroupData group, int offset, int length)
+ String groupHandle, int offset, int length)
throws RollerException {
- // TODO: ATLAS getTopSubscriptions DONE
- String groupHandle = (group == null) ? NO_GROUP : group.getHandle();
List ret = null;
try {
Session session = ((HibernatePersistenceStrategy)strategy).getSession();
- Query query = session.createQuery(
+ Query query = null;
+ if (groupHandle != null) {
+ query = session.createQuery(
"select sub from org.apache.roller.pojos.PlanetSubscriptionData sub "
+"join sub.groupSubscriptionAssocs assoc "
+"where "
+"assoc.group.handle=:groupHandle "
+"order by sub.inboundblogs desc");
- query.setString("groupHandle", group.getHandle());
- query.setFirstResult(offset);
- query.setMaxResults(length);
+ query.setString("groupHandle", groupHandle);
+ } else {
+ query = session.createQuery(
+ "select sub from org.apache.roller.pojos.PlanetSubscriptionData sub "
+ +"order by sub.inboundblogs desc");
+ }
+ if (offset != 0) {
+ query.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ query.setMaxResults(length);
+ }
ret = query.list();
} catch (HibernateException e) {
throw new RollerException(e);
@@ -354,8 +349,7 @@
public Date getLastUpdated(PlanetGroupData group) {
return (Date)lastUpdatedByGroup.get(group);
}
-
-
+
public void refreshEntries() throws RollerException {
Roller roller = RollerFactory.getRoller();
@@ -456,8 +450,7 @@
log.info("--- DONE --- Refreshed entries in "
+ ((endTime-startTime)/1000.0) + " seconds");
}
-
-
+
protected Set getNewEntries(PlanetSubscriptionData sub,
FeedFetcher feedFetcher,
FeedFetcherCache feedInfoCache)
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRefererManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRefererManagerImpl.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRefererManagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRefererManagerImpl.java Wed May 31 03:34:01 2006
@@ -20,9 +20,6 @@
*/
package org.apache.roller.business.hibernate;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -47,9 +44,6 @@
import org.apache.roller.pojos.WeblogEntryData;
import org.apache.roller.pojos.WebsiteData;
import org.apache.roller.pojos.WebsiteDisplayData;
-import org.hibernate.dialect.DB2Dialect;
-import org.hibernate.dialect.DerbyDialect;
-import org.hibernate.dialect.HSQLDialect;
import org.hibernate.dialect.OracleDialect;
import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.engine.SessionFactoryImplementor;
@@ -58,6 +52,7 @@
import org.apache.roller.model.RollerFactory;
import org.apache.roller.model.UserManager;
import org.apache.roller.model.WeblogManager;
+import org.apache.roller.pojos.StatCount;
import org.apache.roller.util.DateUtil;
import org.apache.roller.util.LinkbackExtractor;
import org.apache.roller.util.Utilities;
@@ -264,8 +259,56 @@
}
/**
- * Return most popular websites based on dayhits, in descending order.
- * @returns List of WebsiteDisplayData objects
+ * Returns hot weblogs as StatCount objects, in descending order by today's hits.
+ */
+ public List getHotWeblogs(int sinceDays, int offset, int length)
+ throws RollerException {
+ // TODO: ATLAS getDaysPopularWebsites DONE TESTED
+ String msg = "Getting hot weblogs";
+ ArrayList result = new ArrayList();
+ try {
+ Session session =
+ ((HibernatePersistenceStrategy)strategy).getSession();
+ Query query = session.createQuery(
+ "select sum(r.dayHits) as s, w.id, w.name, w.handle "
+ +"from WebsiteData w, RefererData r "
+ +"where r.website=w and w.enabled=true and w.active=true "
+ +"group by w.name, w.handle, w.id order by col_0_0_ desc");
+
+ // +"group by w.name, w.handle, w.id order by s desc");
+ // The above would be *much* better but "HQL parser does not
+ // resolve alias in ORDER BY clause" (See Hibernate issue HHH-892)
+
+ if (offset != 0) {
+ query.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ query.setMaxResults(length);
+ }
+ Iterator rawResults = query.list().iterator();
+ for (Iterator it = query.list().iterator(); it.hasNext();) {
+ Object[] row = (Object[])it.next();
+ Integer hits = (Integer)row[0];
+ String websiteId = (String)row[1];
+ String websiteName = (String)row[2];
+ String websiteHandle = (String)row[3];
+ result.add(new StatCount(
+ websiteId,
+ websiteHandle,
+ websiteName,
+ "statCount.weblogDayHits",
+ (long)hits));
+ }
+ return result;
+
+ } catch (Throwable pe) {
+ log.error(msg, pe);
+ throw new RollerException(msg, pe);
+ }
+ }
+
+ /**
+ * @deprecated Replaced by getHotWeblogs().
*/
public List getDaysPopularWebsites(int sinceDays, int offset, int length)
throws RollerException {
@@ -285,8 +328,12 @@
// The above would be *much* better but "HQL parser does not
// resolve alias in ORDER BY clause" (See Hibernate issue HHH-892)
- query.setFirstResult(offset);
- query.setMaxResults(length);
+ if (offset != 0) {
+ query.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ query.setMaxResults(length);
+ }
Iterator rawResults = query.list().iterator();
for (Iterator it = query.list().iterator(); it.hasNext();) {
Object[] row = (Object[])it.next();
@@ -301,92 +348,6 @@
hits));
}
return result;
-
- /* The old raw SQL way:
- List list = new ArrayList();
- Session ses = ((HibernatePersistenceStrategy)strategy).getSession();
- Connection con = ses.connection();
- final PreparedStatement stmt;
- Dialect currentDialect = ((SessionFactoryImplementor)ses.getSessionFactory()).getDialect();
- if (currentDialect instanceof HSQLDialect) {
- // special handling for HSQLDB
- stmt = con.prepareStatement(
- "select top ? w.id, w.name, w.handle, sum(r.dayhits) as s "+
- "from website as w, referer as r "+
- "where r.websiteid=w.id and w.isenabled=? and w.isactive=? " +
- "group by w.name, w.handle, w.id order by s desc");
- stmt.setInt(1, len);
- stmt.setBoolean(2, true);
- stmt.setBoolean(3, true);
- } else if(currentDialect instanceof DerbyDialect) {
- // special handling for Derby
- stmt = con.prepareStatement(
- "select w.id, w.name, w.handle, sum(r.dayhits) as s "+
- "from website as w, referer as r "+
- "where r.websiteid=w.id and w.isenabled=? and w.isactive=? " +
- "group by w.name, w.handle, w.id order by s desc");
- stmt.setBoolean(1, true);
- stmt.setBoolean(2, true);
- stmt.setMaxRows(len);
- } else if(currentDialect instanceof DB2Dialect) {
- // special handling for IBM DB2
- stmt = con.prepareStatement(
- "select w.id, w.name, w.handle, sum(r.dayhits) as s "+
- "from website as w, referer as r "+
- "where r.websiteid=w.id and w.isenabled=? and w.isactive=? " +
- "group by w.name, w.handle, w.id order by s desc fetch first " +
- Integer.toString(len) + " rows only");
- stmt.setBoolean(1, true);
- stmt.setBoolean(2, true);
- } else if (currentDialect instanceof OracleDialect) {
- stmt = con.prepareStatement(
- "select w.id, w.name, w.handle, sum(r.dayhits) as s "+
- "from website w, referer r "+
- "where r.websiteid=w.id and w.isenabled=? and w.isactive=? and rownum <= ? " +
- "group by w.name, w.handle, w.id order by s desc");
- stmt.setBoolean(1, true);
- stmt.setBoolean(2, true);
- stmt.setInt(3, len );
- } else if (currentDialect instanceof SQLServerDialect) {
- stmt = con.prepareStatement("select top " + len + " w.id, w.name, w.handle, sum(r.dayhits) as s " +
- "from website as w, referer as r where r.websiteid=w.id and w.isenabled=? and w.isactive=? " +
- "group by w.name, w.handle, w.id order by s desc");
- stmt.setBoolean(1, true);
- stmt.setBoolean(2, true);
- } else { // for MySQL and PostgreSQL
- stmt = con.prepareStatement(
- "select w.id, w.name, w.handle, sum(r.dayhits) as s "+
- "from website as w, referer as r "+
- "where r.websiteid=w.id and w.isenabled= ? and w.isactive=? " +
- // Ben Walding (a Postgres SQL user): Basically, you have
- // to have all non-aggregated columns that exist in your
- // 'SELECT' section, in the 'GROUP BY' section as well:
- "group by w.name, w.handle, w.id order by s desc limit ?");
- stmt.setBoolean(1, true);
- stmt.setBoolean(2, true);
- stmt.setInt(3, len);
- }
- ResultSet rs = stmt.executeQuery();
- if ( rs.next() ) {
- do
- {
- String websiteId = rs.getString(1);
- String websiteName = rs.getString(2);
- String websiteHandle = rs.getString(3);
- Integer hits = new Integer(rs.getInt(4));
- list.add(new WebsiteDisplayData(
- websiteId,
- websiteName,
- websiteHandle,
- hits));
- if(list.size() >= len) {
- rs.close();
- break;
- }
- }
- while ( rs.next() );
- }
- return list; */
} catch (Throwable pe) {
log.error(msg, pe);
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRollerPlanetManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRollerPlanetManagerImpl.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRollerPlanetManagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateRollerPlanetManagerImpl.java Wed May 31 03:34:01 2006
@@ -115,12 +115,14 @@
"site.newsfeeds.defaultEntries");
entries = blogmgr.getWeblogEntries(
website,
+ null,
null, // startDate
new Date(), // endDate
null, // catName
WeblogEntryData.PUBLISHED, // status
null, // sortby (null means pubTime)
- new Integer(entryCount)); // maxEntries
+ 0, // offset
+ entryCount); // length
sub.setLastUpdated(siteUpdated);
saveSubscription(sub);
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java Wed May 31 03:34:01 2006
@@ -220,7 +220,7 @@
// TODO BACKEND: we must do this in a better fashion, like getUserCnt()?
boolean adminUser = false;
- List existingUsers = this.getUsers();
+ List existingUsers = this.getUsers(0, 1);
if(existingUsers.size() == 0) {
// Make first user an admin
adminUser = true;
@@ -463,8 +463,13 @@
if (active != null) {
criteria.add(Expression.eq("active", active));
}
- criteria.setFirstResult(offset);
- criteria.setMaxResults(length);
+ if (offset != 0) {
+ criteria.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ criteria.setMaxResults(length);
+ }
+ criteria.addOrder(Order.desc("dateCreated"));
return criteria.list();
} catch (HibernateException e) {
throw new RollerException(e);
@@ -532,11 +537,11 @@
}
}
- public List getUsers() throws RollerException {
- return getUsers(Boolean.TRUE);
+ public List getUsers(int offset, int length) throws RollerException {
+ return getUsers(Boolean.TRUE, offset, length);
}
- public List getUsers(Boolean enabled) throws RollerException {
+ public List getUsers(Boolean enabled, int offset, int length) throws RollerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -544,7 +549,12 @@
if (enabled != null) {
criteria.add(Expression.eq("enabled", enabled));
}
-
+ if (offset != 0) {
+ criteria.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ criteria.setMaxResults(length);
+ }
return criteria.list();
} catch (HibernateException e) {
throw new RollerException(e);
@@ -554,7 +564,7 @@
/**
* Get users of a website
*/
- public List getUsers(WebsiteData website, Boolean enabled) throws RollerException {
+ public List getUsers(WebsiteData website, Boolean enabled, int offset, int length) throws RollerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -566,14 +576,20 @@
if (enabled != null) {
criteria.add(Expression.eq("enabled", enabled));
}
+ if (offset != 0) {
+ criteria.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ criteria.setMaxResults(length);
+ }
return criteria.list();
} catch (HibernateException e) {
throw new RollerException(e);
}
}
- public List getUsersStartingWith(String startsWith,
- int offset, int length, Boolean enabled) throws RollerException {
+ public List getUsersStartingWith(String startsWith, Boolean enabled,
+ int offset, int length) throws RollerException {
List results = new ArrayList();
try {
@@ -588,8 +604,12 @@
.add(Expression.like("userName", startsWith, MatchMode.START))
.add(Expression.like("emailAddress", startsWith, MatchMode.START)));
}
- criteria.setFirstResult(offset);
- criteria.setMaxResults(length);
+ if (offset != 0) {
+ criteria.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ criteria.setMaxResults(length);
+ }
results = criteria.list();
} catch (HibernateException e) {
throw new RollerException(e);
@@ -800,8 +820,12 @@
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
Criteria criteria = session.createCriteria(UserData.class);
criteria.add(Expression.like("userName", new String(new char[]{letter}) + "%", MatchMode.START));
- criteria.setFirstResult(offset);
- criteria.setMaxResults(length);
+ if (offset != 0) {
+ criteria.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ criteria.setMaxResults(length);
+ }
return criteria.list();
} catch (HibernateException e) {
throw new RollerException(e);
@@ -839,8 +863,12 @@
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
Criteria criteria = session.createCriteria(WebsiteData.class);
criteria.add(Expression.like("handle", new String(new char[]{letter}) + "%", MatchMode.START));
- criteria.setFirstResult(offset);
- criteria.setMaxResults(length);
+ if (offset != 0) {
+ criteria.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ criteria.setMaxResults(length);
+ }
return criteria.list();
} catch (HibernateException e) {
throw new RollerException(e);
@@ -858,8 +886,12 @@
"select count(distinct c), c.weblogEntry.website.id, c.weblogEntry.website.name, c.weblogEntry.website.description "
+"from CommentData c group by c.weblogEntry.website.id, c.weblogEntry.website.name, c.weblogEntry.website.description "
+"order by col_0_0_ desc");
- query.setFirstResult(offset);
- query.setMaxResults(length);
+ if (offset != 0) {
+ query.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ query.setMaxResults(length);
+ }
List results = new ArrayList();
for (Iterator iter = query.list().iterator(); iter.hasNext();) {
Object[] row = (Object[]) iter.next();
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/hibernate/HibernateWeblogManagerImpl.java Wed May 31 03:34:01 2006
@@ -55,6 +55,7 @@
import org.hibernate.criterion.MatchMode;
import org.apache.roller.model.WeblogManager;
import org.apache.roller.pojos.StatCount;
+import org.apache.roller.pojos.UserData;
import org.apache.roller.util.DateUtil;
import org.apache.roller.util.Utilities;
@@ -395,12 +396,15 @@
public List getWeblogEntries(
WebsiteData website,
- Date startDate,
- Date endDate,
- String catName,
- String status,
- String sortby,
- Integer maxEntries) throws RollerException {
+ UserData user,
+ Date startDate,
+ Date endDate,
+ String catName,
+ String status,
+ String sortby,
+ int offset,
+ int length) throws RollerException {
+
WeblogCategoryData cat = null;
if (StringUtils.isNotEmpty(catName) && website != null) {
cat = getWeblogCategoryByPath(website, catName);
@@ -421,6 +425,10 @@
criteria.add(Expression.eq("w.enabled", Boolean.TRUE));
}
+ if (user != null) {
+ criteria.add(Expression.eq("creator", user));
+ }
+
if (startDate != null) {
criteria.add(
Expression.ge("pubTime", startDate));
@@ -445,10 +453,14 @@
criteria.addOrder(Order.desc("pubTime"));
}
- if (maxEntries != null) {
- criteria.setMaxResults(maxEntries.intValue());
+ if (offset != 0) {
+ criteria.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ criteria.setMaxResults(length);
}
return criteria.list();
+
} catch (HibernateException e) {
log.error(e);
throw new RollerException(e);
@@ -921,34 +933,7 @@
return (WeblogEntryData) this.strategy.load(
id, WeblogEntryData.class);
}
-
- public List getWeblogEntries(
- WebsiteData website,
- Date startDate,
- Date endDate,
- String catName,
- String status,
- String sortby,
- int offset,
- int range) throws RollerException {
- List filtered = new ArrayList();
- List entries = getWeblogEntries(
- website,
- startDate,
- endDate,
- catName,
- status,
- sortby,
- new Integer(offset + range));
- if (entries.size() < offset) {
- return entries;
- }
- for (int i=offset; i<entries.size(); i++) {
- filtered.add(entries.get(i));
- }
- return filtered;
- }
-
+
/**
* Gets the Date of the latest Entry publish time, before the end of today,
* for all WeblogEntries
@@ -963,15 +948,13 @@
Date startDate,
Date endDate,
String catName,
- String status,
- Integer maxEntries) throws RollerException {
+ String status) throws RollerException {
return getWeblogEntryMap(
website,
startDate,
endDate,
catName,
status,
- maxEntries,
false);
}
@@ -980,15 +963,13 @@
Date startDate,
Date endDate,
String catName,
- String status,
- Integer maxEntries) throws RollerException {
+ String status) throws RollerException {
return getWeblogEntryMap(
website,
startDate,
endDate,
catName,
status,
- maxEntries,
true);
}
@@ -998,18 +979,18 @@
Date endDate,
String catName,
String status,
- Integer maxEntries,
boolean stringsOnly) throws RollerException {
TreeMap map = new TreeMap(reverseComparator);
List entries = getWeblogEntries(
- website,
- startDate,
- endDate,
- catName,
- status,
- null,
- maxEntries);
+ website,
+ null,
+ startDate,
+ endDate,
+ catName,
+ status,
+ null,
+ 0, Integer.MAX_VALUE);
Calendar cal = Calendar.getInstance();
if (website != null) {
@@ -1055,8 +1036,12 @@
+"from CommentData c group by c.weblogEntry.id, c.weblogEntry.anchor, c.weblogEntry.title "
+"order by col_0_0_ desc");
}
- query.setFirstResult(offset);
- query.setMaxResults(length);
+ if (offset != 0) {
+ query.setFirstResult(offset);
+ }
+ if (length != Integer.MAX_VALUE) {
+ query.setMaxResults(length);
+ }
List results = new ArrayList();
for (Iterator iter = query.list().iterator(); iter.hasNext();) {
Object[] row = (Object[]) iter.next();
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/business/search/operations/RebuildWebsiteIndexOperation.java Wed May 31 03:34:01 2006
@@ -103,13 +103,14 @@
WeblogManager weblogManager = roller.getWeblogManager();
List entries = weblogManager .getWeblogEntries(
- website, // userName
+ website, // website
+ null,
null, // startDate
new Date(), // endDate (don't index 'future' entries)
null, // catName
WeblogEntryData.PUBLISHED, // status
- null, // sortby (null mean pubTime)
- null); // maxEntries (null to get 'em all)
+ null, // sortby (null means pubTime)
+ 0, Integer.MAX_VALUE); // offset, length
for (Iterator wbItr = entries.iterator(); wbItr.hasNext();) {
WeblogEntryData entry = (WeblogEntryData) wbItr.next();
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/PlanetManager.java Wed May 31 03:34:01 2006
@@ -116,7 +116,7 @@
* Get top X subscriptions, restricted by group.
*/
public List getTopSubscriptions(
- PlanetGroupData group, int offset, int len) throws RollerException;
+ String groupHandle, int offset, int len) throws RollerException;
/**
* Get entries in a single feed as list of PlanetEntryData objects.
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/RefererManager.java Wed May 31 03:34:01 2006
@@ -84,9 +84,19 @@
* @param len Maximum number of results to return (for paging)
* @return List of WebsiteDisplayData objects.
*/
- public List getDaysPopularWebsites(int sinceDays, int offset, int len)
- throws RollerException;
+ public List getDaysPopularWebsites(int sinceDays, int offset, int length)
+ throws RollerException;
+ /**
+ * Returns hot weblogs as StatCount objects, in descending order by today's hits.
+ * @param sinceDays Restrict to last X days (or -1 for all)
+ * @param offset Offset into results (for paging)
+ * @param len Maximum number of results to return (for paging)
+ * @return List of StatCount objects.
+ */
+ public List getHotWeblogs(int sinceDays, int offset, int length)
+ throws RollerException;
+
/**
* Get referers that refer to a specific weblog entry.
* @param entryid Weblog entry ID
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/UserManager.java Wed May 31 03:34:01 2006
@@ -68,14 +68,14 @@
/**
* Get all enabled users
*/
- public List getUsers() throws RollerException;
+ public List getUsers(int offset, int length) throws RollerException;
/**
* Get all users, optionally include dis-enabled users.
*
* @param enabled True for enabled only, false for disabled only, null for all
*/
- public List getUsers(Boolean enabled) throws RollerException;
+ public List getUsers(Boolean enabled, int offset, int length) throws RollerException;
/**
* Get all users or a website.
@@ -83,7 +83,7 @@
* @param website Get all users of this website (or null for all)
* @returns List of UserData objects.
*/
- public List getUsers(WebsiteData website, Boolean enabled) throws RollerException;
+ public List getUsers(WebsiteData website, Boolean enabled, int offset, int length) throws RollerException;
/**
* Returns users whose usernames or email addresses start with a string.
@@ -94,7 +94,7 @@
* @return List of (up to length) users that match startsWith string
*/
public List getUsersStartingWith(String startsWith,
- int offset, int length, Boolean enabled) throws RollerException;
+ Boolean enabled, int offset, int length) throws RollerException;
/**
* Get map with 26 entries, one for each letter A-Z and
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/model/WeblogManager.java Wed May 31 03:34:01 2006
@@ -18,14 +18,13 @@
package org.apache.roller.model;
-import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.apache.roller.RollerException;
import org.apache.roller.pojos.Assoc;
import org.apache.roller.pojos.CommentData;
-import org.apache.roller.pojos.WeblogCategoryAssoc;
+import org.apache.roller.pojos.UserData;
import org.apache.roller.pojos.WeblogCategoryData;
import org.apache.roller.pojos.WeblogEntryData;
import org.apache.roller.pojos.WebsiteData;
@@ -74,39 +73,16 @@
*/
public List getWeblogEntries(
WebsiteData website,
- Date startDate,
- Date endDate,
- String catName,
- String status,
- String sortBy,
- int offset,
- int range)
+ UserData user,
+ Date startDate,
+ Date endDate,
+ String catName,
+ String status,
+ String sortBy,
+ int offset,
+ int range)
throws RollerException;
-
- /**
- * Get WeblogEntries up to limit as list in reverse chronological order.
- * The range offset and list arguments enable paging through query results.
- * @param userName User name or null to get for all users.
- * @param startDate Start date or null for no start date.
- * @param endDate End date or null for no end date.
- * @param catName Category path or null for all categories.
- * @param status Status of DRAFT, PENDING, PUBLISHED or null for all
- * @param sortby Sort by either 'pubTime' or 'updateTime' (null for pubTime)
- * @param offset Index of first entry to include.
- * @param maxEntries Max number of entries to include.
- * @return List of WeblogEntryData objects in reverse chrono order.
- * @throws RollerException
- */
- public List getWeblogEntries(
- WebsiteData website,
- Date startDate,
- Date endDate,
- String catName,
- String status,
- String sortBy,
- Integer maxEntries)
- throws RollerException;
-
+
/**
* Get Weblog Entries grouped by day. This method returns a Map that
* contains Lists, each List contains WeblogEntryData objects, and the
@@ -122,11 +98,10 @@
*/
public Map getWeblogEntryObjectMap(
WebsiteData website,
- Date startDate,
- Date endDate,
- String catName,
- String status,
- Integer maxEntries)
+ Date startDate,
+ Date endDate,
+ String catName,
+ String status)
throws RollerException;
/**
@@ -147,8 +122,7 @@
Date startDate,
Date endDate,
String catName,
- String status,
- Integer maxEntries)
+ String status)
throws RollerException;
/**
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetEntryData.java Wed May 31 03:34:01 2006
@@ -173,6 +173,7 @@
/**
* @hibernate.id column="id"
* generator-class="uuid.hex" unsaved-value="null"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getId() {
return id;
@@ -182,6 +183,7 @@
}
/**
* @hibernate.property column="categories" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getCategoriesString() {
return categoriesString;
@@ -200,6 +202,7 @@
}
/**
* @hibernate.property column="author" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getAuthor() {
return author;
@@ -209,6 +212,7 @@
}
/**
* @hibernate.property column="content" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getText() {
return text;
@@ -218,6 +222,7 @@
}
/**
* @hibernate.property column="guid" non-null="false" unique="true"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getGuid() {
return guid;
@@ -227,6 +232,7 @@
}
/**
* @hibernate.property column="handle" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getHandle() {
return handle;
@@ -236,6 +242,7 @@
}
/**
* @hibernate.property column="published" non-null="true" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public Timestamp getPubTime() {
return published;
@@ -245,6 +252,7 @@
}
/**
* @hibernate.property column="permalink" non-null="true" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getPermaLink() {
return permalink;
@@ -254,6 +262,7 @@
}
/**
* @hibernate.property column="title" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getTitle() {
return title;
@@ -263,6 +272,7 @@
}
/**
* @hibernate.property column="updated" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public Timestamp getUpdateTime() {
return updated;
@@ -288,7 +298,7 @@
return false;
}
- //------------------------------------------------------------- implemenatation
+ //------------------------------------------------------------- implementation
/**
* Returns categories as list of WeblogCategoryData objects.
@@ -332,6 +342,7 @@
/**
* Returns creator as a UserData object.
+ * @roller.wrapPojoMethod type="pojo"
* TODO: make planet model entry author name, email, and uri
*/
public UserData getCreator() {
@@ -346,7 +357,7 @@
/**
* Returns summary (always null for planet entry)
- * TODO: make planet model entry.summary
+ * @roller.wrapPojoMethod type="simple"
*/
public String getSummary() {
return null;
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetSubscriptionData.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetSubscriptionData.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetSubscriptionData.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/pojos/PlanetSubscriptionData.java Wed May 31 03:34:01 2006
@@ -78,6 +78,7 @@
/**
* @hibernate.id column="id"
* generator-class="uuid.hex" unsaved-value="null"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getId()
{
@@ -102,6 +103,7 @@
}
/**
* @hibernate.property column="feed_url" non-null="true" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getFeedUrl()
{
@@ -113,6 +115,7 @@
}
/**
* @hibernate.property column="last_updated" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public Date getLastUpdated()
{
@@ -124,6 +127,7 @@
}
/**
* @hibernate.property column="site_url" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getSiteUrl()
{
@@ -135,6 +139,7 @@
}
/**
* @hibernate.property column="title" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getTitle()
{
@@ -146,6 +151,7 @@
}
/**
* @hibernate.property column="author" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public String getAuthor()
{
@@ -157,6 +163,7 @@
}
/**
* @hibernate.property column="inbound_links" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public int getInboundlinks()
{
@@ -168,6 +175,7 @@
}
/**
* @hibernate.property column="inbound_blogs" non-null="false" unique="false"
+ * @roller.wrapPojoMethod type="simple"
*/
public int getInboundblogs()
{
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/admin/struts/actions/PlanetAction.java Wed May 31 03:34:01 2006
@@ -1,20 +1,20 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
package org.apache.roller.ui.admin.struts.actions;
import java.util.ArrayList;
@@ -44,156 +44,129 @@
* @struts.action name="main" path="/planet" scope="request"
* @struts.action-forward name="planet.page" path=".planet"
*/
-public class PlanetAction extends Action
-{
- private static Log mLogger =
- LogFactory.getFactory().getInstance(PlanetAction.class);
- private static ResourceBundle bundle =
- ResourceBundle.getBundle("ApplicationResources");
+public class PlanetAction extends Action {
+ private static Log mLogger =
+ LogFactory.getFactory().getInstance(PlanetAction.class);
+ private static ResourceBundle bundle =
+ ResourceBundle.getBundle("ApplicationResources");
- /**
- * Loads model and forwards to planet.page.
- */
- public ActionForward execute(
- ActionMapping mapping, ActionForm form,
- HttpServletRequest req, HttpServletResponse res)
- throws Exception
- {
- RollerContext rctx = RollerContext.getRollerContext();
+ /**
+ * Loads model and forwards to planet.page.
+ */
+ public ActionForward execute(
+ ActionMapping mapping, ActionForm form,
+ HttpServletRequest req, HttpServletResponse res)
+ throws Exception {
+ RollerContext rctx = RollerContext.getRollerContext();
req.setAttribute("version",rctx.getRollerVersion());
req.setAttribute("buildTime",rctx.getRollerBuildTime());
req.setAttribute("baseURL", rctx.getContextUrl(req));
req.setAttribute("data", new PlanetPageData(req));
- boolean allowNewUsers =
- RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
-
+ boolean allowNewUsers =
+ RollerRuntimeConfig.getBooleanProperty("users.registration.enabled");
+
java.security.Principal prince = req.getUserPrincipal();
- if (prince != null)
- {
+ if (prince != null) {
req.setAttribute("loggedIn",Boolean.TRUE);
req.setAttribute("userName",prince.getName());
- }
- else if (allowNewUsers)
- {
+ } else if (allowNewUsers) {
req.setAttribute("allowNewUsers",Boolean.TRUE);
}
req.setAttribute("leftPage","/theme/status.jsp");
return mapping.findForward("planet.page");
- }
-
+ }
+
/**
- * Page model.
+ * Page model.
*/
- public static class PlanetPageData
- {
+ public static class PlanetPageData {
private HttpServletRequest mRequest = null;
- private String mTitle =
+ private String mTitle =
bundle.getString("planet.title.unconfigured");
- private String mDescription =
+ private String mDescription =
bundle.getString("planet.description.unconfigured");
public String getTitle() {return mTitle;}
public String getDescription() {return mDescription;}
- public PlanetPageData(HttpServletRequest req) throws RollerException
- {
- mRequest = req;
- Roller roller = RollerFactory.getRoller();
- PlanetConfigData cfg = roller.getPlanetManager().getConfiguration();
- if (cfg != null)
- {
- mTitle = cfg.getTitle();
- mDescription = cfg.getDescription();
- }
+ public PlanetPageData(HttpServletRequest req) throws RollerException {
+ mRequest = req;
+ Roller roller = RollerFactory.getRoller();
+ PlanetConfigData cfg = roller.getPlanetManager().getConfiguration();
+ if (cfg != null) {
+ mTitle = cfg.getTitle();
+ mDescription = cfg.getDescription();
+ }
}
- /**
+ /**
* Get aggregation of entries in 'all' and 'external' groups
*/
- public List getAggregation(int num) throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
+ public List getAggregation(int num) throws RollerException {
+ Roller roller = RollerFactory.getRoller();
return roller.getPlanetManager().getAggregation(0, num);
}
- /**
+ /**
* Get named group
*/
- public PlanetGroupData getGroup(String name) throws RollerException
- {
+ public PlanetGroupData getGroup(String name) throws RollerException {
PlanetGroupData group = null;
- try
- {
- Roller roller = RollerFactory.getRoller();
+ try {
+ Roller roller = RollerFactory.getRoller();
group = roller.getPlanetManager().getGroup(name);
- }
- catch (RollerException e)
- {
- mLogger.error(e);
+ } catch (RollerException e) {
+ mLogger.error(e);
}
return group;
}
- /**
+ /**
* Get aggregation of entries in named group
*/
- public List getAggregation(String name, int num) throws RollerException
- {
+ public List getAggregation(String name, int num) throws RollerException {
List ret = new ArrayList();
- try
- {
- Roller roller = RollerFactory.getRoller();
+ try {
+ Roller roller = RollerFactory.getRoller();
PlanetGroupData group= roller.getPlanetManager().getGroup(name);
ret = roller.getPlanetManager().getAggregation(group, 0, num);
- }
- catch (RollerException e)
- {
- mLogger.error(e);
+ } catch (RollerException e) {
+ mLogger.error(e);
}
return ret;
}
/**
* Get top blogs according to Technorati
*/
- public List getTopSubscriptions(int num) throws RollerException
- {
+ public List getTopSubscriptions(int num) throws RollerException {
List ret = new ArrayList();
- try
- {
- Roller roller = RollerFactory.getRoller();
+ try {
+ Roller roller = RollerFactory.getRoller();
ret = roller.getPlanetManager().getTopSubscriptions(0, num);
- }
- catch (RollerException e)
- {
- mLogger.error(e);
+ } catch (RollerException e) {
+ mLogger.error(e);
}
return ret;
}
/**
* Get top blogs in a group according to Technorati
*/
- public List getTopSubscriptions(String name, int num)
- throws RollerException
- {
+ public List getTopSubscriptions(String name, int num)
+ throws RollerException {
List ret = new ArrayList();
- try
- {
- Roller roller = RollerFactory.getRoller();
- PlanetGroupData group= roller.getPlanetManager().getGroup(name);
- ret = roller.getPlanetManager().getTopSubscriptions(group, 0, num);
- }
- catch (RollerException e)
- {
- mLogger.error(e);
+ try {
+ Roller roller = RollerFactory.getRoller();
+ ret = roller.getPlanetManager().getTopSubscriptions(name, 0, num);
+ } catch (RollerException e) {
+ mLogger.error(e);
}
return ret;
}
- /**
+ /**
* Get list of most popular websites in terms of day hits.
*/
- public List getPopularWebsites(int num) throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
+ public List getPopularWebsites(int num) throws RollerException {
+ Roller roller = RollerFactory.getRoller();
return roller.getRefererManager().getDaysPopularWebsites(-1, 0, num);
}
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/ajax/UserDataServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/ajax/UserDataServlet.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/ajax/UserDataServlet.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/ajax/UserDataServlet.java Wed May 31 03:34:01 2006
@@ -69,7 +69,7 @@
try {
UserManager umgr = roller.getUserManager();
List users =
- umgr.getUsersStartingWith(startsWith, offset, length, enabledOnly);
+ umgr.getUsersStartingWith(startsWith, enabledOnly, offset, length);
Iterator userIter = users.iterator();
while (userIter.hasNext()) {
UserData user = (UserData)userIter.next();
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/ExportEntriesAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/ExportEntriesAction.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/ExportEntriesAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/ExportEntriesAction.java Wed May 31 03:34:01 2006
@@ -181,12 +181,13 @@
List entries = weblogMgr.getWeblogEntries(
rreq.getWebsite(), // userName
+ null,
startDate, // startDate
endDate, // endDate
null, // catName
null, // status
null, // sortby (null for pubtime)
- null); // maxEntries
+ 0, Integer.MAX_VALUE);
ActionMessages messages = writeSuccessMessage(request, response, rreq, form);
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java Wed May 31 03:34:01 2006
@@ -408,8 +408,8 @@
// list of enabled website authors and admins
ArrayList reviewers = new ArrayList();
- List websiteUsers =
- umgr.getUsers(entry.getWebsite(), Boolean.TRUE);
+ List websiteUsers = umgr.getUsers(
+ entry.getWebsite(), Boolean.TRUE, 0, Integer.MAX_VALUE);
// build list of reviewers (website users with author permission)
Iterator websiteUserIter = websiteUsers.iterator();
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryManagementAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryManagementAction.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryManagementAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryManagementAction.java Wed May 31 03:34:01 2006
@@ -149,6 +149,7 @@
entries = RollerFactory.getRoller().getWeblogManager().getWeblogEntries(
website,
+ null,
startDate,
endDate,
category,
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryPageModel.java Wed May 31 03:34:01 2006
@@ -132,12 +132,13 @@
return RollerFactory.getRoller().getWeblogManager()
.getWeblogEntries(
getWeblogEntry().getWebsite(), // userName
+ null,
null, // startDate
null, // endDate
null, // catName
WeblogEntryData.PUBLISHED, // status
null, // sortby (null for pubTime)
- new Integer(20)); // maxEntries
+ 0, 20);
}
/**
@@ -152,12 +153,13 @@
return RollerFactory.getRoller().getWeblogManager()
.getWeblogEntries(
getWeblogEntry().getWebsite(),
+ null,
null, // startDate
null, // endDate
null, // catName
WeblogEntryData.DRAFT, // status
"updateTime", // sortby
- new Integer(20)); // maxEntries
+ 0, 20); // maxEntries
}
/**
@@ -172,12 +174,13 @@
return RollerFactory.getRoller().getWeblogManager()
.getWeblogEntries(
getWeblogEntry().getWebsite(),
+ null,
null, // startDate
null, // endDate
null, // catName
WeblogEntryData.PENDING, // status
"updateTime", // sortby
- new Integer(20)); // maxEntries
+ 0, 20);
}
public List getHoursList()
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/BigWeblogCalendarModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/BigWeblogCalendarModel.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/BigWeblogCalendarModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/BigWeblogCalendarModel.java Wed May 31 03:34:01 2006
@@ -71,12 +71,11 @@
{
WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
mMonthMap = mgr.getWeblogEntryObjectMap(
- mRollerReq.getWebsite(), // userName
- startDate, // startDate
- endDate, // endDate
- catName, // catName
- WeblogEntryData.PUBLISHED, // status
- null
+ mRollerReq.getWebsite(), // website
+ startDate, // startDate
+ endDate, // endDate
+ catName, // catName
+ WeblogEntryData.PUBLISHED // status
);
}
catch (RollerException e)
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/WeblogCalendarModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/WeblogCalendarModel.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/WeblogCalendarModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/tags/WeblogCalendarModel.java Wed May 31 03:34:01 2006
@@ -143,12 +143,11 @@
{
WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
mMonthMap = mgr.getWeblogEntryStringMap(
- mRollerReq.getWebsite(), // userName
- startDate, // startDate
- endDate, // endDate
- catName, // catName
- WeblogEntryData.PUBLISHED, // status
- null
+ mRollerReq.getWebsite(), // website
+ startDate, // startDate
+ endDate, // endDate
+ catName, // catName
+ WeblogEntryData.PUBLISHED // status
);
}
catch (RollerException e)
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/MainPageAction.java Wed May 31 03:34:01 2006
@@ -117,12 +117,13 @@
Roller roller = RollerFactory.getRoller();
list = roller.getWeblogManager().getWeblogEntries(
null, // userName
+ null,
null, // startDate
new Date(), // endDate
null, // catName
WeblogEntryData.PUBLISHED, // status
null, // sortby (null for pubTime)
- new Integer(num)); // maxEntries
+ 0, num); // maxEntries
} catch (Exception e) {
mLogger.error(e);
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/ContextLoader.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/ContextLoader.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/ContextLoader.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/ContextLoader.java Wed May 31 03:34:01 2006
@@ -96,14 +96,23 @@
RollerContext rollerCtx = RollerContext.getRollerContext( );
try {
- // Add page model object to context
+ // Add default page model object to context
String pageModelClassName =
RollerConfig.getProperty("velocity.pagemodel.classname");
Class pageModelClass = Class.forName(pageModelClassName);
PageModel pageModel = (PageModel)pageModelClass.newInstance();
- pageModel.init(rreq);
+ pageModel.init(rreq);
ctx.put("pageModel", pageModel );
+
+ // Add other page models
+ // TODO: ATLAS make page models configurable
+ SitePageModel sitePageModel = new SitePageModel();
+ ctx.put("sitePageModel", sitePageModel);
+ PlanetPageModel planetPageModel = new PlanetPageModel();
+ ctx.put("planetPageModel", planetPageModel);
+
ctx.put("pages", pageModel.getPages());
+
} catch (Exception e) {
throw new RollerException("ERROR creating Page Model",e);
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageModel.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PageModel.java Wed May 31 03:34:01 2006
@@ -347,7 +347,7 @@
} else {
cal = Calendar.getInstance();
}
- Integer limit = new Integer(maxEntries);
+ int limit = maxEntries;
Date startDate = null;
Date endDate = mRollerReq.getDate();
if (endDate == null) endDate = new Date();
@@ -357,7 +357,7 @@
endDate = DateUtil.getEndOfDay(endDate, cal);
startDate = DateUtil.getStartOfDay(endDate, cal);
// and get them ALL, no limit
- limit = null;
+ limit = Integer.MAX_VALUE;
} else if (mRollerReq.isMonthSpecified()) {
endDate = DateUtil.getEndOfMonth(endDate, cal);
}
@@ -366,8 +366,7 @@
startDate, // startDate
endDate, // endDate
catParam, // catName
- WeblogEntryData.PUBLISHED, // status
- limit); // maxEntries
+ WeblogEntryData.PUBLISHED); // status
// need to wrap pojos
java.util.Date key = null;
@@ -464,12 +463,13 @@
List mEntries = mgr.getWeblogEntries(
mRollerReq.getWebsite(),
+ null,
null, // startDate
day, // endDate
catParam, // catName
WeblogEntryData.PUBLISHED, // status
null, // sortby (null for pubTime)
- new Integer(maxEntries)); // maxEntries
+ 0, maxEntries); // maxEntries
// wrap pojos
ret = new ArrayList(mEntries.size());
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java?rev=410494&r1=410493&r2=410494&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/rendering/velocity/PlanetPageModel.java Wed May 31 03:34:01 2006
@@ -18,41 +18,48 @@
package org.apache.roller.ui.rendering.velocity;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.roller.model.PlanetManager;
+import org.apache.roller.model.Roller;
import org.apache.roller.model.RollerFactory;
+import org.apache.roller.pojos.PlanetEntryData;
import org.apache.roller.pojos.PlanetGroupData;
import org.apache.roller.pojos.PlanetSubscriptionData;
-import org.apache.roller.ui.core.RollerRequest;
+import org.apache.roller.pojos.wrapper.PlanetEntryDataWrapper;
+import org.apache.roller.pojos.wrapper.PlanetSubscriptionDataWrapper;
/**
- * Allow Roller page templates to get the main Planet aggregation (the 'all'
- * and 'external' group), custom aggregations, specified by handle, and
- * subscription entries (specified by feedUrl).
- * @author Dave Johnson
+ * Page model that provides access to planet aggregations, feeds and
+ * subscriptions for display on a frontpage weblog.
*/
-public class PlanetPageModel extends PageModel {
- PlanetManager planetManager = null;
-
- public void init(RollerRequest rreq) {
- super.init(rreq);
- try {
- planetManager = RollerFactory.getRoller().getPlanetManager();
- } catch (Exception e) {
- mLogger.error("ERROR initializing page model",e);
- }
- }
+public class PlanetPageModel {
+ protected static Log log =
+ LogFactory.getFactory().getInstance(PlanetPageModel.class);
/**
- * Get move recent WeblogEntry objects from 'all' and
+ * Get move recent PlanetEntry objects from 'all' and
* 'exernal' Planet groups. in reverse chrono order.
* @param offset Offset into results (for paging)
* @param len Max number of results to return
*/
public List getAggregation(int offset, int len) {
- //return planetManager.getAggregation(offset, len);
- return null;
+ List results = new ArrayList();
+ try {
+ Roller roller = RollerFactory.getRoller();
+ PlanetManager planetManager = roller.getPlanetManager();
+ List entries = planetManager.getAggregation(offset, len);
+ for (Iterator it = entries.iterator(); it.hasNext();) {
+ PlanetEntryData entry = (PlanetEntryData) it.next();
+ PlanetEntryDataWrapper wrapped = PlanetEntryDataWrapper.wrap(entry);
+ results.add(wrapped);
+ }
+ } catch (Exception e) {
+ log.error("ERROR: get aggregation", e);
+ }
+ return results;
}
/**
@@ -61,12 +68,18 @@
* @param offset Offset into results (for paging)
* @param len Max number of results to return
*/
- public List getAggregation(String group, int offset, int len) {
+ public List getAggregation(String groupHandle, int offset, int len) {
List list = new ArrayList();
- //PlanetGroupData group = planetManager.getGroup(group);
- //if (group != null) {
- // list = planetManager.getAggregation(group, offset, len);
- //}
+ try {
+ Roller roller = RollerFactory.getRoller();
+ PlanetManager planetManager = roller.getPlanetManager();
+ PlanetGroupData group = planetManager.getGroup(groupHandle);
+ if (group != null) {
+ list = planetManager.getAggregation(group, offset, len);
+ }
+ } catch (Exception e) {
+ log.error("ERROR: get aggregation", e);
+ }
return list;
}
@@ -78,10 +91,16 @@
*/
public List getFeed(String feedUrl, int offset, int len) {
List list = new ArrayList();
- //PlanetSubscriptionData sub = planetManager.getSubscription(feedUrl);
- //if (sub != null) {
- //list = sub.getEntries();
- //}
+ try {
+ Roller roller = RollerFactory.getRoller();
+ PlanetManager planetManager = roller.getPlanetManager();
+ PlanetSubscriptionData sub = planetManager.getSubscription(feedUrl);
+ if (sub != null) {
+ list = sub.getEntries();
+ }
+ } catch (Exception e) {
+ log.error("ERROR: get feed", e);
+ }
return list;
}
@@ -91,8 +110,30 @@
* @param offset Offset into results (for paging)
* @param len Max number of results to return
*/
- public List getRankedBlogs(int sinceDays, int offset, int len) {
- return null;
+ public List getRankedSubscriptions(int sinceDays, int offset, int length) {
+ return getRankedSubscriptions(null, sinceDays, offset, length);
}
+ /**
+ * Get PlanetSubscription objects in descending order by Planet ranking.
+ * @param groupHandle Only consider weblogs updated in the last sinceDays
+ * @param sinceDays Only consider weblogs updated in the last sinceDays
+ * @param offset Offset into results (for paging)
+ * @param len Max number of results to return
+ */
+ public List getRankedSubscriptions(String groupHandle, int sinceDays, int offset, int length) {
+ List list = new ArrayList();
+ try {
+ Roller roller = RollerFactory.getRoller();
+ PlanetManager planetManager = roller.getPlanetManager();
+ List subs = planetManager.getTopSubscriptions(groupHandle, offset, length);
+ for (Iterator it = subs.iterator(); it.hasNext();) {
+ PlanetSubscriptionData sub = (PlanetSubscriptionData) it.next();
+ list.add(PlanetSubscriptionDataWrapper.wrap(sub));
+ }
+ } catch (Exception e) {
+ log.error("ERROR: get ranked blogs", e);
+ }
+ return list;
+ }
}