roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r746736 - in /roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin: GlobalCommentManagement.java GlobalConfig.java
Date Sun, 22 Feb 2009 15:33:17 GMT
Author: snoopdave
Date: Sun Feb 22 15:33:17 2009
New Revision: 746736

URL: http://svn.apache.org/viewvc?rev=746736&view=rev
Log:
Fix for https://issues.apache.org/roller/browse/ROL-1788, GET on admin URL erroneously clears
checkboxes

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalCommentManagement.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalCommentManagement.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalCommentManagement.java?rev=746736&r1=746735&r2=746736&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalCommentManagement.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalCommentManagement.java
Sun Feb 22 15:33:17 2009
@@ -25,6 +25,7 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -33,19 +34,19 @@
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.pojos.GlobalPermission;
 import org.apache.roller.weblogger.pojos.Weblog;
-import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
 import org.apache.roller.weblogger.ui.struts2.pagers.CommentsPager;
 import org.apache.roller.weblogger.ui.struts2.util.KeyValueObject;
 import org.apache.roller.weblogger.util.cache.CacheManager;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.roller.weblogger.util.Utilities;
+import org.apache.struts2.interceptor.ServletRequestAware;
 
 
 /**
  * Action for managing global set of comments.
  */
-public class GlobalCommentManagement extends UIAction {
+public class GlobalCommentManagement extends UIAction implements ServletRequestAware {
     
     private static Log log = LogFactory.getLog(GlobalCommentManagement.class);
     
@@ -67,6 +68,10 @@
     // indicates number of comments that would be deleted by bulk removal
     // a non-zero value here indicates bulk removal is a valid option
     private int bulkDeleteCount = 0;
+
+    // work around checkbox issue in cases where user inadvertently does a
+    // GET on the GlobalConfig!save URL and thus sets all checkboxes to false
+    private String httpMethod = "GET";
     
     
     public GlobalCommentManagement() {
@@ -241,6 +246,7 @@
      * Update a list of comments.
      */
     public String update() {
+        if (!"POST".equals(httpMethod)) return ERROR;
         
         try {
             WeblogEntryManager wmgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
@@ -379,5 +385,9 @@
     public void setPager(CommentsPager pager) {
         this.pager = pager;
     }
+
+    public void setServletRequest(HttpServletRequest req) {
+        httpMethod = req.getMethod();
+    }
     
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java?rev=746736&r1=746735&r2=746736&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/admin/GlobalConfig.java
Sun Feb 22 15:33:17 2009
@@ -23,6 +23,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import javax.servlet.http.HttpServletRequest;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -38,12 +39,13 @@
 import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
 import org.apache.roller.weblogger.ui.struts2.util.UIAction;
 import org.apache.struts2.interceptor.ParameterAware;
+import org.apache.struts2.interceptor.ServletRequestAware;
 
 
 /**
  * Action which handles editing of global configuration.
  */
-public class GlobalConfig extends UIAction implements ParameterAware {
+public class GlobalConfig extends UIAction implements ParameterAware, ServletRequestAware
{
     
     private static Log log = LogFactory.getLog(GlobalConfig.class);
     
@@ -61,8 +63,12 @@
     
     // comment plugins that are enabled.  this is what the html form submits to
     private String[] commentPlugins = new String[0];
-    
-    
+
+    // work around checkbox issue in cases where user inadvertently does a
+    // GET on the GlobalConfig!save URL and thus sets all checkboxes to false
+    private String httpMethod = "GET";
+
+
     public GlobalConfig() {
         this.actionName = "globalConfig";
         this.desiredMenu = "admin";
@@ -130,6 +136,7 @@
      * Save global properties.
      */
     public String save() {
+        if (!"POST".equals(httpMethod)) return ERROR;
         
         // only set values for properties that are already defined
         String propName = null;
@@ -248,5 +255,9 @@
     public void setCommentPlugins(String[] commentPlugins) {
         this.commentPlugins = commentPlugins;
     }
+
+    public void setServletRequest(HttpServletRequest req) {
+        httpMethod = req.getMethod();
+    }
     
 }



Mime
View raw message