You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by ag...@apache.org on 2006/11/16 21:17:21 UTC
svn commit: r475909 - in /incubator/roller/trunk:
src/org/apache/roller/business/ src/org/apache/roller/business/hibernate/
src/org/apache/roller/ui/authoring/struts/actions/
src/org/apache/roller/ui/rendering/model/
src/org/apache/roller/ui/rendering/...
Author: agilliland
Date: Thu Nov 16 12:17:20 2006
New Revision: 475909
URL: http://svn.apache.org/viewvc?view=rev&rev=475909
Log:
Cleaning up UserManager.
- removed method getUsers(offset, length) because it was an unneeded dupe of getUsers(enabled, start, end, offset, length)
- modified method getUsers(enabled, start, end, offset, length) to also accept a weblog object to constrain the result set.
- removed method getUsers(weblog, enabled, offset, length) because it was an unneeded dupe of the new getUsers(weblog, enabled, start, end, offset, length)
now, there is only a single getUsers() method which can handle all cases and this is easiest because that method is only used a handful of times anyways.
Modified:
incubator/roller/trunk/src/org/apache/roller/business/UserManager.java
incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SiteModel.java
incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/UsersPager.java
incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
incubator/roller/trunk/tests/org/apache/roller/business/PermissionTest.java
incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java
incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java
incubator/roller/trunk/web/WEB-INF/jsps/setupBody.jsp
Modified: incubator/roller/trunk/src/org/apache/roller/business/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/UserManager.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/UserManager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/UserManager.java Thu Nov 16 12:17:20 2006
@@ -100,19 +100,14 @@
/**
- * Get all enabled users
- */
- public List getUsers(int offset, int length) throws RollerException;
-
-
- /**
* Lookup a group of users.
*
* The lookup may be constrained to users with a certain enabled status,
* to users created within a certain date range, and the results can be
* confined to a certain offset & length for paging abilities.
*
- * @param enabled True for enabled only, False for disabled only, null for all
+ * @param weblog Confine results to users with permission to a certain weblog.
+ * @param enabled True for enabled only, False for disabled only (or null for all)
* @param startDate Restrict to those created after startDate (or null for all)
* @param endDate Restrict to those created before startDate (or null for all)
* @param offset The index of the first result to return.
@@ -121,24 +116,12 @@
* @throws RollerException If there is a problem.
*/
public List getUsers(
+ WebsiteData weblog,
Boolean enabled,
Date startDate,
Date endDate,
int offset,
int length) throws RollerException;
-
-
- /**
- * Get all users or a website.
- *
- * @param website Get all users of this website (or null for all)
- * @returns List of UserData objects.
- */
- public List getUsers(
- WebsiteData website,
- Boolean enabled,
- int offset,
- int length) throws RollerException;
/**
Modified: incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/business/hibernate/HibernateUserManagerImpl.java Thu Nov 16 12:17:20 2006
@@ -250,7 +250,7 @@
// TODO BACKEND: we must do this in a better fashion, like getUserCnt()?
boolean adminUser = false;
- List existingUsers = this.getUsers(0, 1);
+ List existingUsers = this.getUsers(null, Boolean.TRUE, null, null, 0, 1);
if(existingUsers.size() == 0) {
// Make first user an admin
adminUser = true;
@@ -573,61 +573,50 @@
}
}
- public List getUsers(int offset, int length) throws RollerException {
- return getUsers(Boolean.TRUE, null, null, offset, length);
- }
- public List getUsers(Boolean enabled, Date startDate, Date endDate, int offset, int length) throws RollerException {
- if (endDate == null) endDate = new Date();
+ public List getUsers(WebsiteData weblog, Boolean enabled, Date startDate,
+ Date endDate, int offset, int length)
+ throws RollerException {
+
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
Criteria criteria = session.createCriteria(UserData.class);
- criteria.add(Expression.lt("dateCreated", endDate));
- if (startDate != null) {
- criteria.add(Expression.gt("dateCreated", startDate));
+
+ if (weblog != null) {
+ criteria.createAlias("permissions", "permissions");
+ criteria.add(Expression.eq("permissions.website", weblog));
}
+
if (enabled != null) {
criteria.add(Expression.eq("enabled", enabled));
}
+
+ if (startDate != null) {
+ // if we are doing date range then we must have an end date
+ if(endDate == null) {
+ endDate = new Date();
+ }
+
+ criteria.add(Expression.lt("dateCreated", endDate));
+ criteria.add(Expression.gt("dateCreated", startDate));
+ }
+
if (offset != 0) {
criteria.setFirstResult(offset);
}
if (length != -1) {
criteria.setMaxResults(length);
}
+
criteria.addOrder(Order.desc("dateCreated"));
+
return criteria.list();
+
} catch (HibernateException e) {
throw new RollerException(e);
}
}
- /**
- * Get users of a website
- */
- public List getUsers(WebsiteData website, Boolean enabled, int offset, int length) throws RollerException {
-
- try {
- Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
- Criteria criteria = session.createCriteria(UserData.class);
- if (website != null) {
- criteria.createAlias("permissions","permissions");
- criteria.add(Expression.eq("permissions.website", website));
- }
- if (enabled != null) {
- criteria.add(Expression.eq("enabled", enabled));
- }
- if (offset != 0) {
- criteria.setFirstResult(offset);
- }
- if (length != -1) {
- criteria.setMaxResults(length);
- }
- return criteria.list();
- } catch (HibernateException e) {
- throw new RollerException(e);
- }
- }
public List getUsersStartingWith(String startsWith, Boolean enabled,
int offset, int length) throws RollerException {
Modified: incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/authoring/struts/actions/WeblogEntryFormAction.java Thu Nov 16 12:17:20 2006
@@ -408,7 +408,7 @@
// list of enabled website authors and admins
ArrayList reviewers = new ArrayList();
List websiteUsers = umgr.getUsers(
- entry.getWebsite(), Boolean.TRUE, 0, -1);
+ entry.getWebsite(), Boolean.TRUE, null, null, 0, -1);
// build list of reviewers (website users with author permission)
Iterator websiteUserIter = websiteUsers.iterator();
Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SiteModel.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SiteModel.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SiteModel.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/model/SiteModel.java Thu Nov 16 12:17:20 2006
@@ -377,7 +377,7 @@
try {
Roller roller = RollerFactory.getRoller();
UserManager umgr = roller.getUserManager();
- List users = umgr.getUsers(0, length);
+ List users = umgr.getUsers(null, Boolean.TRUE, null, null, 0, length);
for (Iterator it = users.iterator(); it.hasNext();) {
UserData user = (UserData) it.next();
results.add(UserDataWrapper.wrap(user));
Modified: incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/UsersPager.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/UsersPager.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/UsersPager.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/ui/rendering/pagers/UsersPager.java Thu Nov 16 12:17:20 2006
@@ -135,7 +135,7 @@
UserManager umgr = roller.getUserManager();
List rawUsers = null;
if (letter == null) {
- rawUsers = umgr.getUsers(offset, length + 1);
+ rawUsers = umgr.getUsers(null, Boolean.TRUE, null, null, offset, length + 1);
} else {
rawUsers = umgr.getUsersByLetter(letter.charAt(0), offset, length + 1);
}
Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerMemberHandler.java Thu Nov 16 12:17:20 2006
@@ -139,7 +139,7 @@
private EntrySet getCollection() throws HandlerException {
// get all permissions: for all users, for all websites
try {
- List users = getRoller().getUserManager().getUsers(null, null, null, 0, -1);
+ List users = getRoller().getUserManager().getUsers(null, null, null, null, 0, -1);
List perms = new ArrayList();
for (Iterator i = users.iterator(); i.hasNext(); ) {
UserData user = (UserData)i.next();
Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerUserHandler.java Thu Nov 16 12:17:20 2006
@@ -87,7 +87,7 @@
private EntrySet getCollection() throws HandlerException {
try {
- List users = getRoller().getUserManager().getUsers(null, null, null, 0, -1);
+ List users = getRoller().getUserManager().getUsers(null, null, null, null, 0, -1);
if (users == null) {
users = java.util.Collections.EMPTY_LIST;
}
Modified: incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/adminapi/RollerWeblogHandler.java Thu Nov 16 12:17:20 2006
@@ -100,7 +100,7 @@
private EntrySet getCollection() throws HandlerException {
try {
- List users = getRoller().getUserManager().getUsers(null, null, null, 0, -1);
+ List users = getRoller().getUserManager().getUsers(null, null, null, null, 0, -1);
if (users == null) {
users = Collections.EMPTY_LIST;
}
Modified: incubator/roller/trunk/tests/org/apache/roller/business/PermissionTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/business/PermissionTest.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/business/PermissionTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/business/PermissionTest.java Thu Nov 16 12:17:20 2006
@@ -231,7 +231,7 @@
assertEquals(testWeblog.getId(), ((WebsiteData)weblogs.get(0)).getId());
// assert that website has user
- List users = mgr.getUsers(testWeblog, null, 0, -1);
+ List users = mgr.getUsers(testWeblog, null, null, null, 0, -1);
assertEquals(2, users.size());
// test user can be retired from website
Modified: incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/BookmarksActionTest.java Thu Nov 16 12:17:20 2006
@@ -92,7 +92,7 @@
UserData user = null;
try {
umgr = RollerFactory.getRoller().getUserManager();
- user = (UserData)umgr.getUsers(testWeblog, null, 0, Integer.MAX_VALUE).get(0);
+ user = (UserData)umgr.getUsers(testWeblog, null, null, null, 0, Integer.MAX_VALUE).get(0);
doFilters();
authenticateUser(user.getUserName(), "editor");
} catch (RollerException e) {
Modified: incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java (original)
+++ incubator/roller/trunk/tests/org/apache/roller/ui/authoring/struts/actions/WeblogEntryActionTest.java Thu Nov 16 12:17:20 2006
@@ -82,7 +82,7 @@
UserData user = null;
try {
umgr = RollerFactory.getRoller().getUserManager();
- user = (UserData)umgr.getUsers(testWeblog, null, 0, -1).get(0);
+ user = (UserData)umgr.getUsers(testWeblog, null, null, null, 0, -1).get(0);
authenticateUser(user.getUserName(), "editor");
} catch (RollerException e) {
e.printStackTrace();
Modified: incubator/roller/trunk/web/WEB-INF/jsps/setupBody.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/web/WEB-INF/jsps/setupBody.jsp?view=diff&rev=475909&r1=475908&r2=475909
==============================================================================
--- incubator/roller/trunk/web/WEB-INF/jsps/setupBody.jsp (original)
+++ incubator/roller/trunk/web/WEB-INF/jsps/setupBody.jsp Thu Nov 16 12:17:20 2006
@@ -20,7 +20,7 @@
try {
Roller roller = RollerFactory.getRoller();
pageContext.setAttribute("userCount",
- new Integer(roller.getUserManager().getUsers(0,-1).size()));
+ new Integer(roller.getUserManager().getUsers(null, null, null, null, 0,-1).size()));
pageContext.setAttribute("blogCount",
new Integer(roller.getUserManager().getWebsites(null, null, null, null, null, 0, -1).size()));
pageContext.setAttribute("setupError", Boolean.FALSE);