roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eli...@apache.org
Subject svn commit: r470149 - /incubator/roller/trunk/src/org/apache/roller/webservices/json/TagStatsServlet.java
Date Thu, 02 Nov 2006 00:49:10 GMT
Author: eliast
Date: Wed Nov  1 16:49:10 2006
New Revision: 470149

URL: http://svn.apache.org/viewvc?view=rev&rev=470149
Log:
- Added configurable limit to TagStatsServlet.

Modified:
    incubator/roller/trunk/src/org/apache/roller/webservices/json/TagStatsServlet.java

Modified: incubator/roller/trunk/src/org/apache/roller/webservices/json/TagStatsServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/trunk/src/org/apache/roller/webservices/json/TagStatsServlet.java?view=diff&rev=470149&r1=470148&r2=470149
==============================================================================
--- incubator/roller/trunk/src/org/apache/roller/webservices/json/TagStatsServlet.java (original)
+++ incubator/roller/trunk/src/org/apache/roller/webservices/json/TagStatsServlet.java Wed
Nov  1 16:49:10 2006
@@ -26,27 +26,27 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.roller.RollerException;
 import org.apache.roller.business.Roller;
 import org.apache.roller.business.RollerFactory;
 import org.apache.roller.business.UserManager;
 import org.apache.roller.business.WeblogManager;
+import org.apache.roller.config.RollerConfig;
 import org.apache.roller.pojos.TagStat;
-import org.apache.roller.pojos.UserData;
 import org.apache.roller.pojos.WebsiteData;
-import org.apache.roller.util.Utilities;
 
 /**
  * Return list of tags matching a startsWith strings. <br />
  * 
  * @web.servlet name="TagStatsServlet" 
  * @web.servlet-mapping url-pattern="/roller-services/json/tags/*"
+ * 
  * @author Elias Torres (<a href="mailto:eliast@us.ibm.com">eliast@us.ibm.com</a>)
  */
 public class TagStatsServlet extends HttpServlet {
     
-    private final int MAX_LENGTH = 100;
+    // this allows for -1 for no limits.
+    private final int MAX_LENGTH = RollerConfig.getIntProperty("services.json.tags.max",
100);
     
     protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
         doGet(request, response);
@@ -56,9 +56,17 @@
             throws ServletException, IOException {    
         
         int limit = MAX_LENGTH;       
-        try { 
-            limit = Integer.parseInt(request.getParameter("limit"));
+        try {
+            // only change limit, if specified.
+            if(request.getParameter("limit") != null) {
+              limit = Integer.parseInt(request.getParameter("limit"));
+            }
         } catch (Throwable ignored) {}
+        
+        // if we didn't specify no limit and user is abusing, kill it.
+        if(MAX_LENGTH > -1 && limit > MAX_LENGTH) {
+          limit = MAX_LENGTH;
+        }
         
         String pathInfo = request.getPathInfo();
         String handle = null;



Mime
View raw message