roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r227237 - in /incubator/roller/branches/roller_2.0/src/org/roller/presentation/ajax: ./ UserDataServlet.java
Date Wed, 03 Aug 2005 17:31:16 GMT
Author: snoopdave
Date: Wed Aug  3 10:31:09 2005
New Revision: 227237

URL: http://svn.apache.org/viewcvs?rev=227237&view=rev
Log:
further group blogging UI refinements

Added:
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/ajax/
    incubator/roller/branches/roller_2.0/src/org/roller/presentation/ajax/UserDataServlet.java

Added: incubator/roller/branches/roller_2.0/src/org/roller/presentation/ajax/UserDataServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/branches/roller_2.0/src/org/roller/presentation/ajax/UserDataServlet.java?rev=227237&view=auto
==============================================================================
--- incubator/roller/branches/roller_2.0/src/org/roller/presentation/ajax/UserDataServlet.java
(added)
+++ incubator/roller/branches/roller_2.0/src/org/roller/presentation/ajax/UserDataServlet.java
Wed Aug  3 10:31:09 2005
@@ -0,0 +1,64 @@
+package org.roller.presentation.ajax;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.roller.RollerException;
+import org.roller.model.Roller;
+import org.roller.model.RollerFactory;
+import org.roller.model.UserManager;
+import org.roller.pojos.UserData;
+
+/**
+ * Return list of users matching a startsWith strings. <br />
+ * Accepts request params (none required):<br />
+ *     startsWith: string to be matched against username and email address<br />
+ *     offset: offset into results (for paging)<br />
+ *     length: number of users to return (max is 50)<br /><br />
+ * List format:<br />
+ *     username0, emailaddress0 <br/>
+ *     username1, emailaddress1 <br/>
+ *     username2, emailaddress2 <br/>
+ *     usernameN, emailaddressN <br/>
+ * 
+ * @web.servlet name="UserDataServlet" 
+ * @web.servlet-mapping url-pattern="/userdata/*"
+ * @author David M Johnson
+ */
+public class UserDataServlet extends HttpServlet {
+    private final int MAX_LENGTH = 50;   
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {    
+        
+        String startsWith = request.getParameter("startsWith");        
+        int offset = 0;
+        int length = MAX_LENGTH;
+        try { offset = Integer.parseInt(request.getParameter("offset"));
+        } catch (Throwable ignored) {}             
+        try { length = Integer.parseInt(request.getParameter("length"));
+        } catch (Throwable ignored) {}
+        
+        Roller roller = RollerFactory.getRoller();
+        try {
+            UserManager umgr = roller.getUserManager();
+            List users = 
+                umgr.getUsersStartingWith(startsWith, offset, length, Boolean.TRUE);
+            Iterator userIter = users.iterator();
+            while (userIter.hasNext()) {
+                UserData user = (UserData)userIter.next();
+                response.getWriter().print(user.getUserName());   
+                response.getWriter().print(",");   
+                response.getWriter().println(user.getEmailAddress());
+            }
+            response.flushBuffer();
+        } catch (RollerException e) {
+            throw new ServletException(e.getMessage());
+        }
+    }
+}



Mime
View raw message