roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r470488 [2/2] - in /incubator/roller/branches/roller_3.1: ./ custom/ docs/installguide/ docs/templateguide/ docs/templateguide/generated/html/ docs/userguide/ docs/userguide/generated/ docs/userguide/generated/html/ src/org/apache/roller/bu...
Date Thu, 02 Nov 2006 19:40:58 GMT
Modified: incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogFeedRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogFeedRequest.java?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogFeedRequest.java
(original)
+++ incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogFeedRequest.java
Thu Nov  2 11:40:54 2006
@@ -54,7 +54,7 @@
     private String type = null;
     private String format = null;
     private String weblogCategoryName = null;
-    private List   tags = new ArrayList();
+    private List   tags = null;
     private boolean excerpts = false;
     
     // heavyweight attributes
@@ -151,7 +151,7 @@
             log.debug("type = "+this.type);
             log.debug("format = "+this.format);
             log.debug("weblogCategory = "+this.weblogCategoryName);
-            log.debug("tags = "+ Utilities.stringArrayToString((String[])this.tags.toArray(new
String[this.tags.size()]), ","));            
+            log.debug("tags = "+this.tags);
             log.debug("excerpts = "+this.excerpts);
         }
     }

Modified: incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
(original)
+++ incubator/roller/branches/roller_3.1/src/org/apache/roller/ui/rendering/util/WeblogPageRequest.java
Thu Nov  2 11:40:54 2006
@@ -62,7 +62,7 @@
     private String weblogPageName = null;
     private String weblogCategoryName = null;
     private String weblogDate = null;
-    private List tags = new ArrayList();
+    private List tags = null;
     private int pageNum = 0;
     private Map customParams = new HashMap();
     
@@ -197,7 +197,7 @@
             }
             
             // only check for other params if we didn't find an anchor above or tags
-            if(this.weblogAnchor == null && tags.size() == 0) {
+            if(this.weblogAnchor == null && this.tags == null) {
                 if(request.getParameter("date") != null) {
                     String date = request.getParameter("date");
                     if(this.isValidDateString(date)) {
@@ -246,7 +246,7 @@
             log.debug("weblogAnchor = "+this.weblogAnchor);
             log.debug("weblogDate = "+this.weblogDate);
             log.debug("weblogCategory = "+this.weblogCategoryName);
-            log.debug("tags = "+ Utilities.stringArrayToString((String[])this.tags.toArray(new
String[this.tags.size()]), ","));
+            log.debug("tags = "+this.tags);
             log.debug("weblogPage = "+this.weblogPageName);
             log.debug("pageNum = "+this.pageNum);
         }

Modified: incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java (original)
+++ incubator/roller/branches/roller_3.1/src/org/apache/roller/util/URLUtilities.java Thu
Nov  2 11:40:54 2006
@@ -357,6 +357,32 @@
     
     
     /**
+     * Get url to JSON tags service url, optionally for a given weblog.
+     */
+    public static final String getWeblogTagsJsonURL(WebsiteData weblog,
+                                                    boolean absolute) {
+        
+        StringBuffer url = new StringBuffer();
+        
+        if(absolute) {
+            url.append(RollerRuntimeConfig.getAbsoluteContextURL());
+        } else {
+            url.append(RollerRuntimeConfig.getRelativeContextURL());
+        }
+        
+        // json tags service base
+        url.append("/roller-services/json/tags/");
+        
+        // is this for a specific weblog or site-wide?
+        if(weblog != null) {
+            url.append(weblog.getHandle()).append("/");
+        }
+        
+        return url.toString();
+    }
+    
+    
+    /**
      * Get root url for a given *preview* weblog.  
      * Optionally for a certain locale.
      */

Modified: incubator/roller/branches/roller_3.1/src/org/apache/roller/webservices/json/TagStatsServlet.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/src/org/apache/roller/webservices/json/TagStatsServlet.java?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/src/org/apache/roller/webservices/json/TagStatsServlet.java
(original)
+++ incubator/roller/branches/roller_3.1/src/org/apache/roller/webservices/json/TagStatsServlet.java
Thu Nov  2 11:40:54 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,15 +56,46 @@
             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[] path = new String[0];
+        String handle = null;
+        String prefix = null;
         
-        if(!StringUtils.isEmpty(pathInfo)) {
-            path = StringUtils.split(pathInfo, '/');
+        if(pathInfo != null) {
+          
+          // remove first slash
+          if(pathInfo.startsWith("/"))
+            pathInfo = pathInfo.substring(1);
+          
+          // find a slash
+          int slash = pathInfo.indexOf("/");
+          
+          // if .../tags/handle/
+          if(slash > -1) {
+            handle = pathInfo.substring(0,slash);
+            pathInfo = pathInfo.substring(slash+1);
+          }
+          
+          // double-slash .../tags// or .../tags/handle/adfa/
+          if(pathInfo.indexOf("/") > -1) {
+            response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Malformed URL: unncessary
slash.");
+            return;
+          }
+          
+          // keep prefix null unless we have one.
+          if(pathInfo.length() > 0)
+            prefix = pathInfo;
         }
                                         
         Roller roller = RollerFactory.getRoller();
@@ -72,34 +103,27 @@
             response.setContentType("text/html; charset=utf-8");
             
             WeblogManager wmgr = roller.getWeblogManager();
-            WebsiteData website = null;
-            String startsWith = null;            
+            WebsiteData website = null;           
             
             // website handle is always the first path segment,
             // only throw an exception when not found if we have a tag prefix 
-            if(path.length > 0) {
+            if(handle != null) {
                 try {
                     UserManager umgr = RollerFactory.getRoller().getUserManager();
-                    website = umgr.getWebsiteByHandle(path[0], Boolean.TRUE);
-                    if (website == null && path.length > 1)
+                    website = umgr.getWebsiteByHandle(handle, Boolean.TRUE);
+                    if (website == null)
                         throw new RollerException();                
                 } catch (RollerException ex) {
                     response.sendError(HttpServletResponse.SC_NOT_FOUND, "Weblog handle not
found.");
                     return;
                 }    
             }
-            
-            if(path.length == 2) {
-                startsWith = path[1].trim();
-            } else if(path.length == 1 && website == null) {
-                startsWith = path[0].trim();
-            }
                                     
-            List tags = wmgr.getTags(website, null, startsWith, limit);
+            List tags = wmgr.getTags(website, null, prefix, limit);
             
             response.getWriter().println("{");
             response.getWriter().print("  prefix : \"");
-            response.getWriter().print(startsWith == null ? "" : startsWith);
+            response.getWriter().print(prefix == null ? "" : prefix);
             response.getWriter().println("\",");
             response.getWriter().print("  weblog : \"");
             response.getWriter().print(website != null ? website.getHandle() : "");

Modified: incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/PlanetManagerTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/PlanetManagerTest.java?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/PlanetManagerTest.java
(original)
+++ incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/PlanetManagerTest.java
Thu Nov  2 11:40:54 2006
@@ -305,7 +305,7 @@
             TestUtils.endSession(true);
         }
         {
-            planet.refreshEntries();
+            planet.refreshEntries(null);
             TestUtils.endSession(true);
             
             PlanetSubscriptionData sub = planet.getSubscription(feed_url1);
@@ -355,7 +355,7 @@
                 TestUtils.endSession(true);
             }
             {
-                planet.refreshEntries();
+                planet.refreshEntries(null);
                 TestUtils.endSession(true);
                 
                 int count = 0;

Modified: incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/WeblogEntryTest.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/WeblogEntryTest.java?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/WeblogEntryTest.java
(original)
+++ incubator/roller/branches/roller_3.1/tests/org/apache/roller/business/WeblogEntryTest.java
Thu Nov  2 11:40:54 2006
@@ -1,24 +1,19 @@
 /*
-* 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.
-*/
-/*
- * WeblogEntryTest.java
+ * 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
  *
- * Created on April 9, 2006, 4:38 PM
+ *     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.business;
@@ -446,6 +441,52 @@
 
         // teardown our test entry
         TestUtils.teardownWeblogEntry(id);
+        TestUtils.endSession(true);
+    }
+    
+    public void testTagsExist() throws Exception {
+        
+        WeblogManager mgr = RollerFactory.getRoller().getWeblogManager();
+
+        WebsiteData weblog = TestUtils.setupWeblog("tagsExistWeblog1", testUser);
+        String wid = weblog.getId();
+        
+        // setup some test entries to use
+        WeblogEntryData entry = TestUtils.setupWeblogEntry("tagsExistEntry1", testWeblog
+                .getDefaultCategory(), testWeblog, testUser);
+        String id1 = entry.getId();
+        entry.addTag("blahTag");
+        entry.addTag("fooTag");
+        mgr.saveWeblogEntry(entry);
+
+        WeblogEntryData entry2 = TestUtils.setupWeblogEntry("tagsExistEntry2", weblog
+                .getDefaultCategory(), weblog, testUser);
+        String id2 = entry2.getId();
+        entry2.addTag("aaaTag");
+        entry2.addTag("bbbTag");
+        mgr.saveWeblogEntry(entry2);
+        TestUtils.endSession(true);
+        
+        // we'll need these
+        List tags1 = new ArrayList();
+        tags1.add("nonExistTag");
+        
+        List tags2 = new ArrayList();
+        tags2.add("blahtag");
+        
+        // test site-wide
+        this.assertTrue(mgr.getTagComboExists(tags2, null));
+        this.assertFalse(mgr.getTagComboExists(tags1, null));
+        
+        // test weblog specific
+        this.assertTrue(mgr.getTagComboExists(tags2, testWeblog));
+        this.assertFalse(mgr.getTagComboExists(tags1, testWeblog));
+        this.assertFalse(mgr.getTagComboExists(tags2, weblog));
+        
+        // teardown our test data
+        TestUtils.teardownWeblogEntry(id1);
+        TestUtils.teardownWeblogEntry(id2);
+        TestUtils.teardownWeblog(wid);
         TestUtils.endSession(true);
     }
     

Modified: incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/CommentManagementSidebar.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/CommentManagementSidebar.jsp?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/CommentManagementSidebar.jsp
(original)
+++ incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/CommentManagementSidebar.jsp
Thu Nov  2 11:40:54 2006
@@ -80,7 +80,6 @@
             <br />
         </label> 
         <div>
-        <div>
             <html:radio property="pendingString" value="ALL">
                 <fmt:message key="commentManagement.all" /></html:radio><br
/>
             <html:radio property="pendingString" value="ONLY_PENDING">

Modified: incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/WeblogEdit.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/WeblogEdit.jsp?view=diff&rev=470488&r1=470487&r2=470488
==============================================================================
--- incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/WeblogEdit.jsp (original)
+++ incubator/roller/branches/roller_3.1/web/WEB-INF/jsps/authoring/WeblogEdit.jsp Thu Nov
 2 11:40:54 2006
@@ -17,6 +17,7 @@
 -->
 <%@ include file="/taglibs.jsp" %>
 <%@ page import="org.apache.roller.pojos.*" %>
+<%@ page import="org.apache.roller.util.URLUtilities" %>
 <%@ page import="org.apache.roller.ui.authoring.struts.formbeans.WeblogEntryFormEx" %>
 <%@ page import="org.apache.roller.ui.authoring.struts.actions.WeblogEntryPageModel" %>
 <%
@@ -173,7 +174,7 @@
 		<br/>
         <script type="text/javascript">
         <!--
-		new RollerTagsAutoCompleter("entryEditTags", "entryEditTagsChoices", "<%= request.getContextPath()
%>/roller-services/json/tags/<%= model.getWeblogEntry().getWebsite().getHandle() %>",
{ tokens : [' ',','], minChars: 2 });
+		new RollerTagsAutoCompleter("entryEditTags", "entryEditTagsChoices", "<%= URLUtilities.getWeblogTagsJsonURL(model.getWeblogEntry().getWebsite(),
false) %>", { tokens : [' ',','], minChars: 2 });
         // --></script>
     </td></tr> 
     



Mime
View raw message